@aibee/crc-bmap 0.0.138 → 0.0.139

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 bi=Object.create;var Ge=Object.defineProperty;var Mi=Object.getOwnPropertyDescriptor;var Si=Object.getOwnPropertyNames;var wi=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var y=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var gt=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports);var Ci=(o,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Si(n))!Ti.call(o,i)&&i!==t&&Ge(o,i,{get:()=>n[i],enumerable:!(e=Mi(n,i))||e.enumerable});return o};var Se=(o,n,t)=>(t=o!=null?bi(wi(o)):{},Ci(n||!o||!o.__esModule?Ge(t,"default",{value:o,enumerable:!0}):t,o));var ln=gt((Ar,an)=>{an.exports=function(n,t){return n[0]=t[0],n[1]=t[1],n}});var hn=gt((Rr,cn)=>{var un=ln();cn.exports=function(o,n){Array.isArray(n)||(n=[]),o.length>0&&n.push(un([0,0],o[0]));for(var t=0;t<o.length-1;t++){var e=o[t],i=o[t+1],r=e[0],s=e[1],l=i[0],u=i[1],a=[.75*r+.25*l,.75*s+.25*u],c=[.25*r+.75*l,.25*s+.75*u];n.push(a),n.push(c)}return o.length>1&&n.push(un([0,0],o[o.length-1])),n}});var _n=gt((Or,yn)=>{var Pe=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((n,t)=>n.priority-t.priority)}set(n,t){let e=Number(t);if(isNaN(e))throw new TypeError('"priority" must be a number');return this.keys.has(n)?this.queue.map(i=>(i.key===n&&Object.assign(i,{priority:e}),i)):(this.keys.add(n),this.queue.push({key:n,priority:e})),this.sort(),this.queue.length}next(){let n=this.queue.shift();return this.keys.delete(n.key),n}isEmpty(){return this.queue.length===0}has(n){return this.keys.has(n)}get(n){return this.queue.find(t=>t.key===n)}};yn.exports=Pe});var En=gt((Fr,xn)=>{function vn(o,n){let t=new Map;for(let[e,i]of o)e!==n&&i instanceof Map?t.set(e,vn(i,n)):e!==n&&t.set(e,i);return t}xn.exports=vn});var Sn=gt((Ur,Mn)=>{function Bi(o){let n=Number(o);return!(isNaN(n)||n<=0)}function bn(o){let n=new Map;return Object.keys(o).forEach(e=>{let i=o[e];if(i!==null&&typeof i=="object"&&!Array.isArray(i))return n.set(e,bn(i));if(!Bi(i))throw new Error(`Could not add node at key "${e}", make sure it's a valid node`,i);return n.set(e,Number(i))}),n}Mn.exports=bn});var Cn=gt((Br,Tn)=>{function wn(o){if(!(o instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof o}`);o.forEach((n,t)=>{if(typeof n=="object"&&n instanceof Map){wn(n);return}if(typeof n!="number"||n<=0)throw new Error(`Values must be numbers greater than 0. Found value ${n} at ${t}`)})}Tn.exports=wn});var Ae=gt((Gr,An)=>{var Gi=_n(),zi=En(),Pn=Sn(),Ln=Cn(),Le=class{constructor(n){n instanceof Map?(Ln(n),this.graph=n):n?this.graph=Pn(n):this.graph=new Map}addNode(n,t){let e;return t instanceof Map?(Ln(t),e=t):e=Pn(t),this.graph.set(n,e),this}addVertex(n,t){return this.addNode(n,t)}removeNode(n){return this.graph=zi(this.graph,n),this}path(n,t,e={}){if(!this.graph.size)return e.cost?{path:null,cost:0}:null;let i=new Set,r=new Gi,s=new Map,l=[],u=0,a=[];if(e.avoid&&(a=[].concat(e.avoid)),a.includes(n))throw new Error(`Starting node (${n}) cannot be avoided`);if(a.includes(t))throw new Error(`Ending node (${t}) cannot be avoided`);for(r.set(n,0);!r.isEmpty();){let c=r.next();if(c.key===t){u=c.priority;let f=c.key;for(;s.has(f);)l.push(f),f=s.get(f);break}i.add(c.key),(this.graph.get(c.key)||new Map).forEach((f,m)=>{if(i.has(m)||a.includes(m))return null;if(!r.has(m))return s.set(m,c.key),r.set(m,c.priority+f);let h=r.get(m).priority,d=c.priority+f;return d<h?(s.set(m,c.key),r.set(m,d)):null})}return l.length?(e.trim?l.shift():l=l.concat([n]),e.reverse||(l=l.reverse()),e.cost?{path:l,cost:u}:l):e.cost?{path:null,cost:0}:null}shortestPath(...n){return this.path(...n)}};An.exports=Le});var ve=y("three");var W=class{tasks={requestAnimation:new Set,timeout:new Set,interval:new Set};requestAnimationFrame(n){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),n()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(n){this.tasks.requestAnimation.delete(n),window.cancelAnimationFrame(n)}setTimeout(n,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),n()},t);return this.tasks.timeout.add(e),e}clearTimeout(n){this.tasks.timeout.delete(n),window.clearTimeout(n)}setInterval(n,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),n()},t);return this.tasks.interval.add(e),e}clearInterval(n){this.tasks.interval.delete(n),window.clearInterval(n)}dispose(){this.tasks.requestAnimation.forEach(n=>{window.cancelAnimationFrame(n)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(n=>{window.clearTimeout(n)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(n=>{window.clearInterval(n)}),this.tasks.interval.clear()}};var T=y("three"),ze=y("three/examples/jsm/controls/MapControls");function ke(){let o=new T.Scene;return o.background=new T.Color(16777215),o}function Ve(){let o=new T.WebGLRenderer({antialias:!0});return o.autoClear=!0,o.setClearAlpha(1),o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=T.PCFSoftShadowMap,o}function He(o,n){let t=new T.OrthographicCamera(-o/2,o/2,n/2,-n/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function We(){let o=new T.Group,n=new T.AmbientLight(16777215,2.6);return o.add(n),o}function Xe(o,n){let t=new ze.MapControls(o,n);return t.enableDamping=!1,t.zoomSpeed=1,t}function nt(o,n=[]){let t=new T.Shape(o.map(e=>new T.Vector2(...e)));return n.length&&n.forEach(e=>{var i=new T.Path(e.map(r=>new T.Vector2(...r)));t.holes.push(i)}),t}function qe(o=16777215,n=1){let t=new T.DirectionalLight(o,n);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 Z(o,n){if(n&&o.children&&o.children.length&&o.children.forEach(t=>{Z(t,n)}),o.isMesh){let t=o;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(e=>{e.dispose()}):t.material.dispose())}o.isLight&&o.dispose?.()}function je(o){return/[\u4E00-\u9FA5]+/g.test(o)}var X=y("three"),Mt=new Map,Rt=new Map,Pi=new X.TextureLoader;function Li(){let o=document.createElement("canvas");o.width=1024,o.height=64;let n=o.getContext("2d",{willReadFrequently:!0});return n.font="54px sans-serif",n.textBaseline="hanging",n.lineWidth=12,n.fillStyle="rgba(0,0,0,1)",n.strokeStyle="white",{canvas:o,ctx:n}}var we,mt;function Ai(){if(!we){let{canvas:o,ctx:n}=Li();we=o,mt=n}}function Ye(o){if(Rt.has(o))return Rt.get(o);Ai(),mt.clearRect(0,0,1024,64);let n=je(o)?4:8;mt.strokeText(o,2,n),mt.fillText(o,2,n);let t=Math.ceil(mt.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=mt.getImageData(0,0,t,64),i=new X.DataTexture(Uint8Array.from(e.data),t,64,X.RGBAFormat);return i.flipY=!0,i.minFilter=X.LinearFilter,i.magFilter=X.LinearFilter,Rt.set(o,i),i}function $e(){Rt.forEach((o,n)=>{o.dispose()}),Mt.forEach(o=>{o instanceof Promise?o.then(n=>n.dispose()):o.dispose()}),Rt.clear(),Mt.clear()}function Ze(){mt=null,we=null}async function Ke(o){if(Mt.has(o))return Mt.get(o);let n=Pi.loadAsync(o);return n.then(t=>{t.format=X.RGBAFormat,t.magFilter=X.LinearFilter,t.minFilter=X.LinearFilter,t.colorSpace="srgb",Mt.set(o,t)}),Mt.set(o,n),n}var L=y("three"),St=y("@turf/turf");function b(o,n,t,e){let i=o.clone().project(n),r=t/2,s=e/2,l=Math.round(i.x*r+r),u=Math.round(-i.y*s+s);return{x:l,y:u}}function Bt(o){let n=(0,St.featureCollection)(o.map(e=>(0,St.point)(e)));return(0,St.center)(n).geometry.coordinates}function Gt(o,n,t){return o.x>=n.x&&o.x<=t.x&&o.y>=n.y&&o.y<=t.y}function ur(o){let n=0,t=new L.Vector3;for(let e=1;e<o.length;e++){let i=new L.Vector3(o[e-1][0],o[e-1][1],0),r=new L.Vector3(o[e][0],o[e][1],0),s=r.distanceTo(i);s>n&&(n=s,t=r.clone().sub(i).normalize())}return t}function I(o,n){return Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2)}function ht(o){let n=0;for(let t=0;t<o.length-1;t++)n+=I(o[t],o[t+1]);return n}function zt(o,n,t){let e=new L.Vector2(n[0]-o[0],n[1]-o[1]),i=new L.Vector2(n[0]-t[0],n[1]-t[1]),s=e.angleTo(i)*180/Math.PI,l=new L.Vector2(n[0]-o[0],n[1]-o[1]);return new L.Vector2(t[0]-o[0],t[1]-o[1]).cross(l)>0?s:-s}function Je(o,n){let t=Math.min(I(o[0][0],o[0][1]),I(o[0][2],o[0][1]))-1;n||(n=Bt(o[0]));let e=Ri(n,t),i=new L.Vector2(o[0][0][0],o[0][0][1]),r=new L.Vector2(o[0][1][0],o[0][1][1]),s=new L.Vector2(o[0][2][0],o[0][2][1]),u=(i.distanceTo(r)>r.distanceTo(s)?r.clone().sub(i):s.clone().sub(r)).angleTo(new L.Vector2(0,1)),a=new L.Matrix3;return a.multiply(new L.Matrix3().translate(n[0],n[1])).multiply(new L.Matrix3().rotate(u)).multiply(new L.Matrix3().translate(-n[0],-n[1])),[e.map(c=>{let p=new L.Vector2(c[0],c[1]).applyMatrix3(a);return[p.x,p.y]})]}function Ri(o,n){let t=n/2;return[[o[0]-t,o[1]+t],[o[0]+t,o[1]+t],[o[0]+t,o[1]-t],[o[0]-t,o[1]-t],[o[0]-t,o[1]+t]]}function Qe(o,n){let t=0,e=1/0,[i,r]=n;for(let s=0;s<o.length-1;s++){let[l,u]=o[s],[a,c]=o[s+1],p=Math.min(l,a)<=i&&i<=Math.max(l,a),f=Math.min(u,c)<=r&&r<=Math.max(u,c);if(p&&f){let m=Math.abs((a-l)*(r-u)-(c-u)*(i-l));m<e&&(e=m,t=s)}}return t}function tn(o,n){let t=o[0],e=o[1],i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){let l=n[r][0],u=n[r][1],a=n[s][0],c=n[s][1];u>e!=c>e&&t<(a-l)*(e-u)/(c-u)+l&&(i=!i)}return i}function wt(o,n){return new Proxy(o,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,r)=>{let s=Reflect.get(t,e,r),l=Reflect.set(t,e,i,r);return s!==i&&n.dispatchEvent({type:`change-${e}`,value:i}),l}})}function yt(o,n){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),n)})])}function kt(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function en(o,n){let t=kt("svg");return t.setAttribute("width",o),t.setAttribute("height",n),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function It(o="2",n){let t=kt("circle");return t.setAttribute("r",o),t.setAttribute("fill",n),t}function Vt(o){let n=kt("line");return n.setAttribute("stroke",o),n}function Tt(o,n){let t=kt("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",n),t}function _t(o,n,t){o.setAttribute("cx",`${n}`),o.setAttribute("cy",`${t}`)}function K(o,n,t){n&&(o.setAttribute("x1",`${n.x}`),o.setAttribute("y1",`${n.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function J(o,n,t,e,i){o.setAttribute("x",`${n}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}function nn(){return Promise.resolve()}function dr(){return new Promise(o=>{requestAnimationFrame(o)})}function mr(o){return parseInt(o.replace("#","0x"),16)}function yr(o,n){let t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16),r=Math.round(t*n),s=Math.round(e*n),l=Math.round(i*n);return`#${(1<<24|r<<16|s<<8|l).toString(16).slice(1)}`}function ut(o,n=.85){let t,e,i;if(o.startsWith("#"))t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16);else{let s=o.slice(4,-1).split(",");t=parseInt(s[0].trim()),e=parseInt(s[1].trim()),i=parseInt(s[2].trim())}return t=Math.min(Math.floor(t*n),255),e=Math.min(Math.floor(e*n),255),i=Math.min(Math.floor(i*n),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}var rn=y("three/examples/jsm/loaders/GLTFLoader");function Ii(){return new rn.GLTFLoader}var Ht=null,Wt=new Map;function Xt(o){if(Wt.has(o)){let t=Wt.get(o).then(e=>(e.scene=e.scene.clone(),e))}Ht||(Ht=Ii());let n=new Promise((t,e)=>{Ht.load(o,i=>{t(i)},void 0,e)});return Wt.set(o,n),n.then(t=>(t.scene=t.scene.clone(),t))}function on(){Ht=null,Wt.clear()}var qt=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function Te(o){return qt?o==="Meta":o==="Control"}var Ce="__once__",sn=class{events=new Map;on(n,t){if(typeof t!="function")return;let e=this.events.get(n);return e?e.add(t):this.events.set(n,new Set([t]))}once(n,t){if(typeof t!="function")return;let e=`${Ce}${n}`,i=this.events.get(e);return i?i.add(t):this.events.set(e,new Set([t]))}off(n,t){let e=this.events.get(n),i=this.events.get(`${Ce}${n}`);!e&&!i||(t===void 0&&(e?.clear(),i?.clear()),e?.has(t)&&e.delete(t),i?.has(t)&&i.delete(t))}offAll(){this.events.clear()}emit(n,...t){let e=this.events.get(n),i=this.events.get(`${Ce}${n}`);!e&&!i||(e?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.clear())}};var Nt=(t=>(t.SWITCH_FLOOR_BEFORE="switch_floor_before",t.SWITCH_FLOOR_AFTER="switch_floor_after",t))(Nt||{});function Q(o){return Object.keys(o).sort().map(n=>`${n}=${o[n]}`).join("&")}function Cr(o,n){return new Promise((t,e)=>{let i=new XMLHttpRequest;i.open("GET",o,!0),Object.keys(n.headers||{}).forEach(r=>{i.setRequestHeader(r,n.headers[r])}),n.responseType&&(i.responseType=n.responseType),i.onload=()=>{if(i.status>=200&&i.status<300)if(n.responseType==="arraybuffer")t(i.response);else try{let r=JSON.parse(i.responseText);t(r)}catch(r){e(r)}else e(i.statusText)},i.onerror=()=>{e(i.statusText)},i.send()})}var Ct=class o{keySet=new Set;static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}genUniqueKey(){let n=o.createKey();for(;this.keySet.has(n);)n=o.createKey();return n}removeKey(n){this.keySet.delete(n)}dispose(){this.keySet.clear()}};var Pt=y("three"),pn=Se(hn(),1);function Ni(o,n){let t=o.clone().normalize(),e=n.clone().normalize();return Math.acos(t.dot(e))}function Di(o){let n=0;return o.reduce(([t,e],[i,r])=>(n+=Math.sqrt((i-t)**2+(r-e)**2),[i,r])),n/o.length}function fn(o,n=.25){if(Di(o)<n)return o;let t=(0,pn.default)(o);return fn(t,n)}function dn(o,n=!1,t=!0,e=5,i=150,r=3){let s=[],l=!n;if(s.push(o[0]),o.length<2)return s;for(let a=0;a<o.length-2;a+=1){let c=o[a],p=o[a+1],f=o[a+2],m=new Pt.Vector2(c[0]-p[0],c[1]-p[1]),h=new Pt.Vector2(f[0]-p[0],f[1]-p[1]),d=Ni(m,h)/Math.PI*180,g=m.length()+h.length();(!l||d<i&&g>.01||g>e)&&(s.push(o[a+1]),l=!0)}if(s.push(o[o.length-1]),!t)return s;let u=[];u.push(s[0]);for(let a=0;a<s.length-2;a+=1){let c=new Pt.Vector2(s[a][0],s[a][1]),p=new Pt.Vector2(s[a+1][0],s[a+1][1]),f=new Pt.Vector2(s[a+2][0],s[a+2][1]),m=c.distanceTo(p)/2,h=f.distanceTo(p)/2,d=p.clone(),g=p.clone();d.add(c.clone().sub(p).normalize().multiplyScalar(m>r?r/2:m)),g.add(f.clone().sub(p).normalize().multiplyScalar(h>r?r/2:h));let v=[[d.x,d.y],[p.x,p.y],[g.x,g.y]];u.push(...fn(v,r/25))}return u.push(s[s.length-1]),Oi(u)}function Oi(o){if(o.length<=1)return o;let n=[],t;return o.forEach(([e,i])=>{t?e===t[0]&&i===t[1]||(t=[e,i],n.push([e,i])):(t=[e,i],n.push([e,i]))}),n}function gn(o,n,t){let e=Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2);if(e===0)return{distance:Math.sqrt((o[0]-n[0])**2+(o[1]-n[1])**2),closestPoint:n.slice(0)};let i=Math.max(0,Math.min(1,((o[0]-n[0])*(t[0]-n[0])+(o[1]-n[1])*(t[1]-n[1]))/e**2)),r=[n[0]+i*(t[0]-n[0]),n[1]+i*(t[1]-n[1])];return{distance:Math.sqrt((o[0]-r[0])**2+(o[1]-r[1])**2),closestPoint:r}}function mn(o,n,t){let[e,i]=o,[r,s]=n,l=Math.sqrt(Math.pow(r-e,2)+Math.pow(s-i,2));if(l===0||l<t)return[...n];let u=t/l,a=e+(r-e)*u,c=i+(s-i)*u;return[a,c]}var Fi=(a=>(a.START="start",a.END="end",a.FRONT="front",a.RIGHT="right",a.LEFT="left",a.RIGHT_FRONT="right_front",a.LEFT_FRONT="left_front",a.RIGHT_BACK="right_back",a.LEFT_BACK="left_back",a))(Fi||{});function Ui(o,n,t){let e=zt(o,n,t);return 180-Math.abs(e)<15?"front":e>135?"right_front":e<-135?"left_front":e<=135&&e>=60?"right":e>=-135&&e<=-60?"left":e<60&&e>0?"right_back":e>-60&&e<0?"left_back":"front"}function Nr(o){let n=[{direction:"start",distance:I(o[0],o[1]),points:[o[0],o[1]]}];for(let t=2;t<o.length;t++){let e=Ui(o[t-2],o[t-1],o[t]);if(e==="front"){let i=n[n.length-1],r=I(o[t-1],o[t]);i.distance+=r,t!==2&&i.points.push(o[t-1])}else n.push({direction:e,distance:I(o[t-1],o[t]),points:[o[t-1],o[t]]})}return n.push({direction:"end",distance:0,points:[o[o.length-1]]}),n}var it=Se(Ae(),1);var q="___",Rn=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;lineMap=new Map;baseRoute=new it.default;escalatorRoute=new it.default;straightLadderRoute=new it.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${q}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${q}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${q}${e.from}`,r=`${t.floor}${q}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=I(s,l);this.addLineItem(i,r,u),e.direction==="double"&&this.addLineItem(r,i,u)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${q}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${q}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${q}${r.start.id}`,u=`${r.end.floor}${q}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new it.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new it.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new it.default(n)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${q}${n.nodeId}`);if(t){let[e,i]=t.split(q);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=I(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(console.log(i,r),r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+ht(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${q}${n.id}`,r=`${t.floor}${q}${t.id}`,s=e.path(i,r);if(console.log(i,r,s),!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new it.default,this.escalatorRoute=new it.default,this.straightLadderRoute=new it.default}};var j=Se(Ae(),1);var G="___",In=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;parkingMap=new Map;lineMap=new Map;baseRoute=new j.default;escalatorRoute=new j.default;straightLadderRoute=new j.default;forwardLineMap=new Map;forwardRoute=new j.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${G}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${G}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}e.type==="parkingSpace"&&this.parkingMap.set(`${e.floor}${G}${e.name}`,e)}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${G}${e.from}`,r=`${t.floor}${G}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=I(s,l);switch(this.addLineItem(i,r,u),this.addLineItem(r,i,u),e.direction){case"double":this.addLineItem(i,r,u,this.forwardLineMap),this.addLineItem(r,i,u,this.forwardLineMap);break;case"single":this.addLineItem(i,r,u,this.forwardLineMap);break;case"back":this.addLineItem(r,i,u,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${G}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${G}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${G}${r.start.id}`,u=`${r.end.floor}${G}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new j.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new j.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new j.default(n)}initForwardRoute(){this.forwardRoute=new j.default(this.forwardLineMap)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility||n.parkingSpace&&n.floor?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${G}${n.nodeId}`);if(t){let[e,i]=t.split(G);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=I(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){if(n.parkingSpace){let e=this.parkingMap.get(`${n.floor}${G}${n.parkingSpace}`);if(e)return{floor:e.floor,id:e.id}}let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;case"forward":s=this.getForwardPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+ht(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${G}${n.id}`,r=`${t.floor}${G}${t.id}`,s=e.path(i,r);if(!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId,p.distance=ht(p.points)}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId,distance:0})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}getForwardPath(n,t){return this.getRoutePath(n,t,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new j.default,this.escalatorRoute=new j.default,this.straightLadderRoute=new j.default}};function Nn(o){return o.replace(/[A-Z]/g,n=>"_"+n.toLowerCase()).replace(/^_/,"")}var Dn=new Ct;function Lt(o,n,t){return new Promise((e,i)=>{let r=Dn.genUniqueKey(),s=({data:l})=>{l.type===`${n}_result`&&l.key===r&&(Dn.removeKey(r),self.removeEventListener("message",s),l.error?i(l.error):e(l.data))};o.addEventListener("message",s),o.postMessage({type:n,key:r,data:t})})}function jr(o){let n={};for(let e in o)e.startsWith("on")&&(n[Nn(e.slice(2))]=o[e]);let t=async({data:e})=>{if(n[e.type])try{let i=await n[e.type](e.data);self.postMessage({type:`${e.type}_result`,key:e.key,data:i})}catch(i){self.postMessage({type:`${e.type}_result`,key:e.key,error:i})}else self.postMessage({type:`${e.type}_result`,key:e.key,error:"no_event"})};return self.addEventListener("message",t),()=>{self.removeEventListener("message",t)}}var M=y("three"),bt=y("@tweenjs/tween.js");var jn=y("three");var x=y("three");var Re={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},U=class extends x.Object3D{constructor(t,e){super();this.context=t;if(this.options=wt({...Re,...e},this),this.options.geometry.type==="point"){let[i,r]=this.options.geometry.coords;return this.position.set(i,r,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})=>{if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),this.lineGeometry?.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}geometry;material;mesh;line;lineMaterial;lineGeometry;options;getCenter(){if(this.options.geometry.type==="point")return this.position.clone();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/2),t}init(){this.initDoor(),this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&this.options.strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initDoor(){if(this.options.doors&&this.options.geometry.type==="polygon"){let t=this.options.geometry.coords[0];this.options.doors.forEach(e=>{let i=e.type==="single"?.5:1,r=.5,s=Qe(t,e.coord),l=new x.Vector2(...e.coord),u=new x.Vector2(...t[s]).sub(new x.Vector2(...e.coord)).normalize(),a=new x.Vector2().addVectors(l,u.clone().multiplyScalar(i)),c=new x.Vector2().addVectors(l,u.clone().multiplyScalar(-i)),p=new x.Vector2(-u.y,u.x),f=new x.Vector2().addVectors(a,p.clone().multiplyScalar(r));tn([f.x,f.y],t)||(p.multiplyScalar(-1),f=new x.Vector2().addVectors(a,p.clone().multiplyScalar(r)));let m=new x.Vector2().addVectors(c,p.clone().multiplyScalar(r)),h=[[a.x,a.y],[f.x,f.y],[m.x,m.y],[c.x,c.y]];this.options.geometry.coords=[[...t.slice(0,s+1),...h,...t.slice(s+1)]],t=this.options.geometry.coords[0]})}}initGeometry(){let t=nt(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new x.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:ut(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getMaxAndMin(t,e){let i=new x.Box3().setFromObject(this),r=t.clone().add(e.clone().multiplyScalar(1e3)),s=new x.Ray(r,e.clone().multiplyScalar(-1)),l=new x.Vector3;s.intersectBox(i,l);let u=t.clone().add(e.clone().multiplyScalar(-1e3)),a=new x.Ray(u,e.clone()),c=new x.Vector3;return a.intersectBox(i,c),{max:c,min:l}}initGradualMaterial(){let{max:t,min:e}=new x.Box3().setFromObject(this),i=t.clone().sub(e),r=Math.max(i.x,i.y,i.z)/2,s=this.getPosition(),l=new x.Vector3(-1,.2,0).normalize(),{max:u,min:a}=this.getMaxAndMin(s,l),c=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:r,opacity:this.options.fillOpacity,direction:new x.Vector3(-1,.2,0),max:u,min:a});if(this.options.height<=.1)return this.material=c,c;let p=this.getCenter(),f=new x.Vector3(-1,.2,1).normalize(),{max:m,min:h}=this.getMaxAndMin(p,f),d=this.context.materialFactory.createShaderMaterial({gradualColor:[ut(this.options.gradualColor[0],this.options.colorFactor),ut(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:r,opacity:this.options.fillOpacity,direction:new x.Vector3(-1,.2,1),max:m,min:h});return this.material=[c,d],[c,d]}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 x.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 r=0;r<i.length;r++){let s=i[r];for(let l=0;l<s.length;l++){let u=s[l],a=l+1===s.length?s[0]:s[l+1];t.push(new x.Vector3(u[0],u[1],e)),t.push(new x.Vector3(a[0],a[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new x.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new x.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;this.mesh.updateMatrixWorld(!0);let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:r}=e[0];return{position:i,distance:r}}return!1}dispose(){this.geometry?.dispose(),this.line?.geometry.dispose(),this.clear()}};var Y=y("three");var jt=class extends Y.Object3D{directionalLight;plane;basicOpacity=.07;constructor(){super(),this.directionalLight=this.initLight(),this.initPlane()}initLight(){let n=qe(16777215,.5);return n.position.set(0,0,100),this.add(n),n}changeLightCamera(n){let t=n.x,e=n.y;this.directionalLight.shadow.camera.left=-t,this.directionalLight.shadow.camera.right=t,this.directionalLight.shadow.camera.top=e,this.directionalLight.shadow.camera.bottom=-e,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(t,e)}changeLightColor(n){this.directionalLight.color=new Y.Color(n)}setPosition(n){this.position.copy(n),this.directionalLight.position.set(-n.x/2,-n.y/2,100)}initPlane(n=1e3,t=1e3){let e=new Y.PlaneGeometry(n,t),i=new Y.ShadowMaterial({transparent:!0,opacity:0,side:Y.DoubleSide}),r=new Y.Mesh(e,i);return r.receiveShadow=!0,r.position.z=-10,this.add(r),this.plane=r,r}setTarget(n){this.directionalLight.target=n}transformOpacity(n){return n*this.basicOpacity}setOpacity(n){this.plane.material.opacity=this.transformOpacity(n)}dispose(){Z(this,!0)}};var $t=y("three");var S=y("three");var On=y("lodash");var ki={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},Yt=class extends S.EventDispatcher{constructor(t,e={}){super();this.context=t;this.options={...ki,...e},this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}div;element;position=new S.Vector3;clientPos={x:0,y:0};visible=!0;options;placement="top";observer=null;initObserver(){let t=new MutationObserver((0,On.debounce)(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){if(this.element instanceof U&&this.element.options.geometry.type==="polygon"){let{max:r,min:s}=new S.Box3().setFromObject(this.element),l=(r.x+s.x)/2,u=(r.y+s.y)/2;return{left:new S.Vector3(s.x,u,r.z),leftTop:new S.Vector3(s.x,r.y,r.z),top:new S.Vector3(l,r.y,r.z),rightTop:new S.Vector3(r.x,r.y,r.z),right:new S.Vector3(r.x,u,r.z),rightBottom:new S.Vector3(r.x,s.y,r.z),bottom:new S.Vector3(l,s.y,r.z),leftBottom:new S.Vector3(s.x,s.y,r.z),center:new S.Vector3(l,u,r.z)}}let{x:t,y:e,z:i}=this.element?.getPosition?.()||this.position;return{left:new S.Vector3(t,e,i),leftTop:new S.Vector3(t,e,i),top:new S.Vector3(t,e,i),rightTop:new S.Vector3(t,e,i),right:new S.Vector3(t,e,i),rightBottom:new S.Vector3(t,e,i),bottom:new S.Vector3(t,e,i),leftBottom:new S.Vector3(t,e,i),center:new S.Vector3(t,e,i)}}getPlacementScreenPosition(){let{width:t,height:e}=this.context.clientSize,i=this.getPlacementPosition();return Object.keys(i).reduce((r,s)=>{let{x:l,y:u}=b(i[s],this.context.camera,t,e);return r[s]={x:l,y:u},r},{})}checkOverflow(t,e){let{width:i,height:r}=this.context.clientSize;return e.x>0&&t.x<i&&e.y<r&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:e}=this.div,i=this.getPlacementScreenPosition(),r=t/2,s=e/2,l=[{type:"center",getBox(u,a){return{max:{x:r+u,y:a-e},min:{x:u-r,y:a}}}},{type:"left",getBox(u,a){return{max:{x:u,y:a-s},min:{x:u-t,y:a+s}}}},{type:"leftTop",getBox(u,a){return{max:{x:u,y:a-e},min:{x:u-t,y:a}}}},{type:"top",getBox(u,a){return{max:{x:u+r,y:a-e},min:{x:u-r,y:a}}}},{type:"rightTop",getBox(u,a){return{max:{x:u+t,y:a-e},min:{x:u,y:a}}}},{type:"right",getBox(u,a){return{max:{x:u+t,y:a-s},min:{x:u,y:a+s}}}},{type:"rightBottom",getBox(u,a){return{max:{x:u+t,y:a},min:{x:u,y:a+e}}}},{type:"bottom",getBox(u,a){return{max:{x:u+r,y:a},min:{x:u-r,y:a+e}}}},{type:"leftBottom",getBox(u,a){return{max:{x:u,y:a},min:{x:u-t,y:a+s}}}}];for(let u=0;u<l.length;u++){let a=l[u],c=i[a.type],{max:p,min:f}=a.getBox(c.x,c.y);if(this.checkOverflow(p,f))return{type:a.type,position:c}}return{type:"center",position:i.center}}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}usePlacement(){let t=this.getPlacement();this.div.className=`overlay_${t.type}`,this._updatePosition(t.position.x,t.position.y)}bindElement(t){this.element=t,this.options.autoChangePlacement&&this.initObserver(),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 S.Box3().setFromObject(this.element).getCenter(new S.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:r}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=r}_updatePosition(t,e){this.clientPos={x:t,y:e};let{width:i,height:r,x:s,y:l}=this.context.clientSize;this.options.appendToBody&&(this.div.style.left=`${s}px`,this.div.style.top=`${l+r}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${t}px, ${-r+e}px, 0)`:this.dispatchEvent({type:"update-position",x:t,y:e,width:i,height:r})}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:r}=this.context.clientSize,{x:s,y:l}=b(e,this.context.camera,i,r);this.clientPos.x===s&&this.clientPos.y===l&&!t||this._updatePosition(s,l)}onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()};registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.observer?.disconnect(),this.div?.remove(),this.div=null}};var Vi={texts:[{text:""}],level:1,icon_position:"bottom",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},vt=class extends $t.EventDispatcher{constructor(t,e){super();this.context=t;this.options=wt({...Vi,...e},this),this.position.set(e.position?.x||0,e.position?.y||0,e.position?.z||0),this.overlay=new Yt(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:i,y:r,height:s})=>{this.overlay.div.style.transform=`translate3d(calc(${i}px - 50%), calc(${-s+r}px - ${this.options.icon&&this.options.icon_position!=="center"?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:i})=>{i?this.img?this.img.setAttribute("src",i):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:i})=>{let r=this.textDiv;if(r){let s=this.initText();this.div.replaceChild(s,r)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",({value:i})=>{this.overlay.setOpacity(i)}),this.addEventListener("change-icon_size",({value:i})=>{this.img&&(this.img.style.width=`${i?.[0]||32}px`,this.img.style.height=`${i?.[1]||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:i})=>{this.img&&(this.img.style.opacity=`${i}`)}),this.addEventListener("change-icon_border",({value:i})=>{this.img&&(this.img.style.border=`${i.width}px solid ${i.color}`)}),this.addEventListener("change-background",({value:i})=>{this.div.style.background=i})}div;textDiv;img;overlay;options;visible=!0;size={width:0,height:0};position=new $t.Vector3;userData={};showTextStatus=!0;disposed=!1;get withinDisplayRange(){return this.overlay.withinDisplayRange}async resetSize(){if(await nn(),!this.disposed)if(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 this.div=t,this.addText(),this.options.icon&&this.addIcon(),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.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(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[r,s]of Object.entries(e.styles))i.style[r]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${this.options.icon_size?.[0]||32}px`,t.style.height=`${this.options.icon_size?.[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}_changePosition=()=>{this.overlay.updatePosition(!0)};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,r=e*t,s=i*t,{x:l,y:u}=this.overlay.clientPos;return{left:l-r/2,right:l+r/2,top:this.options.icon?u-s:u-s/2,bottom:this.options.icon?u:u+s/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(),this.disposed=!0}};var z=y("three");var O=y("three"),Fn=y("@mars3d/heatmap.js"),pt=y("@turf/turf"),Zt=class extends O.Object3D{constructor(t){super();this.context=t;this.div=document.createElement("div")}heatmap;div;plane;clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:r,center:s}=this.getBox(t);this.heatmap=(0,Fn.create)({width:e,height:i,container:this.div,...this.context.config.heatMap}),this.heatmap.setData(this.transformData(t,r)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new O.PlaneGeometry(t,e),r=new O.Texture(this.div.firstChild);r.needsUpdate=!0;let s=new O.MeshBasicMaterial({transparent:!0,side:O.DoubleSide,map:r});s.needsUpdate=!0,this.plane=new O.Mesh(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new O.Matrix3().makeScale(1,-1).multiply(new O.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let l=new O.Vector2(s.x,s.y).applyMatrix3(i);return{x:l.x,y:l.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,pt.featureCollection)(t.data.map(a=>(0,pt.point)([a.x,a.y]))),i=(0,pt.bbox)(e),r=i[2]-i[0],s=i[3]-i[1],l={x:i[0],y:i[3]},u=(0,pt.center)(e);return{width:r,height:s,leftTop:l,center:u.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var Jt=y("three");var Kt=class extends Jt.Object3D{constructor(t,e){super();this.context=t;this.options=e;this.position.copy(e.position||new Jt.Vector3(0,0,0)),this.loadModel()}model=null;async loadModel(){let t=await Xt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t}dispose(){Z(this),this.model=null}};var te=y("three");var Un=y("three");var B=class extends Un.Object3D{constructor(t){super();this.context=t}dispose(){Z(this),this.children.forEach(t=>t.dispose?.()),this.clear()}};var Qt=class extends B{graphicMap=new Map;constructor(n){super(n)}getCenter(){return new te.Box3().setFromObject(this).getCenter(new te.Vector3)}createGraphic(n){let t=new U(this.context,n);return this.add(t),this.graphicMap.set(n.id,t),t}removeGraphic(n){this.remove(n),this.graphicMap.delete(n.options.id),n.dispose()}removeGraphicById(n){this.graphicMap.has(n)&&this.removeGraphic(this.graphicMap.get(n))}getGraphicByNodeId(n){return this.graphicMap.get(n)||null}getGraphicByRaycaster(n){let t={distance:1e4,graphic:null,position:null},e=this.children.reduce((i,r)=>{if(r instanceof U){let s=r.raycast(n);if(s){let{distance:l}=s;if(l<i.distance)return{distance:s.distance,position:s.position,graphic:r}}return i}else return i},t);return e===t?{graphics:[],position:null}:{graphics:[e.graphic],position:e.position}}};var Bn=y("lodash");var At=class extends B{pois=[];debounceCollisionDetection;timer=new W;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=(0,Bn.debounce)(this.collisionDetection,10)}clear(n=!1){return this.pois.forEach(t=>{t.options.built_in&&!n||t.dispose()}),this.pois=n?[]:this.pois.filter(t=>t.options.built_in),this}createPoi(n){let t=new vt(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){return this.pois.filter(i=>i instanceof vt&&i.isContain(n,t))}onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[];this.pois.filter(e=>e.visible&&e.withinDisplayRange).forEach((e,i)=>{let{left:r,right:s,top:l,bottom:u}=e.getBox();if(i===0||!e.options.collision_enable){n.push({left:r,right:s,top:l,bottom:u}),e.parentSetVisible(!0);return}let a=n.some(c=>c.left<s&&c.right>r&&c.top<u&&c.bottom>l);e.parentSetVisible(!a),a||n.push({left:r,right:s,top:l,bottom:u})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var Gn=y("lodash");var ne=y("three"),ee=class extends B{pois=[];debounceCollisionDetection;timer=new W;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=(0,Gn.debounce)(this.collisionDetection,10)}clear(){return this.pois.forEach(n=>{n.dispose()}),this.pois=[],this}createPoi(n){let t=new k(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.remove(n),this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(this.add(n),!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){let e=new ne.Vector2(n,t);return this.pois.filter(r=>r instanceof k&&r.canSelect&&r.box.containsPoint(e))}changeParkingSpaceVisibleByZoom=()=>{let n=this.parent?.parent;if(n&&n instanceof rt){let{clientSize:{width:t,height:e}}=this.context,{max:i,min:r}=n.box,l=Math.min(t/(i.x-r.x),e/(i.y-r.y))*(i.x-r.x)/60;this.pois.filter(u=>u.userData.type==="parkingSpace").map(u=>{let a=this.context.camera.zoom>=l;u.visible=a,a||u.parentSetVisible(a)})}};onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[],{camera:t}=this.context;t.updateMatrixWorld();let e=s=>s<=1&&s>=-1,i=t.projectionMatrix.clone();i.multiply(t.matrixWorldInverse),this.pois.filter(s=>{if(s.visible){let l=new ne.Vector3().setFromMatrixPosition(s.matrixWorld);return l.applyMatrix4(i),s.screenPosition=l,e(l.x)&&e(l.y)&&e(l.z)}return!1}).forEach((s,l)=>{let u=s.getBox(s.screenPosition);if(l===0||!s.options.collision_enable){n.push(u),s.parentSetVisible(!0);return}let a=n.some(c=>c.intersectsBox(u));s.parentSetVisible(!a),a||n.push(u)})}registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var rt=class extends z.Object3D{constructor(t){super();this.context=t;this.groundLayer=new B(this.context),this.graphicLayer=new Qt(this.context),this.poiLayer=new At(this.context),this.poiLayer2=new ee(this.context),this.wallLayer=new B(this.context),this.textureLayer=new B(this.context),this.glbModelLayer=new B(this.context),this.laneLayer=new B(this.context),this.mergeGraphicLayer=new B(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}graphicLayer;poiLayer;poiLayer2;wallLayer;textureLayer;glbModelLayer;laneLayer;mergeGraphicLayer;grounds=new Set;groundLayer;shadow=new jt;heatmap;groundUpper=new z.Object3D;models=new z.Object3D;modelMap=new Map;groundMaxHeight=0;name="";key="";box=new z.Box3;getPosition(){return this.box.getCenter(new z.Vector3)}createGround(t){let e=new U(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundLayer.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.groundUpper.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new z.Box3().setFromObject(this).getCenter(new z.Vector3)}addModel(t){let e=new Kt(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new z.Box3().setFromObject(this.groundUpper),e=t.getCenter(new z.Vector3),i=t.getSize(new z.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 Zt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new z.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}updateBox(){this.box.setFromObject(this)}dispose(){this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.grounds.forEach(t=>t.dispose()),this.heatmap?.dispose(),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var ie=y("three");var ot=class extends ie.EventDispatcher{constructor(t){super();this.context=t;this.svg=en(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}points=[];svg;enable=!0;_onResize=({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))};_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:r,offsetY:s}=t,{clientWidth:l,clientHeight:u}=i.domElement,a=r/l*2-1,c=1-s/u*2;return new ie.Vector3(a,c,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 re=class extends ot{constructor(t){super(t);this.context=t;let{config:{svg:{circle:e,line:i}}}=t;this.circles=[It(e.radius,e.fill),It(e.radius,e.fill)],this.line=Vt(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}circles;line;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)}onUpdate=()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);_t(this.circles[0],t.x,t.y),K(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);_t(this.circles[1],t.x,t.y),K(this.line,void 0,t)}};onPointermove=t=>{this.points.length===1&&(this.line.style.display="block",K(this.line,void 0,{x:t.offsetX,y:t.offsetY}))};onPointerleave=()=>{this.points[1]||(this.line.style.display="none")};onPointerdown=t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:r}=t,s=this.circles[this.points.length];_t(s,i,r),this.points.length||K(this.line,{x:i,y:r},{x:i,y:r}),this.addPoint(e)}};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:r}]=this.points;return Math.sqrt((i-t)**2+(r-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var oe=class extends ot{circles=[];lines=[];isClose=!1;constructor(n){super(n),this.registryEvent()}setEnable(n){super.setEnable(n),n?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(n){this.circles.push(n),this.svg.appendChild(n)}addLine(n){this.lines.push(n),this.svg.appendChild(n)}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)}onUpdate=()=>{this.points.length&&this.points.forEach((n,t)=>{let e=this.getSvgCoordinate(n);this.circles[t]&&_t(this.circles[t],e.x,e.y),t!==0&&K(this.lines[t-1],void 0,e),this.lines[t]&&K(this.lines[t],e)})};onPointermove=n=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",K(this.lastLine,void 0,{x:n.offsetX,y:n.offsetY}))};onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")};onPointerdown=n=>{if(this.isClose)return;let t=this.getIntersectByPointerEvent(n);if(t){let{offsetX:e,offsetY:i}=n;this.checkAdsorb(e,i)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(t);let{circle:{fill:r,radius:s},line:{stroke:l}}=this.context.config.svg;if(!this.isClose){let u=It(s,r);_t(u,e,i),this.addCircle(u)}if(this.lines.length&&K(this.lastLine,void 0,{x:e,y:i}),!this.isClose){let u=Vt(l);K(u,{x:e,y:i},{x:e,y:i}),this.addLine(u)}}};checkAdsorb(n,t){if(this.points.length<3)return!1;let e=this.circles[0],i=+e.getAttribute("cx"),r=+e.getAttribute("cy");return Math.sqrt((n-i)**2+(t-r)**2)<=5}addPoint(n){if(this.points.push(n),this.isClose){let t=this.calculatedArea();this.dispatchEvent({type:"area",area:t})}}calculatedArea(){let n=this.points.map(i=>[i.x,i.y]),t=0,e=n.length;for(let i=0;i<e;i++){let r=(i+1)%e;t+=n[i][0]*n[r][1]-n[r][0]*n[i][1]}return Math.abs(t/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var kn=y("three");var zn=class extends ot{constructor(t){super(t);this.context=t;let{config:{svg:{line:e}}}=t;this.rect=Tt(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Tt(e.stroke,"#ffffff"),this.centerRect[i]=Tt(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}rect;cornerRect=[];centerRect=[];graphic;setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}onUpdate=()=>{if(this.graphic){let t=new kn.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:r}}=this.context,{min:s,max:l}=t,u=b(s,e,i,r),a=b(l,e,i,r);J(this.rect,u.x,a.y,Math.abs(a.x-u.x),Math.abs(a.y-u.y));let{x:c,y:p}=u,{x:f,y:m}=a,h=5,d=[{x:c-h,y:m-h},{x:f-h,y:m-h},{x:c-h,y:p-h},{x:f-h,y:p-h}];for(let E=0;E<d.length;E++)J(this.cornerRect[E],d[E].x,d[E].y,h*2,h*2);let g=4,v=(c+f)/2,P=(p+m)/2,C=[{x:v-g,y:m-g},{x:c-g,y:P-g},{x:f-g,y:P-g},{x:v-g,y:p-g}];for(let E=0;E<C.length;E++)J(this.centerRect[E],C[E].x,C[E].y,g*2,g*2)}else{J(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)J(this.cornerRect[t],0,0,0,0),J(this.centerRect[t],0,0,0,0)}};selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var A=y("three");var Ie=y("three/examples/jsm/utils/BufferGeometryUtils"),se=class extends A.Object3D{constructor(t,e){super();this.context=t;this.options=e;e.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(e=>{let i=nt(e.geometry.coords[0],e.geometry.coords.slice(1));return new A.ExtrudeGeometry(i,{steps:1,bevelEnabled:!1,depth:e.height,curveSegments:4})});this.geometry=(0,Ie.mergeGeometries)(t),t.forEach(e=>e.dispose())}initMaterial(){let t=`
1
+ "use strict";(()=>{var bi=Object.create;var Ge=Object.defineProperty;var Mi=Object.getOwnPropertyDescriptor;var Si=Object.getOwnPropertyNames;var wi=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var y=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var gt=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports);var Ci=(o,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Si(n))!Ti.call(o,i)&&i!==t&&Ge(o,i,{get:()=>n[i],enumerable:!(e=Mi(n,i))||e.enumerable});return o};var Se=(o,n,t)=>(t=o!=null?bi(wi(o)):{},Ci(n||!o||!o.__esModule?Ge(t,"default",{value:o,enumerable:!0}):t,o));var ln=gt((Ar,an)=>{an.exports=function(n,t){return n[0]=t[0],n[1]=t[1],n}});var hn=gt((Rr,cn)=>{var un=ln();cn.exports=function(o,n){Array.isArray(n)||(n=[]),o.length>0&&n.push(un([0,0],o[0]));for(var t=0;t<o.length-1;t++){var e=o[t],i=o[t+1],r=e[0],s=e[1],l=i[0],u=i[1],a=[.75*r+.25*l,.75*s+.25*u],c=[.25*r+.75*l,.25*s+.75*u];n.push(a),n.push(c)}return o.length>1&&n.push(un([0,0],o[o.length-1])),n}});var _n=gt((Or,yn)=>{var Pe=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((n,t)=>n.priority-t.priority)}set(n,t){let e=Number(t);if(isNaN(e))throw new TypeError('"priority" must be a number');return this.keys.has(n)?this.queue.map(i=>(i.key===n&&Object.assign(i,{priority:e}),i)):(this.keys.add(n),this.queue.push({key:n,priority:e})),this.sort(),this.queue.length}next(){let n=this.queue.shift();return this.keys.delete(n.key),n}isEmpty(){return this.queue.length===0}has(n){return this.keys.has(n)}get(n){return this.queue.find(t=>t.key===n)}};yn.exports=Pe});var En=gt((Fr,xn)=>{function vn(o,n){let t=new Map;for(let[e,i]of o)e!==n&&i instanceof Map?t.set(e,vn(i,n)):e!==n&&t.set(e,i);return t}xn.exports=vn});var Sn=gt((Ur,Mn)=>{function Bi(o){let n=Number(o);return!(isNaN(n)||n<=0)}function bn(o){let n=new Map;return Object.keys(o).forEach(e=>{let i=o[e];if(i!==null&&typeof i=="object"&&!Array.isArray(i))return n.set(e,bn(i));if(!Bi(i))throw new Error(`Could not add node at key "${e}", make sure it's a valid node`,i);return n.set(e,Number(i))}),n}Mn.exports=bn});var Cn=gt((Br,Tn)=>{function wn(o){if(!(o instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof o}`);o.forEach((n,t)=>{if(typeof n=="object"&&n instanceof Map){wn(n);return}if(typeof n!="number"||n<=0)throw new Error(`Values must be numbers greater than 0. Found value ${n} at ${t}`)})}Tn.exports=wn});var Ae=gt((Gr,An)=>{var Gi=_n(),zi=En(),Pn=Sn(),Ln=Cn(),Le=class{constructor(n){n instanceof Map?(Ln(n),this.graph=n):n?this.graph=Pn(n):this.graph=new Map}addNode(n,t){let e;return t instanceof Map?(Ln(t),e=t):e=Pn(t),this.graph.set(n,e),this}addVertex(n,t){return this.addNode(n,t)}removeNode(n){return this.graph=zi(this.graph,n),this}path(n,t,e={}){if(!this.graph.size)return e.cost?{path:null,cost:0}:null;let i=new Set,r=new Gi,s=new Map,l=[],u=0,a=[];if(e.avoid&&(a=[].concat(e.avoid)),a.includes(n))throw new Error(`Starting node (${n}) cannot be avoided`);if(a.includes(t))throw new Error(`Ending node (${t}) cannot be avoided`);for(r.set(n,0);!r.isEmpty();){let c=r.next();if(c.key===t){u=c.priority;let f=c.key;for(;s.has(f);)l.push(f),f=s.get(f);break}i.add(c.key),(this.graph.get(c.key)||new Map).forEach((f,m)=>{if(i.has(m)||a.includes(m))return null;if(!r.has(m))return s.set(m,c.key),r.set(m,c.priority+f);let h=r.get(m).priority,d=c.priority+f;return d<h?(s.set(m,c.key),r.set(m,d)):null})}return l.length?(e.trim?l.shift():l=l.concat([n]),e.reverse||(l=l.reverse()),e.cost?{path:l,cost:u}:l):e.cost?{path:null,cost:0}:null}shortestPath(...n){return this.path(...n)}};An.exports=Le});var ve=y("three");var W=class{tasks={requestAnimation:new Set,timeout:new Set,interval:new Set};requestAnimationFrame(n){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),n()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(n){this.tasks.requestAnimation.delete(n),window.cancelAnimationFrame(n)}setTimeout(n,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),n()},t);return this.tasks.timeout.add(e),e}clearTimeout(n){this.tasks.timeout.delete(n),window.clearTimeout(n)}setInterval(n,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),n()},t);return this.tasks.interval.add(e),e}clearInterval(n){this.tasks.interval.delete(n),window.clearInterval(n)}dispose(){this.tasks.requestAnimation.forEach(n=>{window.cancelAnimationFrame(n)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(n=>{window.clearTimeout(n)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(n=>{window.clearInterval(n)}),this.tasks.interval.clear()}};var T=y("three"),ze=y("three/examples/jsm/controls/MapControls");function ke(){let o=new T.Scene;return o.background=new T.Color(16777215),o}function Ve(){let o=new T.WebGLRenderer({antialias:!0});return o.autoClear=!0,o.setClearAlpha(1),o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=T.PCFSoftShadowMap,o}function He(o,n){let t=new T.OrthographicCamera(-o/2,o/2,n/2,-n/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function We(){let o=new T.Group,n=new T.AmbientLight(16777215,2.6);return o.add(n),o}function Xe(o,n){let t=new ze.MapControls(o,n);return t.enableDamping=!1,t.zoomSpeed=.5,t}function nt(o,n=[]){let t=new T.Shape(o.map(e=>new T.Vector2(...e)));return n.length&&n.forEach(e=>{var i=new T.Path(e.map(r=>new T.Vector2(...r)));t.holes.push(i)}),t}function qe(o=16777215,n=1){let t=new T.DirectionalLight(o,n);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 Z(o,n){if(n&&o.children&&o.children.length&&o.children.forEach(t=>{Z(t,n)}),o.isMesh){let t=o;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(e=>{e.dispose()}):t.material.dispose())}o.isLight&&o.dispose?.()}function je(o){return/[\u4E00-\u9FA5]+/g.test(o)}var X=y("three"),Mt=new Map,Rt=new Map,Pi=new X.TextureLoader;function Li(){let o=document.createElement("canvas");o.width=1024,o.height=64;let n=o.getContext("2d",{willReadFrequently:!0});return n.font="54px sans-serif",n.textBaseline="hanging",n.lineWidth=12,n.fillStyle="rgba(0,0,0,1)",n.strokeStyle="white",{canvas:o,ctx:n}}var we,mt;function Ai(){if(!we){let{canvas:o,ctx:n}=Li();we=o,mt=n}}function Ye(o){if(Rt.has(o))return Rt.get(o);Ai(),mt.clearRect(0,0,1024,64);let n=je(o)?4:8;mt.strokeText(o,2,n),mt.fillText(o,2,n);let t=Math.ceil(mt.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=mt.getImageData(0,0,t,64),i=new X.DataTexture(Uint8Array.from(e.data),t,64,X.RGBAFormat);return i.flipY=!0,i.minFilter=X.LinearFilter,i.magFilter=X.LinearFilter,Rt.set(o,i),i}function $e(){Rt.forEach((o,n)=>{o.dispose()}),Mt.forEach(o=>{o instanceof Promise?o.then(n=>n.dispose()):o.dispose()}),Rt.clear(),Mt.clear()}function Ze(){mt=null,we=null}async function Ke(o){if(Mt.has(o))return Mt.get(o);let n=Pi.loadAsync(o);return n.then(t=>{t.format=X.RGBAFormat,t.magFilter=X.LinearFilter,t.minFilter=X.LinearFilter,t.colorSpace="srgb",Mt.set(o,t)}),Mt.set(o,n),n}var L=y("three"),St=y("@turf/turf");function b(o,n,t,e){let i=o.clone().project(n),r=t/2,s=e/2,l=Math.round(i.x*r+r),u=Math.round(-i.y*s+s);return{x:l,y:u}}function Bt(o){let n=(0,St.featureCollection)(o.map(e=>(0,St.point)(e)));return(0,St.center)(n).geometry.coordinates}function Gt(o,n,t){return o.x>=n.x&&o.x<=t.x&&o.y>=n.y&&o.y<=t.y}function ur(o){let n=0,t=new L.Vector3;for(let e=1;e<o.length;e++){let i=new L.Vector3(o[e-1][0],o[e-1][1],0),r=new L.Vector3(o[e][0],o[e][1],0),s=r.distanceTo(i);s>n&&(n=s,t=r.clone().sub(i).normalize())}return t}function I(o,n){return Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2)}function ht(o){let n=0;for(let t=0;t<o.length-1;t++)n+=I(o[t],o[t+1]);return n}function zt(o,n,t){let e=new L.Vector2(n[0]-o[0],n[1]-o[1]),i=new L.Vector2(n[0]-t[0],n[1]-t[1]),s=e.angleTo(i)*180/Math.PI,l=new L.Vector2(n[0]-o[0],n[1]-o[1]);return new L.Vector2(t[0]-o[0],t[1]-o[1]).cross(l)>0?s:-s}function Je(o,n){let t=Math.min(I(o[0][0],o[0][1]),I(o[0][2],o[0][1]))-1;n||(n=Bt(o[0]));let e=Ri(n,t),i=new L.Vector2(o[0][0][0],o[0][0][1]),r=new L.Vector2(o[0][1][0],o[0][1][1]),s=new L.Vector2(o[0][2][0],o[0][2][1]),u=(i.distanceTo(r)>r.distanceTo(s)?r.clone().sub(i):s.clone().sub(r)).angleTo(new L.Vector2(0,1)),a=new L.Matrix3;return a.multiply(new L.Matrix3().translate(n[0],n[1])).multiply(new L.Matrix3().rotate(u)).multiply(new L.Matrix3().translate(-n[0],-n[1])),[e.map(c=>{let p=new L.Vector2(c[0],c[1]).applyMatrix3(a);return[p.x,p.y]})]}function Ri(o,n){let t=n/2;return[[o[0]-t,o[1]+t],[o[0]+t,o[1]+t],[o[0]+t,o[1]-t],[o[0]-t,o[1]-t],[o[0]-t,o[1]+t]]}function Qe(o,n){let t=0,e=1/0,[i,r]=n;for(let s=0;s<o.length-1;s++){let[l,u]=o[s],[a,c]=o[s+1],p=Math.min(l,a)<=i&&i<=Math.max(l,a),f=Math.min(u,c)<=r&&r<=Math.max(u,c);if(p&&f){let m=Math.abs((a-l)*(r-u)-(c-u)*(i-l));m<e&&(e=m,t=s)}}return t}function tn(o,n){let t=o[0],e=o[1],i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){let l=n[r][0],u=n[r][1],a=n[s][0],c=n[s][1];u>e!=c>e&&t<(a-l)*(e-u)/(c-u)+l&&(i=!i)}return i}function wt(o,n){return new Proxy(o,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,r)=>{let s=Reflect.get(t,e,r),l=Reflect.set(t,e,i,r);return s!==i&&n.dispatchEvent({type:`change-${e}`,value:i}),l}})}function yt(o,n){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),n)})])}function kt(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function en(o,n){let t=kt("svg");return t.setAttribute("width",o),t.setAttribute("height",n),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function It(o="2",n){let t=kt("circle");return t.setAttribute("r",o),t.setAttribute("fill",n),t}function Vt(o){let n=kt("line");return n.setAttribute("stroke",o),n}function Tt(o,n){let t=kt("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",n),t}function _t(o,n,t){o.setAttribute("cx",`${n}`),o.setAttribute("cy",`${t}`)}function K(o,n,t){n&&(o.setAttribute("x1",`${n.x}`),o.setAttribute("y1",`${n.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function J(o,n,t,e,i){o.setAttribute("x",`${n}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}function nn(){return Promise.resolve()}function dr(){return new Promise(o=>{requestAnimationFrame(o)})}function mr(o){return parseInt(o.replace("#","0x"),16)}function yr(o,n){let t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16),r=Math.round(t*n),s=Math.round(e*n),l=Math.round(i*n);return`#${(1<<24|r<<16|s<<8|l).toString(16).slice(1)}`}function ut(o,n=.85){let t,e,i;if(o.startsWith("#"))t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16);else{let s=o.slice(4,-1).split(",");t=parseInt(s[0].trim()),e=parseInt(s[1].trim()),i=parseInt(s[2].trim())}return t=Math.min(Math.floor(t*n),255),e=Math.min(Math.floor(e*n),255),i=Math.min(Math.floor(i*n),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}var rn=y("three/examples/jsm/loaders/GLTFLoader");function Ii(){return new rn.GLTFLoader}var Ht=null,Wt=new Map;function Xt(o){if(Wt.has(o)){let t=Wt.get(o).then(e=>(e.scene=e.scene.clone(),e))}Ht||(Ht=Ii());let n=new Promise((t,e)=>{Ht.load(o,i=>{t(i)},void 0,e)});return Wt.set(o,n),n.then(t=>(t.scene=t.scene.clone(),t))}function on(){Ht=null,Wt.clear()}var qt=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function Te(o){return qt?o==="Meta":o==="Control"}var Ce="__once__",sn=class{events=new Map;on(n,t){if(typeof t!="function")return;let e=this.events.get(n);return e?e.add(t):this.events.set(n,new Set([t]))}once(n,t){if(typeof t!="function")return;let e=`${Ce}${n}`,i=this.events.get(e);return i?i.add(t):this.events.set(e,new Set([t]))}off(n,t){let e=this.events.get(n),i=this.events.get(`${Ce}${n}`);!e&&!i||(t===void 0&&(e?.clear(),i?.clear()),e?.has(t)&&e.delete(t),i?.has(t)&&i.delete(t))}offAll(){this.events.clear()}emit(n,...t){let e=this.events.get(n),i=this.events.get(`${Ce}${n}`);!e&&!i||(e?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.clear())}};var Nt=(t=>(t.SWITCH_FLOOR_BEFORE="switch_floor_before",t.SWITCH_FLOOR_AFTER="switch_floor_after",t))(Nt||{});function Q(o){return Object.keys(o).sort().map(n=>`${n}=${o[n]}`).join("&")}function Cr(o,n){return new Promise((t,e)=>{let i=new XMLHttpRequest;i.open("GET",o,!0),Object.keys(n.headers||{}).forEach(r=>{i.setRequestHeader(r,n.headers[r])}),n.responseType&&(i.responseType=n.responseType),i.onload=()=>{if(i.status>=200&&i.status<300)if(n.responseType==="arraybuffer")t(i.response);else try{let r=JSON.parse(i.responseText);t(r)}catch(r){e(r)}else e(i.statusText)},i.onerror=()=>{e(i.statusText)},i.send()})}var Ct=class o{keySet=new Set;static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}genUniqueKey(){let n=o.createKey();for(;this.keySet.has(n);)n=o.createKey();return n}removeKey(n){this.keySet.delete(n)}dispose(){this.keySet.clear()}};var Pt=y("three"),pn=Se(hn(),1);function Ni(o,n){let t=o.clone().normalize(),e=n.clone().normalize();return Math.acos(t.dot(e))}function Di(o){let n=0;return o.reduce(([t,e],[i,r])=>(n+=Math.sqrt((i-t)**2+(r-e)**2),[i,r])),n/o.length}function fn(o,n=.25){if(Di(o)<n)return o;let t=(0,pn.default)(o);return fn(t,n)}function dn(o,n=!1,t=!0,e=5,i=150,r=3){let s=[],l=!n;if(s.push(o[0]),o.length<2)return s;for(let a=0;a<o.length-2;a+=1){let c=o[a],p=o[a+1],f=o[a+2],m=new Pt.Vector2(c[0]-p[0],c[1]-p[1]),h=new Pt.Vector2(f[0]-p[0],f[1]-p[1]),d=Ni(m,h)/Math.PI*180,g=m.length()+h.length();(!l||d<i&&g>.01||g>e)&&(s.push(o[a+1]),l=!0)}if(s.push(o[o.length-1]),!t)return s;let u=[];u.push(s[0]);for(let a=0;a<s.length-2;a+=1){let c=new Pt.Vector2(s[a][0],s[a][1]),p=new Pt.Vector2(s[a+1][0],s[a+1][1]),f=new Pt.Vector2(s[a+2][0],s[a+2][1]),m=c.distanceTo(p)/2,h=f.distanceTo(p)/2,d=p.clone(),g=p.clone();d.add(c.clone().sub(p).normalize().multiplyScalar(m>r?r/2:m)),g.add(f.clone().sub(p).normalize().multiplyScalar(h>r?r/2:h));let v=[[d.x,d.y],[p.x,p.y],[g.x,g.y]];u.push(...fn(v,r/25))}return u.push(s[s.length-1]),Oi(u)}function Oi(o){if(o.length<=1)return o;let n=[],t;return o.forEach(([e,i])=>{t?e===t[0]&&i===t[1]||(t=[e,i],n.push([e,i])):(t=[e,i],n.push([e,i]))}),n}function gn(o,n,t){let e=Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2);if(e===0)return{distance:Math.sqrt((o[0]-n[0])**2+(o[1]-n[1])**2),closestPoint:n.slice(0)};let i=Math.max(0,Math.min(1,((o[0]-n[0])*(t[0]-n[0])+(o[1]-n[1])*(t[1]-n[1]))/e**2)),r=[n[0]+i*(t[0]-n[0]),n[1]+i*(t[1]-n[1])];return{distance:Math.sqrt((o[0]-r[0])**2+(o[1]-r[1])**2),closestPoint:r}}function mn(o,n,t){let[e,i]=o,[r,s]=n,l=Math.sqrt(Math.pow(r-e,2)+Math.pow(s-i,2));if(l===0||l<t)return[...n];let u=t/l,a=e+(r-e)*u,c=i+(s-i)*u;return[a,c]}var Fi=(a=>(a.START="start",a.END="end",a.FRONT="front",a.RIGHT="right",a.LEFT="left",a.RIGHT_FRONT="right_front",a.LEFT_FRONT="left_front",a.RIGHT_BACK="right_back",a.LEFT_BACK="left_back",a))(Fi||{});function Ui(o,n,t){let e=zt(o,n,t);return 180-Math.abs(e)<15?"front":e>135?"right_front":e<-135?"left_front":e<=135&&e>=60?"right":e>=-135&&e<=-60?"left":e<60&&e>0?"right_back":e>-60&&e<0?"left_back":"front"}function Nr(o){let n=[{direction:"start",distance:I(o[0],o[1]),points:[o[0],o[1]]}];for(let t=2;t<o.length;t++){let e=Ui(o[t-2],o[t-1],o[t]);if(e==="front"){let i=n[n.length-1],r=I(o[t-1],o[t]);i.distance+=r,t!==2&&i.points.push(o[t-1])}else n.push({direction:e,distance:I(o[t-1],o[t]),points:[o[t-1],o[t]]})}return n.push({direction:"end",distance:0,points:[o[o.length-1]]}),n}var it=Se(Ae(),1);var q="___",Rn=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;lineMap=new Map;baseRoute=new it.default;escalatorRoute=new it.default;straightLadderRoute=new it.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${q}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${q}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${q}${e.from}`,r=`${t.floor}${q}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=I(s,l);this.addLineItem(i,r,u),e.direction==="double"&&this.addLineItem(r,i,u)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${q}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${q}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${q}${r.start.id}`,u=`${r.end.floor}${q}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new it.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new it.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new it.default(n)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${q}${n.nodeId}`);if(t){let[e,i]=t.split(q);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=I(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(console.log(i,r),r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+ht(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${q}${n.id}`,r=`${t.floor}${q}${t.id}`,s=e.path(i,r);if(console.log(i,r,s),!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new it.default,this.escalatorRoute=new it.default,this.straightLadderRoute=new it.default}};var j=Se(Ae(),1);var G="___",In=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;parkingMap=new Map;lineMap=new Map;baseRoute=new j.default;escalatorRoute=new j.default;straightLadderRoute=new j.default;forwardLineMap=new Map;forwardRoute=new j.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${G}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${G}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}e.type==="parkingSpace"&&this.parkingMap.set(`${e.floor}${G}${e.name}`,e)}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${G}${e.from}`,r=`${t.floor}${G}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=I(s,l);switch(this.addLineItem(i,r,u),this.addLineItem(r,i,u),e.direction){case"double":this.addLineItem(i,r,u,this.forwardLineMap),this.addLineItem(r,i,u,this.forwardLineMap);break;case"single":this.addLineItem(i,r,u,this.forwardLineMap);break;case"back":this.addLineItem(r,i,u,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${G}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${G}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${G}${r.start.id}`,u=`${r.end.floor}${G}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new j.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new j.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new j.default(n)}initForwardRoute(){this.forwardRoute=new j.default(this.forwardLineMap)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility||n.parkingSpace&&n.floor?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${G}${n.nodeId}`);if(t){let[e,i]=t.split(G);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=I(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){if(n.parkingSpace){let e=this.parkingMap.get(`${n.floor}${G}${n.parkingSpace}`);if(e)return{floor:e.floor,id:e.id}}let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;case"forward":s=this.getForwardPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+ht(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${G}${n.id}`,r=`${t.floor}${G}${t.id}`,s=e.path(i,r);if(!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId,p.distance=ht(p.points)}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId,distance:0})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}getForwardPath(n,t){return this.getRoutePath(n,t,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new j.default,this.escalatorRoute=new j.default,this.straightLadderRoute=new j.default}};function Nn(o){return o.replace(/[A-Z]/g,n=>"_"+n.toLowerCase()).replace(/^_/,"")}var Dn=new Ct;function Lt(o,n,t){return new Promise((e,i)=>{let r=Dn.genUniqueKey(),s=({data:l})=>{l.type===`${n}_result`&&l.key===r&&(Dn.removeKey(r),self.removeEventListener("message",s),l.error?i(l.error):e(l.data))};o.addEventListener("message",s),o.postMessage({type:n,key:r,data:t})})}function jr(o){let n={};for(let e in o)e.startsWith("on")&&(n[Nn(e.slice(2))]=o[e]);let t=async({data:e})=>{if(n[e.type])try{let i=await n[e.type](e.data);self.postMessage({type:`${e.type}_result`,key:e.key,data:i})}catch(i){self.postMessage({type:`${e.type}_result`,key:e.key,error:i})}else self.postMessage({type:`${e.type}_result`,key:e.key,error:"no_event"})};return self.addEventListener("message",t),()=>{self.removeEventListener("message",t)}}var M=y("three"),bt=y("@tweenjs/tween.js");var jn=y("three");var x=y("three");var Re={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},U=class extends x.Object3D{constructor(t,e){super();this.context=t;if(this.options=wt({...Re,...e},this),this.options.geometry.type==="point"){let[i,r]=this.options.geometry.coords;return this.position.set(i,r,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})=>{if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),this.lineGeometry?.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}geometry;material;mesh;line;lineMaterial;lineGeometry;options;getCenter(){if(this.options.geometry.type==="point")return this.position.clone();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/2),t}init(){this.initDoor(),this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&this.options.strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initDoor(){if(this.options.doors&&this.options.geometry.type==="polygon"){let t=this.options.geometry.coords[0];this.options.doors.forEach(e=>{let i=e.type==="single"?.5:1,r=.5,s=Qe(t,e.coord),l=new x.Vector2(...e.coord),u=new x.Vector2(...t[s]).sub(new x.Vector2(...e.coord)).normalize(),a=new x.Vector2().addVectors(l,u.clone().multiplyScalar(i)),c=new x.Vector2().addVectors(l,u.clone().multiplyScalar(-i)),p=new x.Vector2(-u.y,u.x),f=new x.Vector2().addVectors(a,p.clone().multiplyScalar(r));tn([f.x,f.y],t)||(p.multiplyScalar(-1),f=new x.Vector2().addVectors(a,p.clone().multiplyScalar(r)));let m=new x.Vector2().addVectors(c,p.clone().multiplyScalar(r)),h=[[a.x,a.y],[f.x,f.y],[m.x,m.y],[c.x,c.y]];this.options.geometry.coords=[[...t.slice(0,s+1),...h,...t.slice(s+1)]],t=this.options.geometry.coords[0]})}}initGeometry(){let t=nt(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new x.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:ut(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getMaxAndMin(t,e){let i=new x.Box3().setFromObject(this),r=t.clone().add(e.clone().multiplyScalar(1e3)),s=new x.Ray(r,e.clone().multiplyScalar(-1)),l=new x.Vector3;s.intersectBox(i,l);let u=t.clone().add(e.clone().multiplyScalar(-1e3)),a=new x.Ray(u,e.clone()),c=new x.Vector3;return a.intersectBox(i,c),{max:c,min:l}}initGradualMaterial(){let{max:t,min:e}=new x.Box3().setFromObject(this),i=t.clone().sub(e),r=Math.max(i.x,i.y,i.z)/2,s=this.getPosition(),l=new x.Vector3(-1,.2,0).normalize(),{max:u,min:a}=this.getMaxAndMin(s,l),c=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:r,opacity:this.options.fillOpacity,direction:new x.Vector3(-1,.2,0),max:u,min:a});if(this.options.height<=.1)return this.material=c,c;let p=this.getCenter(),f=new x.Vector3(-1,.2,1).normalize(),{max:m,min:h}=this.getMaxAndMin(p,f),d=this.context.materialFactory.createShaderMaterial({gradualColor:[ut(this.options.gradualColor[0],this.options.colorFactor),ut(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:r,opacity:this.options.fillOpacity,direction:new x.Vector3(-1,.2,1),max:m,min:h});return this.material=[c,d],[c,d]}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 x.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 r=0;r<i.length;r++){let s=i[r];for(let l=0;l<s.length;l++){let u=s[l],a=l+1===s.length?s[0]:s[l+1];t.push(new x.Vector3(u[0],u[1],e)),t.push(new x.Vector3(a[0],a[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new x.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new x.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;this.mesh.updateMatrixWorld(!0);let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:r}=e[0];return{position:i,distance:r}}return!1}dispose(){this.geometry?.dispose(),this.line?.geometry.dispose(),this.clear()}};var Y=y("three");var jt=class extends Y.Object3D{directionalLight;plane;basicOpacity=.07;constructor(){super(),this.directionalLight=this.initLight(),this.initPlane()}initLight(){let n=qe(16777215,.5);return n.position.set(0,0,100),this.add(n),n}changeLightCamera(n){let t=n.x,e=n.y;this.directionalLight.shadow.camera.left=-t,this.directionalLight.shadow.camera.right=t,this.directionalLight.shadow.camera.top=e,this.directionalLight.shadow.camera.bottom=-e,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(t,e)}changeLightColor(n){this.directionalLight.color=new Y.Color(n)}setPosition(n){this.position.copy(n),this.directionalLight.position.set(-n.x/2,-n.y/2,100)}initPlane(n=1e3,t=1e3){let e=new Y.PlaneGeometry(n,t),i=new Y.ShadowMaterial({transparent:!0,opacity:0,side:Y.DoubleSide}),r=new Y.Mesh(e,i);return r.receiveShadow=!0,r.position.z=-10,this.add(r),this.plane=r,r}setTarget(n){this.directionalLight.target=n}transformOpacity(n){return n*this.basicOpacity}setOpacity(n){this.plane.material.opacity=this.transformOpacity(n)}dispose(){Z(this,!0)}};var $t=y("three");var S=y("three");var On=y("lodash");var ki={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},Yt=class extends S.EventDispatcher{constructor(t,e={}){super();this.context=t;this.options={...ki,...e},this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}div;element;position=new S.Vector3;clientPos={x:0,y:0};visible=!0;options;placement="top";observer=null;initObserver(){let t=new MutationObserver((0,On.debounce)(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){if(this.element instanceof U&&this.element.options.geometry.type==="polygon"){let{max:r,min:s}=new S.Box3().setFromObject(this.element),l=(r.x+s.x)/2,u=(r.y+s.y)/2;return{left:new S.Vector3(s.x,u,r.z),leftTop:new S.Vector3(s.x,r.y,r.z),top:new S.Vector3(l,r.y,r.z),rightTop:new S.Vector3(r.x,r.y,r.z),right:new S.Vector3(r.x,u,r.z),rightBottom:new S.Vector3(r.x,s.y,r.z),bottom:new S.Vector3(l,s.y,r.z),leftBottom:new S.Vector3(s.x,s.y,r.z),center:new S.Vector3(l,u,r.z)}}let{x:t,y:e,z:i}=this.element?.getPosition?.()||this.position;return{left:new S.Vector3(t,e,i),leftTop:new S.Vector3(t,e,i),top:new S.Vector3(t,e,i),rightTop:new S.Vector3(t,e,i),right:new S.Vector3(t,e,i),rightBottom:new S.Vector3(t,e,i),bottom:new S.Vector3(t,e,i),leftBottom:new S.Vector3(t,e,i),center:new S.Vector3(t,e,i)}}getPlacementScreenPosition(){let{width:t,height:e}=this.context.clientSize,i=this.getPlacementPosition();return Object.keys(i).reduce((r,s)=>{let{x:l,y:u}=b(i[s],this.context.camera,t,e);return r[s]={x:l,y:u},r},{})}checkOverflow(t,e){let{width:i,height:r}=this.context.clientSize;return e.x>0&&t.x<i&&e.y<r&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:e}=this.div,i=this.getPlacementScreenPosition(),r=t/2,s=e/2,l=[{type:"center",getBox(u,a){return{max:{x:r+u,y:a-e},min:{x:u-r,y:a}}}},{type:"left",getBox(u,a){return{max:{x:u,y:a-s},min:{x:u-t,y:a+s}}}},{type:"leftTop",getBox(u,a){return{max:{x:u,y:a-e},min:{x:u-t,y:a}}}},{type:"top",getBox(u,a){return{max:{x:u+r,y:a-e},min:{x:u-r,y:a}}}},{type:"rightTop",getBox(u,a){return{max:{x:u+t,y:a-e},min:{x:u,y:a}}}},{type:"right",getBox(u,a){return{max:{x:u+t,y:a-s},min:{x:u,y:a+s}}}},{type:"rightBottom",getBox(u,a){return{max:{x:u+t,y:a},min:{x:u,y:a+e}}}},{type:"bottom",getBox(u,a){return{max:{x:u+r,y:a},min:{x:u-r,y:a+e}}}},{type:"leftBottom",getBox(u,a){return{max:{x:u,y:a},min:{x:u-t,y:a+s}}}}];for(let u=0;u<l.length;u++){let a=l[u],c=i[a.type],{max:p,min:f}=a.getBox(c.x,c.y);if(this.checkOverflow(p,f))return{type:a.type,position:c}}return{type:"center",position:i.center}}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}usePlacement(){let t=this.getPlacement();this.div.className=`overlay_${t.type}`,this._updatePosition(t.position.x,t.position.y)}bindElement(t){this.element=t,this.options.autoChangePlacement&&this.initObserver(),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 S.Box3().setFromObject(this.element).getCenter(new S.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:r}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=r}_updatePosition(t,e){this.clientPos={x:t,y:e};let{width:i,height:r,x:s,y:l}=this.context.clientSize;this.options.appendToBody&&(this.div.style.left=`${s}px`,this.div.style.top=`${l+r}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${t}px, ${-r+e}px, 0)`:this.dispatchEvent({type:"update-position",x:t,y:e,width:i,height:r})}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:r}=this.context.clientSize,{x:s,y:l}=b(e,this.context.camera,i,r);this.clientPos.x===s&&this.clientPos.y===l&&!t||this._updatePosition(s,l)}onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()};registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.observer?.disconnect(),this.div?.remove(),this.div=null}};var Vi={texts:[{text:""}],level:1,icon_position:"bottom",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},vt=class extends $t.EventDispatcher{constructor(t,e){super();this.context=t;this.options=wt({...Vi,...e},this),this.position.set(e.position?.x||0,e.position?.y||0,e.position?.z||0),this.overlay=new Yt(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:i,y:r,height:s})=>{this.overlay.div.style.transform=`translate3d(calc(${i}px - 50%), calc(${-s+r}px - ${this.options.icon&&this.options.icon_position!=="center"?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:i})=>{i?this.img?this.img.setAttribute("src",i):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:i})=>{let r=this.textDiv;if(r){let s=this.initText();this.div.replaceChild(s,r)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",({value:i})=>{this.overlay.setOpacity(i)}),this.addEventListener("change-icon_size",({value:i})=>{this.img&&(this.img.style.width=`${i?.[0]||32}px`,this.img.style.height=`${i?.[1]||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:i})=>{this.img&&(this.img.style.opacity=`${i}`)}),this.addEventListener("change-icon_border",({value:i})=>{this.img&&(this.img.style.border=`${i.width}px solid ${i.color}`)}),this.addEventListener("change-background",({value:i})=>{this.div.style.background=i})}div;textDiv;img;overlay;options;visible=!0;size={width:0,height:0};position=new $t.Vector3;userData={};showTextStatus=!0;disposed=!1;get withinDisplayRange(){return this.overlay.withinDisplayRange}async resetSize(){if(await nn(),!this.disposed)if(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 this.div=t,this.addText(),this.options.icon&&this.addIcon(),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.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(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[r,s]of Object.entries(e.styles))i.style[r]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${this.options.icon_size?.[0]||32}px`,t.style.height=`${this.options.icon_size?.[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}_changePosition=()=>{this.overlay.updatePosition(!0)};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,r=e*t,s=i*t,{x:l,y:u}=this.overlay.clientPos;return{left:l-r/2,right:l+r/2,top:this.options.icon?u-s:u-s/2,bottom:this.options.icon?u:u+s/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(),this.disposed=!0}};var z=y("three");var O=y("three"),Fn=y("@mars3d/heatmap.js"),pt=y("@turf/turf"),Zt=class extends O.Object3D{constructor(t){super();this.context=t;this.div=document.createElement("div")}heatmap;div;plane;clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:r,center:s}=this.getBox(t);this.heatmap=(0,Fn.create)({width:e,height:i,container:this.div,...this.context.config.heatMap}),this.heatmap.setData(this.transformData(t,r)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new O.PlaneGeometry(t,e),r=new O.Texture(this.div.firstChild);r.needsUpdate=!0;let s=new O.MeshBasicMaterial({transparent:!0,side:O.DoubleSide,map:r});s.needsUpdate=!0,this.plane=new O.Mesh(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new O.Matrix3().makeScale(1,-1).multiply(new O.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let l=new O.Vector2(s.x,s.y).applyMatrix3(i);return{x:l.x,y:l.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,pt.featureCollection)(t.data.map(a=>(0,pt.point)([a.x,a.y]))),i=(0,pt.bbox)(e),r=i[2]-i[0],s=i[3]-i[1],l={x:i[0],y:i[3]},u=(0,pt.center)(e);return{width:r,height:s,leftTop:l,center:u.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var Jt=y("three");var Kt=class extends Jt.Object3D{constructor(t,e){super();this.context=t;this.options=e;this.position.copy(e.position||new Jt.Vector3(0,0,0)),this.loadModel()}model=null;async loadModel(){let t=await Xt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t}dispose(){Z(this),this.model=null}};var te=y("three");var Un=y("three");var B=class extends Un.Object3D{constructor(t){super();this.context=t}dispose(){Z(this),this.children.forEach(t=>t.dispose?.()),this.clear()}};var Qt=class extends B{graphicMap=new Map;constructor(n){super(n)}getCenter(){return new te.Box3().setFromObject(this).getCenter(new te.Vector3)}createGraphic(n){let t=new U(this.context,n);return this.add(t),this.graphicMap.set(n.id,t),t}removeGraphic(n){this.remove(n),this.graphicMap.delete(n.options.id),n.dispose()}removeGraphicById(n){this.graphicMap.has(n)&&this.removeGraphic(this.graphicMap.get(n))}getGraphicByNodeId(n){return this.graphicMap.get(n)||null}getGraphicByRaycaster(n){let t={distance:1e4,graphic:null,position:null},e=this.children.reduce((i,r)=>{if(r instanceof U){let s=r.raycast(n);if(s){let{distance:l}=s;if(l<i.distance)return{distance:s.distance,position:s.position,graphic:r}}return i}else return i},t);return e===t?{graphics:[],position:null}:{graphics:[e.graphic],position:e.position}}};var Bn=y("lodash");var At=class extends B{pois=[];debounceCollisionDetection;timer=new W;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=(0,Bn.debounce)(this.collisionDetection,10)}clear(n=!1){return this.pois.forEach(t=>{t.options.built_in&&!n||t.dispose()}),this.pois=n?[]:this.pois.filter(t=>t.options.built_in),this}createPoi(n){let t=new vt(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){return this.pois.filter(i=>i instanceof vt&&i.isContain(n,t))}onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[];this.pois.filter(e=>e.visible&&e.withinDisplayRange).forEach((e,i)=>{let{left:r,right:s,top:l,bottom:u}=e.getBox();if(i===0||!e.options.collision_enable){n.push({left:r,right:s,top:l,bottom:u}),e.parentSetVisible(!0);return}let a=n.some(c=>c.left<s&&c.right>r&&c.top<u&&c.bottom>l);e.parentSetVisible(!a),a||n.push({left:r,right:s,top:l,bottom:u})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var Gn=y("lodash");var ne=y("three"),ee=class extends B{pois=[];debounceCollisionDetection;timer=new W;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=(0,Gn.debounce)(this.collisionDetection,10)}clear(){return this.pois.forEach(n=>{n.dispose()}),this.pois=[],this}createPoi(n){let t=new k(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.remove(n),this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(this.add(n),!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){let e=new ne.Vector2(n,t);return this.pois.filter(r=>r instanceof k&&r.canSelect&&r.box.containsPoint(e))}changeParkingSpaceVisibleByZoom=()=>{let n=this.parent?.parent;if(n&&n instanceof rt){let{clientSize:{width:t,height:e}}=this.context,{max:i,min:r}=n.box,l=Math.min(t/(i.x-r.x),e/(i.y-r.y))*(i.x-r.x)/60;this.pois.filter(u=>u.userData.type==="parkingSpace").map(u=>{let a=this.context.camera.zoom>=l;u.visible=a,a||u.parentSetVisible(a)})}};onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[],{camera:t}=this.context;t.updateMatrixWorld();let e=s=>s<=1&&s>=-1,i=t.projectionMatrix.clone();i.multiply(t.matrixWorldInverse),this.pois.filter(s=>{if(s.visible){let l=new ne.Vector3().setFromMatrixPosition(s.matrixWorld);return l.applyMatrix4(i),s.screenPosition=l,e(l.x)&&e(l.y)&&e(l.z)}return!1}).forEach((s,l)=>{let u=s.getBox(s.screenPosition);if(l===0||!s.options.collision_enable){n.push(u),s.parentSetVisible(!0);return}let a=n.some(c=>c.intersectsBox(u));s.parentSetVisible(!a),a||n.push(u)})}registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var rt=class extends z.Object3D{constructor(t){super();this.context=t;this.groundLayer=new B(this.context),this.graphicLayer=new Qt(this.context),this.poiLayer=new At(this.context),this.poiLayer2=new ee(this.context),this.wallLayer=new B(this.context),this.textureLayer=new B(this.context),this.glbModelLayer=new B(this.context),this.laneLayer=new B(this.context),this.mergeGraphicLayer=new B(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}graphicLayer;poiLayer;poiLayer2;wallLayer;textureLayer;glbModelLayer;laneLayer;mergeGraphicLayer;grounds=new Set;groundLayer;shadow=new jt;heatmap;groundUpper=new z.Object3D;models=new z.Object3D;modelMap=new Map;groundMaxHeight=0;name="";key="";box=new z.Box3;getPosition(){return this.box.getCenter(new z.Vector3)}createGround(t){let e=new U(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundLayer.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.groundUpper.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new z.Box3().setFromObject(this).getCenter(new z.Vector3)}addModel(t){let e=new Kt(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new z.Box3().setFromObject(this.groundUpper),e=t.getCenter(new z.Vector3),i=t.getSize(new z.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 Zt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new z.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}updateBox(){this.box.setFromObject(this)}dispose(){this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.grounds.forEach(t=>t.dispose()),this.heatmap?.dispose(),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var ie=y("three");var ot=class extends ie.EventDispatcher{constructor(t){super();this.context=t;this.svg=en(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}points=[];svg;enable=!0;_onResize=({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))};_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:r,offsetY:s}=t,{clientWidth:l,clientHeight:u}=i.domElement,a=r/l*2-1,c=1-s/u*2;return new ie.Vector3(a,c,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 re=class extends ot{constructor(t){super(t);this.context=t;let{config:{svg:{circle:e,line:i}}}=t;this.circles=[It(e.radius,e.fill),It(e.radius,e.fill)],this.line=Vt(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}circles;line;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)}onUpdate=()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);_t(this.circles[0],t.x,t.y),K(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);_t(this.circles[1],t.x,t.y),K(this.line,void 0,t)}};onPointermove=t=>{this.points.length===1&&(this.line.style.display="block",K(this.line,void 0,{x:t.offsetX,y:t.offsetY}))};onPointerleave=()=>{this.points[1]||(this.line.style.display="none")};onPointerdown=t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:r}=t,s=this.circles[this.points.length];_t(s,i,r),this.points.length||K(this.line,{x:i,y:r},{x:i,y:r}),this.addPoint(e)}};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:r}]=this.points;return Math.sqrt((i-t)**2+(r-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var oe=class extends ot{circles=[];lines=[];isClose=!1;constructor(n){super(n),this.registryEvent()}setEnable(n){super.setEnable(n),n?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(n){this.circles.push(n),this.svg.appendChild(n)}addLine(n){this.lines.push(n),this.svg.appendChild(n)}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)}onUpdate=()=>{this.points.length&&this.points.forEach((n,t)=>{let e=this.getSvgCoordinate(n);this.circles[t]&&_t(this.circles[t],e.x,e.y),t!==0&&K(this.lines[t-1],void 0,e),this.lines[t]&&K(this.lines[t],e)})};onPointermove=n=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",K(this.lastLine,void 0,{x:n.offsetX,y:n.offsetY}))};onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")};onPointerdown=n=>{if(this.isClose)return;let t=this.getIntersectByPointerEvent(n);if(t){let{offsetX:e,offsetY:i}=n;this.checkAdsorb(e,i)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(t);let{circle:{fill:r,radius:s},line:{stroke:l}}=this.context.config.svg;if(!this.isClose){let u=It(s,r);_t(u,e,i),this.addCircle(u)}if(this.lines.length&&K(this.lastLine,void 0,{x:e,y:i}),!this.isClose){let u=Vt(l);K(u,{x:e,y:i},{x:e,y:i}),this.addLine(u)}}};checkAdsorb(n,t){if(this.points.length<3)return!1;let e=this.circles[0],i=+e.getAttribute("cx"),r=+e.getAttribute("cy");return Math.sqrt((n-i)**2+(t-r)**2)<=5}addPoint(n){if(this.points.push(n),this.isClose){let t=this.calculatedArea();this.dispatchEvent({type:"area",area:t})}}calculatedArea(){let n=this.points.map(i=>[i.x,i.y]),t=0,e=n.length;for(let i=0;i<e;i++){let r=(i+1)%e;t+=n[i][0]*n[r][1]-n[r][0]*n[i][1]}return Math.abs(t/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var kn=y("three");var zn=class extends ot{constructor(t){super(t);this.context=t;let{config:{svg:{line:e}}}=t;this.rect=Tt(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Tt(e.stroke,"#ffffff"),this.centerRect[i]=Tt(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}rect;cornerRect=[];centerRect=[];graphic;setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}onUpdate=()=>{if(this.graphic){let t=new kn.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:r}}=this.context,{min:s,max:l}=t,u=b(s,e,i,r),a=b(l,e,i,r);J(this.rect,u.x,a.y,Math.abs(a.x-u.x),Math.abs(a.y-u.y));let{x:c,y:p}=u,{x:f,y:m}=a,h=5,d=[{x:c-h,y:m-h},{x:f-h,y:m-h},{x:c-h,y:p-h},{x:f-h,y:p-h}];for(let E=0;E<d.length;E++)J(this.cornerRect[E],d[E].x,d[E].y,h*2,h*2);let g=4,v=(c+f)/2,P=(p+m)/2,C=[{x:v-g,y:m-g},{x:c-g,y:P-g},{x:f-g,y:P-g},{x:v-g,y:p-g}];for(let E=0;E<C.length;E++)J(this.centerRect[E],C[E].x,C[E].y,g*2,g*2)}else{J(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)J(this.cornerRect[t],0,0,0,0),J(this.centerRect[t],0,0,0,0)}};selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var A=y("three");var Ie=y("three/examples/jsm/utils/BufferGeometryUtils"),se=class extends A.Object3D{constructor(t,e){super();this.context=t;this.options=e;e.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(e=>{let i=nt(e.geometry.coords[0],e.geometry.coords.slice(1));return new A.ExtrudeGeometry(i,{steps:1,bevelEnabled:!1,depth:e.height,curveSegments:4})});this.geometry=(0,Ie.mergeGeometries)(t),t.forEach(e=>e.dispose())}initMaterial(){let t=`
2
2
  varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
3
3
  uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
4
4
  uniform vec3 uColor;