@aibee/crc-bmap 0.0.88 → 0.0.89

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.
package/lib/bmap.min.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var ye=Object.defineProperty,xe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var Rt=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var L=Math.pow,Dt=(n,r,t)=>r in n?ye(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,M=(n,r)=>{for(var t in r||(r={}))Ee.call(r,t)&&Dt(n,t,r[t]);if(Rt)for(var t of Rt(r))we.call(r,t)&&Dt(n,t,r[t]);return n},tt=(n,r)=>xe(n,be(r));var g=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(r,t)=>(typeof require!="undefined"?require:r)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var s=(n,r,t)=>(Dt(n,typeof r!="symbol"?r+"":r,t),t);var z=(n,r,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},a=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,a);c((t=t.apply(n,r)).next())});var me=g("three");var V=class{constructor(){s(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(r){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),r()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(r){this.tasks.requestAnimation.delete(r),window.cancelAnimationFrame(r)}setTimeout(r,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),r()},t);return this.tasks.timeout.add(e),e}clearTimeout(r){this.tasks.timeout.delete(r),window.clearTimeout(r)}setInterval(r,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),r()},t);return this.tasks.interval.add(e),e}clearInterval(r){this.tasks.interval.delete(r),window.clearInterval(r)}dispose(){this.tasks.requestAnimation.forEach(r=>{window.cancelAnimationFrame(r)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(r=>{window.clearTimeout(r)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(r=>{window.clearInterval(r)}),this.tasks.interval.clear()}};var w=g("three"),Ht=g("three/examples/jsm/controls/MapControls");function Vt(){let n=new w.Scene;return n.background=new w.Color(16777215),n}function _t(){let n=new w.WebGLRenderer({antialias:!0});return n.autoClear=!0,n.setClearAlpha(1),n.setClearColor(16777215),n.setPixelRatio(window.devicePixelRatio),n.shadowMap.enabled=!0,n.shadowMap.autoUpdate=!0,n.shadowMap.type=w.PCFSoftShadowMap,n}function $t(n,r){let t=new w.OrthographicCamera(-n/2,n/2,r/2,-r/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function It(){let n=new w.Group,r=new w.AmbientLight(16777215,2.6);return n.add(r),n}function Ut(n,r){let t=new Ht.MapControls(n,r);return t.enableDamping=!1,t.zoomSpeed=2,t}function Kt(n,r=[]){let t=new w.Shape(n.map(e=>new w.Vector2(...e)));return r.length&&r.forEach(e=>{var i=new w.Path(e.map(o=>new w.Vector2(...o)));t.holes.push(i)}),t}function jt(n=16777215,r=1){let t=new w.DirectionalLight(n,r);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function H(n,r){var t;if(r&&n.children&&n.children.length&&n.children.forEach(e=>{H(e,r)}),n.isMesh){let e=n;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}n.isLight&&((t=n.dispose)==null||t.call(n))}function Zt(n){return/[\u4E00-\u9FA5]+/g.test(n)}var I=g("three");var et=new Map;function Pe(){let n=document.createElement("canvas");n.width=1024,n.height=64;let r=n.getContext("2d",{willReadFrequently:!0});return r.font="54px sans-serif",r.textBaseline="hanging",r.lineWidth=12,r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="white",{canvas:n,ctx:r}}var Ot,$;function Me(){if(!Ot){let{canvas:n,ctx:r}=Pe();Ot=n,$=r}}function _e(n){if(et.has(n))return et.get(n);Me(),$.clearRect(0,0,1024,64);let r=Zt(n)?4:8;$.strokeText(n,2,r),$.fillText(n,2,r);let t=Math.ceil($.measureText(n).width);t=t%2===0?t:t+1,t+=2;let e=$.getImageData(0,0,t,64),i=new I.DataTexture(Uint8Array.from(e.data),t,64,I.RGBAFormat);return i.flipY=!0,i.minFilter=I.LinearFilter,i.magFilter=I.LinearFilter,et.set(n,i),i}function Xt(){et.clear()}function Wt(){$=null,Ot=null}var it=g("three"),W=g("@turf/turf");function b(n,r,t,e){let i=n.clone().project(r),o=t/2,a=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*a+a);return{x:c,y:h}}function zt(n){let r=(0,W.featureCollection)(n.map(e=>(0,W.point)(e)));return(0,W.center)(r).geometry.coordinates}function ot(n,r,t){return n.x>=r.x&&n.x<=t.x&&n.y>=r.y&&n.y<=t.y}function Ue(n){let r=0,t=new it.Vector3;for(let e=1;e<n.length;e++){let i=new it.Vector3(n[e-1][0],n[e-1][1],0),o=new it.Vector3(n[e][0],n[e][1],0),a=o.distanceTo(i);a>r&&(r=a,t=o.clone().sub(i).normalize())}return t}function nt(n,r){return new Proxy(n,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let a=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return a!==i&&r.dispatchEvent({type:`change-${e}`,value:i}),c}})}function N(n,r){return Promise.race([n,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function rt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Yt(n,r){let t=rt("svg");return t.setAttribute("width",n),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function Q(n="2",r){let t=rt("circle");return t.setAttribute("r",n),t.setAttribute("fill",r),t}function st(n){let r=rt("line");return r.setAttribute("stroke",n),r}function Y(n,r){let t=rt("rect");return t.setAttribute("stroke",n),t.setAttribute("fill",r),t}function U(n,r,t){n.setAttribute("cx",`${r}`),n.setAttribute("cy",`${t}`)}function k(n,r,t){r&&(n.setAttribute("x1",`${r.x}`),n.setAttribute("y1",`${r.y}`)),t&&(n.setAttribute("x2",`${t.x}`),n.setAttribute("y2",`${t.y}`))}function A(n,r,t,e,i){n.setAttribute("x",`${r}`),n.setAttribute("y",`${t}`),n.setAttribute("width",`${e}`),n.setAttribute("height",`${i}`)}function qt(){return Promise.resolve()}function We(){return new Promise(n=>{requestAnimationFrame(n)})}function qe(n){return parseInt(n.replace("#","0x"),16)}function Ne(n,r){let t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16),o=Math.round(t*r),a=Math.round(e*r),c=Math.round(i*r);return`#${(1<<24|o<<16|a<<8|c).toString(16).slice(1)}`}function at(n,r=.85){let t,e,i;if(n.startsWith("#"))t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16);else{let a=n.slice(4,-1).split(",");t=parseInt(a[0].trim()),e=parseInt(a[1].trim()),i=parseInt(a[2].trim())}return t=Math.floor(t*r),e=Math.floor(e*r),i=Math.floor(i*r),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}var Nt=g("three/examples/jsm/loaders/GLTFLoader");function Ce(){return new Nt.GLTFLoader}var ct=null,ht=new Map;function Qt(n){if(ht.has(n)){let t=ht.get(n).then(e=>(e.scene=e.scene.clone(),e))}ct||(ct=Ce());let r=new Promise((t,e)=>{ct.load(n,i=>{t(i)},void 0,e)});return ht.set(n,r),r.then(t=>(t.scene=t.scene.clone(),t))}function Jt(){ct=null,ht.clear()}var lt=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function kt(n){return lt?n==="Meta":n==="Control"}var v=g("three"),X=g("@tweenjs/tween.js");var se=g("three");var P=g("three");var Le={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:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single"},T=class extends P.Object3D{constructor(t,e){super();this.context=t;s(this,"geometry");s(this,"material");s(this,"mesh");s(this,"line");s(this,"lineMaterial");s(this,"lineGeometry");s(this,"options");if(this.options=nt(M(M({},Le),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.coords;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new P.Vector3,e=new P.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new P.Vector3(0,0,0);let t=new P.Box3,e=new P.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.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=Kt(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new P.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:at(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}initGradualMaterial(){let{max:t,min:e}=new P.Box3().setFromObject(this),i=t.clone().sub(e),o=Math.max(i.x,i.y,i.z)/2,a=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:o,opacity:this.options.fillOpacity,direction:new P.Vector3(-1,.2,0),max:t,min:e});if(this.options.height<=.1)return this.material=a,a;let c=this.context.materialFactory.createShaderMaterial({gradualColor:[at(this.options.gradualColor[0],.95),at(this.options.gradualColor[1],.95)],center:this.getCenter(),maxValue:o,opacity:this.options.fillOpacity,direction:new P.Vector3(-1,.2,1),max:t,min:e});return this.material=[a,c],[a,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new P.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let o=0;o<i.length;o++){let a=i[o];for(let c=0;c<a.length;c++){let h=a[c],l=c+1===a.length?a[0]:a[c+1];t.push(new P.Vector3(h[0],h[1],e)),t.push(new P.Vector3(l[0],l[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new P.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new P.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}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:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};var O=g("three");var pt=class extends O.Object3D{constructor(){super();s(this,"directionalLight");s(this,"plane");s(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=jt(16777215,.5);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 O.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 O.PlaneGeometry(t,e),o=new O.ShadowMaterial({transparent:!0,opacity:0,side:O.DoubleSide}),a=new O.Mesh(i,o);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(){H(this,!0)}};var dt=g("three");var K=g("three");var Ge={autoUpdate:!0,appendToBody:!1},mt=class extends K.EventDispatcher{constructor(t,e={}){super();this.context=t;s(this,"div");s(this,"element");s(this,"position",new K.Vector3);s(this,"clientPos",{x:0,y:0});s(this,"visible",!0);s(this,"options");s(this,"onUpdate",()=>{this.updatePosition()});this.options=M(M({},Ge),e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):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 K.Box3().setFromObject(this.element).getCenter(new K.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:o,x:a,y:c}=this.context.clientSize,{x:h,y:l}=b(e,this.context.camera,i,o);this.clientPos.x===h&&this.clientPos.y===l&&!t||(this.clientPos={x:h,y:l},this.options.appendToBody&&(this.div.style.left=`${a}px`,this.div.style.top=`${c+o}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${h}px, ${-o+l}px, 0)`:this.dispatchEvent({type:"update-position",x:h,y:l,width:i,height:o}))}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t;this.unRegistryEvent(),this.unBindElement(),(t=this.div)==null||t.remove(),this.div=null}};var Se={texts:[{text:""}],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},J=class extends dt.EventDispatcher{constructor(t,e){var i,o,a;super();this.context=t;s(this,"div");s(this,"textDiv");s(this,"img");s(this,"overlay");s(this,"options");s(this,"visible",!0);s(this,"size",{width:0,height:0});s(this,"position",new dt.Vector3);s(this,"userData",{});s(this,"showTextStatus",!0);s(this,"_changePosition",()=>{this.overlay.updatePosition(!0)});this.options=nt(M(M({},Se),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new mt(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):(this.div.appendChild(this.initIcon()),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.div.firstChild?this.div.insertBefore(this.initText(),this.div.firstChild):this.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())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`)}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return z(this,null,function*(){if(yield qt(),this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}})}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.div=t,this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,a]of Object.entries(e.styles))i.style[o]=a;i.textContent=e.text,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.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,o=e*t,a=i*t,{x:c,y:h}=this.overlay.clientPos;return{left:c-o/2,right:c+o/2,top:this.options.icon?h-a:h-a/2,bottom:this.options.icon?h:h+a/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var D=g("three");var gt=g("three");var te=g("three");var q=class extends te.Object3D{constructor(t){super();this.context=t}dispose(){H(this),this.clear()}};var ut=class extends q{constructor(t){super(t);s(this,"graphicMap",new Map)}getCenter(){return new gt.Box3().setFromObject(this).getCenter(new gt.Vector3)}createGraphic(t){let e=new T(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((o,a)=>{if(a instanceof T){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:a}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var ee=g("lodash");var ft=class extends q{constructor(t){super(t);s(this,"pois",[]);s(this,"debounceCollisionDetection");s(this,"timer",new V);s(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,ee.debounce)(this.collisionDetection,10)}clear(t=!1){return this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new J(this.context,t);return 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),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===0){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.pois.filter(o=>o instanceof J&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:a,right:c,top:h,bottom:l}=i.getBox();if(o===0||!i.options.collision_enable){t.push({left:a,right:c,top:h,bottom:l}),i.parentSetVisible(!0);return}let p=t.some(d=>d.left<c&&d.right>a&&d.top<l&&d.bottom>h);i.parentSetVisible(!p),p||t.push({left:a,right:c,top:h,bottom:l})})}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 C=g("three"),ie=g("@mars3d/heatmap.js"),_=g("@turf/turf");var vt=class extends C.Object3D{constructor(t){super();this.context=t;s(this,"heatmap");s(this,"div");s(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:o,center:a}=this.getBox(t);this.heatmap=(0,ie.create)(M({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),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 C.PlaneGeometry(t,e),o=new C.Texture(this.div.firstChild);o.needsUpdate=!0;let a=new C.MeshBasicMaterial({transparent:!0,side:C.DoubleSide,map:o});a.needsUpdate=!0,this.plane=new C.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new C.Matrix3().makeScale(1,-1).multiply(new C.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new C.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,_.featureCollection)(t.data.map(l=>(0,_.point)([l.x,l.y]))),i=(0,_.bbox)(e),o=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,_.center)(e);return{width:o,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var j=g("three");var yt=class extends j.Object3D{constructor(t,e){super();this.context=t;this.options=e;s(this,"poi",null);s(this,"model",null);this.position.copy(e.position||new j.Vector3(0,0,0)),this.loadModel()}loadModel(){return z(this,null,function*(){let t=yield Qt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t,this.initPoi()})}initPoi(){var e;if(!this.options.icon)return;let t=(e=this.context.currentFloor)==null?void 0:e.addPoi({icon:this.options.icon,icon_size:this.options.icon_size,built_in:!0,level:0});this.poi=t||null,this.model&&t&&(t.position=new j.Box3().setFromObject(this).getCenter(new j.Vector3))}dispose(){var t;H(this),this.model=null,this.poi&&((t=this.context.currentFloor)==null||t.poiLayer.removePoi(this.poi),this.poi=null)}};var xt=class extends D.Object3D{constructor(t){super();this.context=t;s(this,"graphicLayer");s(this,"poiLayer");s(this,"grounds",new Set);s(this,"shadow",new pt);s(this,"heatmap");s(this,"groundUpper",new D.Object3D);s(this,"models",new D.Object3D);s(this,"modelMap",new Map);s(this,"groundMaxHeight",0);this.graphicLayer=new ut(this.context),this.poiLayer=new ft(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper),this.add(this.models)}getPosition(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}createGround(t){let e=new T(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,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+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight,this.models.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}addModel(t){let e=new yt(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new D.Box3().setFromObject(this.groundUpper),e=t.getCenter(new D.Vector3),i=t.getSize(new D.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new vt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new D.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.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var bt=g("three");var F=class extends bt.EventDispatcher{constructor(t){super();this.context=t;s(this,"points",[]);s(this,"svg");s(this,"enable",!0);s(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=Yt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}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:o,offsetY:a}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-a/h*2;return new bt.Vector3(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return b(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var Et=class extends F{constructor(t){super(t);this.context=t;s(this,"circles");s(this,"line");s(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);U(this.circles[0],t.x,t.y),k(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);U(this.circles[1],t.x,t.y),k(this.line,void 0,t)}});s(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",k(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});s(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,a=this.circles[this.points.length];U(a,i,o),this.points.length||k(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Q(e.radius,e.fill),Q(e.radius,e.fill)],this.line=st(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:o}]=this.points;return Math.sqrt(L(i-t,2)+L(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var wt=class extends F{constructor(t){super(t);s(this,"circles",[]);s(this,"lines",[]);s(this,"isClose",!1);s(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&U(this.circles[e],i.x,i.y),e!==0&&k(this.lines[e-1],void 0,i),this.lines[e]&&k(this.lines[e],i)})});s(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",k(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});s(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=Q(c,a);U(l,i,o),this.addCircle(l)}if(this.lines.length&&k(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=st(h);k(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});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],o=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(L(t-o,2)+L(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(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let a=(o+1)%i;e+=t[o][0]*t[a][1]-t[a][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var ne=g("three");var oe=class extends F{constructor(t){super(t);this.context=t;s(this,"rect");s(this,"cornerRect",[]);s(this,"centerRect",[]);s(this,"graphic");s(this,"onUpdate",()=>{if(this.graphic){let t=new ne.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:a,max:c}=t,h=b(a,e,i,o),l=b(c,e,i,o);A(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:d}=h,{x:y,y:f}=l,m=5,E=[{x:p-m,y:f-m},{x:y-m,y:f-m},{x:p-m,y:d-m},{x:y-m,y:d-m}];for(let S=0;S<E.length;S++)A(this.cornerRect[S],E[S].x,E[S].y,m*2,m*2);let x=4,u=(p+y)/2,R=(d+f)/2,B=[{x:u-x,y:f-x},{x:p-x,y:R-x},{x:y-x,y:R-x},{x:u-x,y:d-x}];for(let S=0;S<B.length;S++)A(this.centerRect[S],B[S].x,B[S].y,x*2,x*2)}else{A(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)A(this.cornerRect[t],0,0,0,0),A(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=Y(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Y(e.stroke,"#ffffff"),this.centerRect[i]=Y(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 re=g("three");var Pt=class extends F{constructor(t){super(t);s(this,"startPoint");s(this,"endPoint");s(this,"rect");s(this,"frustum",new re.Frustum);s(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});s(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});s(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});s(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=M({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);A(this.rect,i.x,i.y,o,a)}else A(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Y(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),A(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:o}}}=this,a=b(this.startPoint,e,i,o),c=b(this.endPoint,e,i,o),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},l={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(a=>a instanceof T&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let f=t.getPosition();if(f){let m=b(f,o,a,c);return ot(m,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,d=b(l,o,a,c),y=b(p,o,a,c);return!(!ot(d,e,i)||!ot(y,e,i))}dispose(){this.unRegistryEvent()}};var Mt=class extends se.EventDispatcher{constructor(t){super();this.context=t;s(this,"_list",new Set);s(this,"boxSelection");s(this,"prevPanStatus");s(this,"prevRotateStatus");s(this,"downPoint",null);s(this,"isMultipleSelect",!1);s(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});s(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:a}=this.downPoint;if(Math.sqrt(L(o-e,2)+L(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var d;if(!h.has(p.options.id)){let y=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(p.options.id))||null;y&&y.options.geometry.type==="point"&&(c.push(y),h.add(p.options.id))}}),(lt?t.metaKey:t.ctrlKey)||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});s(this,"onPointerOut",t=>{this.disableBoxSelection()});s(this,"onKeyDown",t=>{kt(t.key)&&this.enableBoxSelection()});s(this,"onKeyUp",t=>{kt(t.key)&&this.disableBoxSelection()});s(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new Pt(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,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)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),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),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};var ae=g("three");var Ct=class extends ae.EventDispatcher{constructor(t){super();this.context=t;s(this,"curGraphics",new Set);s(this,"timer",new V);s(this,"graphicTimerMap",new Map);s(this,"onPointerMove",({graphics:t,pois:e,e:i})=>{let o=e.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!t.length&&!o.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:a}=this.context.config.hover,c=new Set;if(o.length){let l,p=1e4;o.forEach(d=>{let y=e.find(x=>x.options.id===d.options.id),{x:f,y:m}=y.clientPos,E=Math.sqrt(L(f-i.offsetX,2)+L(m-i.offsetY,2));E<p&&(p=E,l=d)}),c.add(l)}c.size||t.forEach(l=>c.add(l)),c.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},a);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{c.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let h=this.curGraphics.size;this.curGraphics.forEach(l=>{c.has(l)||this.curGraphics.delete(l)}),h!==this.curGraphics.size&&this.handleHoverGraphicsChange()});s(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}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 G=g("three");function ce(n){return`${n.x}-${n.y}-${n.z}`}var Lt=class{constructor(r){this.context=r;s(this,"lineMaterialMap",new Map);s(this,"meshStandardMaterialMap",new Map);s(this,"meshBasicMaterialMap",new Map);s(this,"shaderMaterialMap",new Map)}generateLineMaterialKey({color:r,opacity:t}){return`${r}-${t}`}createLineMaterial({color:r,opacity:t}){let e=this.generateLineMaterialKey({color:r,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new G.LineBasicMaterial({color:new G.Color(r).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new G.MeshStandardMaterial({color:new G.Color(r).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}createMeshBasicMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let i=new G.MeshBasicMaterial({color:r,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,i),i}createShaderMaterial({gradualColor:r,center:t,maxValue:e,opacity:i,direction:o,max:a,min:c}){let h=`${r.toString()}-${ce(t)}-${e}-${i}-${ce(o)}`;if(this.shaderMaterialMap.has(h))return this.shaderMaterialMap.get(h);let l=`
1
+ "use strict";(()=>{var ye=Object.defineProperty,xe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var Rt=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var L=Math.pow,Dt=(n,r,t)=>r in n?ye(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,M=(n,r)=>{for(var t in r||(r={}))Ee.call(r,t)&&Dt(n,t,r[t]);if(Rt)for(var t of Rt(r))we.call(r,t)&&Dt(n,t,r[t]);return n},tt=(n,r)=>xe(n,be(r));var g=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(r,t)=>(typeof require!="undefined"?require:r)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var s=(n,r,t)=>(Dt(n,typeof r!="symbol"?r+"":r,t),t);var z=(n,r,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},a=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,a);c((t=t.apply(n,r)).next())});var me=g("three");var V=class{constructor(){s(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(r){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),r()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(r){this.tasks.requestAnimation.delete(r),window.cancelAnimationFrame(r)}setTimeout(r,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),r()},t);return this.tasks.timeout.add(e),e}clearTimeout(r){this.tasks.timeout.delete(r),window.clearTimeout(r)}setInterval(r,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),r()},t);return this.tasks.interval.add(e),e}clearInterval(r){this.tasks.interval.delete(r),window.clearInterval(r)}dispose(){this.tasks.requestAnimation.forEach(r=>{window.cancelAnimationFrame(r)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(r=>{window.clearTimeout(r)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(r=>{window.clearInterval(r)}),this.tasks.interval.clear()}};var w=g("three"),Ht=g("three/examples/jsm/controls/MapControls");function Vt(){let n=new w.Scene;return n.background=new w.Color(16777215),n}function _t(){let n=new w.WebGLRenderer({antialias:!0});return n.autoClear=!0,n.setClearAlpha(1),n.setClearColor(16777215),n.setPixelRatio(window.devicePixelRatio),n.shadowMap.enabled=!0,n.shadowMap.autoUpdate=!0,n.shadowMap.type=w.PCFSoftShadowMap,n}function $t(n,r){let t=new w.OrthographicCamera(-n/2,n/2,r/2,-r/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function It(){let n=new w.Group,r=new w.AmbientLight(16777215,2.6);return n.add(r),n}function Ut(n,r){let t=new Ht.MapControls(n,r);return t.enableDamping=!1,t.zoomSpeed=2,t}function Kt(n,r=[]){let t=new w.Shape(n.map(e=>new w.Vector2(...e)));return r.length&&r.forEach(e=>{var i=new w.Path(e.map(o=>new w.Vector2(...o)));t.holes.push(i)}),t}function jt(n=16777215,r=1){let t=new w.DirectionalLight(n,r);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function H(n,r){var t;if(r&&n.children&&n.children.length&&n.children.forEach(e=>{H(e,r)}),n.isMesh){let e=n;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}n.isLight&&((t=n.dispose)==null||t.call(n))}function Zt(n){return/[\u4E00-\u9FA5]+/g.test(n)}var I=g("three");var et=new Map;function Pe(){let n=document.createElement("canvas");n.width=1024,n.height=64;let r=n.getContext("2d",{willReadFrequently:!0});return r.font="54px sans-serif",r.textBaseline="hanging",r.lineWidth=12,r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="white",{canvas:n,ctx:r}}var Ot,$;function Me(){if(!Ot){let{canvas:n,ctx:r}=Pe();Ot=n,$=r}}function _e(n){if(et.has(n))return et.get(n);Me(),$.clearRect(0,0,1024,64);let r=Zt(n)?4:8;$.strokeText(n,2,r),$.fillText(n,2,r);let t=Math.ceil($.measureText(n).width);t=t%2===0?t:t+1,t+=2;let e=$.getImageData(0,0,t,64),i=new I.DataTexture(Uint8Array.from(e.data),t,64,I.RGBAFormat);return i.flipY=!0,i.minFilter=I.LinearFilter,i.magFilter=I.LinearFilter,et.set(n,i),i}function Xt(){et.clear()}function Wt(){$=null,Ot=null}var it=g("three"),W=g("@turf/turf");function b(n,r,t,e){let i=n.clone().project(r),o=t/2,a=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*a+a);return{x:c,y:h}}function zt(n){let r=(0,W.featureCollection)(n.map(e=>(0,W.point)(e)));return(0,W.center)(r).geometry.coordinates}function ot(n,r,t){return n.x>=r.x&&n.x<=t.x&&n.y>=r.y&&n.y<=t.y}function Ue(n){let r=0,t=new it.Vector3;for(let e=1;e<n.length;e++){let i=new it.Vector3(n[e-1][0],n[e-1][1],0),o=new it.Vector3(n[e][0],n[e][1],0),a=o.distanceTo(i);a>r&&(r=a,t=o.clone().sub(i).normalize())}return t}function nt(n,r){return new Proxy(n,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let a=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return a!==i&&r.dispatchEvent({type:`change-${e}`,value:i}),c}})}function N(n,r){return Promise.race([n,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function rt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Yt(n,r){let t=rt("svg");return t.setAttribute("width",n),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function Q(n="2",r){let t=rt("circle");return t.setAttribute("r",n),t.setAttribute("fill",r),t}function st(n){let r=rt("line");return r.setAttribute("stroke",n),r}function Y(n,r){let t=rt("rect");return t.setAttribute("stroke",n),t.setAttribute("fill",r),t}function U(n,r,t){n.setAttribute("cx",`${r}`),n.setAttribute("cy",`${t}`)}function k(n,r,t){r&&(n.setAttribute("x1",`${r.x}`),n.setAttribute("y1",`${r.y}`)),t&&(n.setAttribute("x2",`${t.x}`),n.setAttribute("y2",`${t.y}`))}function A(n,r,t,e,i){n.setAttribute("x",`${r}`),n.setAttribute("y",`${t}`),n.setAttribute("width",`${e}`),n.setAttribute("height",`${i}`)}function qt(){return Promise.resolve()}function We(){return new Promise(n=>{requestAnimationFrame(n)})}function qe(n){return parseInt(n.replace("#","0x"),16)}function Ne(n,r){let t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16),o=Math.round(t*r),a=Math.round(e*r),c=Math.round(i*r);return`#${(1<<24|o<<16|a<<8|c).toString(16).slice(1)}`}function at(n,r=.85){let t,e,i;if(n.startsWith("#"))t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16);else{let a=n.slice(4,-1).split(",");t=parseInt(a[0].trim()),e=parseInt(a[1].trim()),i=parseInt(a[2].trim())}return t=Math.min(Math.floor(t*r),255),e=Math.min(Math.floor(e*r),255),i=Math.min(Math.floor(i*r),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}var Nt=g("three/examples/jsm/loaders/GLTFLoader");function Ce(){return new Nt.GLTFLoader}var ct=null,ht=new Map;function Qt(n){if(ht.has(n)){let t=ht.get(n).then(e=>(e.scene=e.scene.clone(),e))}ct||(ct=Ce());let r=new Promise((t,e)=>{ct.load(n,i=>{t(i)},void 0,e)});return ht.set(n,r),r.then(t=>(t.scene=t.scene.clone(),t))}function Jt(){ct=null,ht.clear()}var lt=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function kt(n){return lt?n==="Meta":n==="Control"}var v=g("three"),X=g("@tweenjs/tween.js");var se=g("three");var P=g("three");var Le={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:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},T=class extends P.Object3D{constructor(t,e){super();this.context=t;s(this,"geometry");s(this,"material");s(this,"mesh");s(this,"line");s(this,"lineMaterial");s(this,"lineGeometry");s(this,"options");if(this.options=nt(M(M({},Le),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.coords;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new P.Vector3,e=new P.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new P.Vector3(0,0,0);let t=new P.Box3,e=new P.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.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=Kt(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new P.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:at(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}initGradualMaterial(){let{max:t,min:e}=new P.Box3().setFromObject(this),i=t.clone().sub(e),o=Math.max(i.x,i.y,i.z)/2,a=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:o,opacity:this.options.fillOpacity,direction:new P.Vector3(-1,.2,0),max:t,min:e});if(this.options.height<=.1)return this.material=a,a;let c=this.context.materialFactory.createShaderMaterial({gradualColor:[at(this.options.gradualColor[0],this.options.colorFactor),at(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:o,opacity:this.options.fillOpacity,direction:new P.Vector3(-1,.2,1),max:t,min:e});return this.material=[a,c],[a,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new P.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let o=0;o<i.length;o++){let a=i[o];for(let c=0;c<a.length;c++){let h=a[c],l=c+1===a.length?a[0]:a[c+1];t.push(new P.Vector3(h[0],h[1],e)),t.push(new P.Vector3(l[0],l[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new P.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new P.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}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:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};var O=g("three");var pt=class extends O.Object3D{constructor(){super();s(this,"directionalLight");s(this,"plane");s(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=jt(16777215,.5);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 O.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 O.PlaneGeometry(t,e),o=new O.ShadowMaterial({transparent:!0,opacity:0,side:O.DoubleSide}),a=new O.Mesh(i,o);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(){H(this,!0)}};var dt=g("three");var K=g("three");var Ge={autoUpdate:!0,appendToBody:!1},mt=class extends K.EventDispatcher{constructor(t,e={}){super();this.context=t;s(this,"div");s(this,"element");s(this,"position",new K.Vector3);s(this,"clientPos",{x:0,y:0});s(this,"visible",!0);s(this,"options");s(this,"onUpdate",()=>{this.updatePosition()});this.options=M(M({},Ge),e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):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 K.Box3().setFromObject(this.element).getCenter(new K.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:o,x:a,y:c}=this.context.clientSize,{x:h,y:l}=b(e,this.context.camera,i,o);this.clientPos.x===h&&this.clientPos.y===l&&!t||(this.clientPos={x:h,y:l},this.options.appendToBody&&(this.div.style.left=`${a}px`,this.div.style.top=`${c+o}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${h}px, ${-o+l}px, 0)`:this.dispatchEvent({type:"update-position",x:h,y:l,width:i,height:o}))}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t;this.unRegistryEvent(),this.unBindElement(),(t=this.div)==null||t.remove(),this.div=null}};var Se={texts:[{text:""}],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},J=class extends dt.EventDispatcher{constructor(t,e){var i,o,a;super();this.context=t;s(this,"div");s(this,"textDiv");s(this,"img");s(this,"overlay");s(this,"options");s(this,"visible",!0);s(this,"size",{width:0,height:0});s(this,"position",new dt.Vector3);s(this,"userData",{});s(this,"showTextStatus",!0);s(this,"_changePosition",()=>{this.overlay.updatePosition(!0)});this.options=nt(M(M({},Se),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new mt(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):(this.div.appendChild(this.initIcon()),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.div.firstChild?this.div.insertBefore(this.initText(),this.div.firstChild):this.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())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`)}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return z(this,null,function*(){if(yield qt(),this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}})}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.div=t,this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,a]of Object.entries(e.styles))i.style[o]=a;i.textContent=e.text,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.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,o=e*t,a=i*t,{x:c,y:h}=this.overlay.clientPos;return{left:c-o/2,right:c+o/2,top:this.options.icon?h-a:h-a/2,bottom:this.options.icon?h:h+a/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var D=g("three");var gt=g("three");var te=g("three");var q=class extends te.Object3D{constructor(t){super();this.context=t}dispose(){H(this),this.clear()}};var ut=class extends q{constructor(t){super(t);s(this,"graphicMap",new Map)}getCenter(){return new gt.Box3().setFromObject(this).getCenter(new gt.Vector3)}createGraphic(t){let e=new T(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((o,a)=>{if(a instanceof T){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:a}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var ee=g("lodash");var ft=class extends q{constructor(t){super(t);s(this,"pois",[]);s(this,"debounceCollisionDetection");s(this,"timer",new V);s(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,ee.debounce)(this.collisionDetection,10)}clear(t=!1){return this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new J(this.context,t);return 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),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===0){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.pois.filter(o=>o instanceof J&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:a,right:c,top:h,bottom:l}=i.getBox();if(o===0||!i.options.collision_enable){t.push({left:a,right:c,top:h,bottom:l}),i.parentSetVisible(!0);return}let p=t.some(d=>d.left<c&&d.right>a&&d.top<l&&d.bottom>h);i.parentSetVisible(!p),p||t.push({left:a,right:c,top:h,bottom:l})})}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 C=g("three"),ie=g("@mars3d/heatmap.js"),_=g("@turf/turf");var vt=class extends C.Object3D{constructor(t){super();this.context=t;s(this,"heatmap");s(this,"div");s(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:o,center:a}=this.getBox(t);this.heatmap=(0,ie.create)(M({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),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 C.PlaneGeometry(t,e),o=new C.Texture(this.div.firstChild);o.needsUpdate=!0;let a=new C.MeshBasicMaterial({transparent:!0,side:C.DoubleSide,map:o});a.needsUpdate=!0,this.plane=new C.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new C.Matrix3().makeScale(1,-1).multiply(new C.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new C.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,_.featureCollection)(t.data.map(l=>(0,_.point)([l.x,l.y]))),i=(0,_.bbox)(e),o=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,_.center)(e);return{width:o,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var j=g("three");var yt=class extends j.Object3D{constructor(t,e){super();this.context=t;this.options=e;s(this,"poi",null);s(this,"model",null);this.position.copy(e.position||new j.Vector3(0,0,0)),this.loadModel()}loadModel(){return z(this,null,function*(){let t=yield Qt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t,this.initPoi()})}initPoi(){var e;if(!this.options.icon)return;let t=(e=this.context.currentFloor)==null?void 0:e.addPoi({icon:this.options.icon,icon_size:this.options.icon_size,built_in:!0,level:0});this.poi=t||null,this.model&&t&&(t.position=new j.Box3().setFromObject(this).getCenter(new j.Vector3))}dispose(){var t;H(this),this.model=null,this.poi&&((t=this.context.currentFloor)==null||t.poiLayer.removePoi(this.poi),this.poi=null)}};var xt=class extends D.Object3D{constructor(t){super();this.context=t;s(this,"graphicLayer");s(this,"poiLayer");s(this,"grounds",new Set);s(this,"shadow",new pt);s(this,"heatmap");s(this,"groundUpper",new D.Object3D);s(this,"models",new D.Object3D);s(this,"modelMap",new Map);s(this,"groundMaxHeight",0);this.graphicLayer=new ut(this.context),this.poiLayer=new ft(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper),this.add(this.models)}getPosition(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}createGround(t){let e=new T(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,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+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight,this.models.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}addModel(t){let e=new yt(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new D.Box3().setFromObject(this.groundUpper),e=t.getCenter(new D.Vector3),i=t.getSize(new D.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new vt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new D.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.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var bt=g("three");var F=class extends bt.EventDispatcher{constructor(t){super();this.context=t;s(this,"points",[]);s(this,"svg");s(this,"enable",!0);s(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=Yt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}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:o,offsetY:a}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-a/h*2;return new bt.Vector3(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return b(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var Et=class extends F{constructor(t){super(t);this.context=t;s(this,"circles");s(this,"line");s(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);U(this.circles[0],t.x,t.y),k(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);U(this.circles[1],t.x,t.y),k(this.line,void 0,t)}});s(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",k(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});s(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,a=this.circles[this.points.length];U(a,i,o),this.points.length||k(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Q(e.radius,e.fill),Q(e.radius,e.fill)],this.line=st(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:o}]=this.points;return Math.sqrt(L(i-t,2)+L(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var wt=class extends F{constructor(t){super(t);s(this,"circles",[]);s(this,"lines",[]);s(this,"isClose",!1);s(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&U(this.circles[e],i.x,i.y),e!==0&&k(this.lines[e-1],void 0,i),this.lines[e]&&k(this.lines[e],i)})});s(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",k(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});s(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=Q(c,a);U(l,i,o),this.addCircle(l)}if(this.lines.length&&k(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=st(h);k(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});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],o=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(L(t-o,2)+L(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(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let a=(o+1)%i;e+=t[o][0]*t[a][1]-t[a][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var ne=g("three");var oe=class extends F{constructor(t){super(t);this.context=t;s(this,"rect");s(this,"cornerRect",[]);s(this,"centerRect",[]);s(this,"graphic");s(this,"onUpdate",()=>{if(this.graphic){let t=new ne.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:a,max:c}=t,h=b(a,e,i,o),l=b(c,e,i,o);A(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:d}=h,{x:y,y:f}=l,m=5,E=[{x:p-m,y:f-m},{x:y-m,y:f-m},{x:p-m,y:d-m},{x:y-m,y:d-m}];for(let S=0;S<E.length;S++)A(this.cornerRect[S],E[S].x,E[S].y,m*2,m*2);let x=4,u=(p+y)/2,R=(d+f)/2,B=[{x:u-x,y:f-x},{x:p-x,y:R-x},{x:y-x,y:R-x},{x:u-x,y:d-x}];for(let S=0;S<B.length;S++)A(this.centerRect[S],B[S].x,B[S].y,x*2,x*2)}else{A(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)A(this.cornerRect[t],0,0,0,0),A(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=Y(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Y(e.stroke,"#ffffff"),this.centerRect[i]=Y(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 re=g("three");var Pt=class extends F{constructor(t){super(t);s(this,"startPoint");s(this,"endPoint");s(this,"rect");s(this,"frustum",new re.Frustum);s(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});s(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});s(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});s(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=M({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);A(this.rect,i.x,i.y,o,a)}else A(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Y(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),A(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:o}}}=this,a=b(this.startPoint,e,i,o),c=b(this.endPoint,e,i,o),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},l={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(a=>a instanceof T&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let f=t.getPosition();if(f){let m=b(f,o,a,c);return ot(m,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,d=b(l,o,a,c),y=b(p,o,a,c);return!(!ot(d,e,i)||!ot(y,e,i))}dispose(){this.unRegistryEvent()}};var Mt=class extends se.EventDispatcher{constructor(t){super();this.context=t;s(this,"_list",new Set);s(this,"boxSelection");s(this,"prevPanStatus");s(this,"prevRotateStatus");s(this,"downPoint",null);s(this,"isMultipleSelect",!1);s(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});s(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:a}=this.downPoint;if(Math.sqrt(L(o-e,2)+L(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var d;if(!h.has(p.options.id)){let y=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(p.options.id))||null;y&&y.options.geometry.type==="point"&&(c.push(y),h.add(p.options.id))}}),(lt?t.metaKey:t.ctrlKey)||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});s(this,"onPointerOut",t=>{this.disableBoxSelection()});s(this,"onKeyDown",t=>{kt(t.key)&&this.enableBoxSelection()});s(this,"onKeyUp",t=>{kt(t.key)&&this.disableBoxSelection()});s(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new Pt(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,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)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),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),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};var ae=g("three");var Ct=class extends ae.EventDispatcher{constructor(t){super();this.context=t;s(this,"curGraphics",new Set);s(this,"timer",new V);s(this,"graphicTimerMap",new Map);s(this,"onPointerMove",({graphics:t,pois:e,e:i})=>{let o=e.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!t.length&&!o.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:a}=this.context.config.hover,c=new Set;if(o.length){let l,p=1e4;o.forEach(d=>{let y=e.find(x=>x.options.id===d.options.id),{x:f,y:m}=y.clientPos,E=Math.sqrt(L(f-i.offsetX,2)+L(m-i.offsetY,2));E<p&&(p=E,l=d)}),c.add(l)}c.size||t.forEach(l=>c.add(l)),c.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},a);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{c.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let h=this.curGraphics.size;this.curGraphics.forEach(l=>{c.has(l)||this.curGraphics.delete(l)}),h!==this.curGraphics.size&&this.handleHoverGraphicsChange()});s(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}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 G=g("three");function ce(n){return`${n.x}-${n.y}-${n.z}`}var Lt=class{constructor(r){this.context=r;s(this,"lineMaterialMap",new Map);s(this,"meshStandardMaterialMap",new Map);s(this,"meshBasicMaterialMap",new Map);s(this,"shaderMaterialMap",new Map)}generateLineMaterialKey({color:r,opacity:t}){return`${r}-${t}`}createLineMaterial({color:r,opacity:t}){let e=this.generateLineMaterialKey({color:r,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new G.LineBasicMaterial({color:new G.Color(r).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new G.MeshStandardMaterial({color:new G.Color(r).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}createMeshBasicMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let i=new G.MeshBasicMaterial({color:r,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,i),i}createShaderMaterial({gradualColor:r,center:t,maxValue:e,opacity:i,direction:o,max:a,min:c}){let h=`${r.toString()}-${ce(t)}-${e}-${i}-${ce(o)}`;if(this.shaderMaterialMap.has(h))return this.shaderMaterialMap.get(h);let l=`
2
2
  uniform vec3 uColor;
3
3
  uniform vec3 uGradualColor;
4
4
  uniform vec3 center;