@aibee/crc-bmap 0.14.38 → 0.14.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames,en=Object.getOwnPropertySymbols,Xa=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty,Ya=Object.prototype.propertyIsEnumerable;var Ks=(a,t,e)=>t in a?Xs(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,We=(a,t)=>{for(var e in t||(t={}))sn.call(t,e)&&Ks(a,e,t[e]);if(en)for(var e of en(t))Ya.call(t,e)&&Ks(a,e,t[e]);return a};var ne=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var qa=(a,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ka(t))!sn.call(a,s)&&s!==e&&Xs(a,s,{get:()=>t[s],enumerable:!(i=Va(t,s))||i.enumerable});return a};var Ys=(a,t,e)=>(e=a!=null?ja(Xa(a)):{},qa(t||!a||!a.__esModule?Xs(e,"default",{value:a,enumerable:!0}):e,a));var it=(a,t,e)=>Ks(a,typeof t!="symbol"?t+"":t,e);var g=(a,t,e)=>new Promise((i,s)=>{var o=h=>{try{r(e.next(h))}catch(c){s(c)}},n=h=>{try{r(e.throw(h))}catch(c){s(c)}},r=h=>h.done?i(h.value):Promise.resolve(h.value).then(o,n);r((e=e.apply(a,t)).next())});var xn=ne((dg,vn)=>{vn.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t}});var Pn=ne((ug,_n)=>{var wn=xn();_n.exports=function(a,t){Array.isArray(t)||(t=[]),a.length>0&&t.push(wn([0,0],a[0]));for(var e=0;e<a.length-1;e++){var i=a[e],s=a[e+1],o=i[0],n=i[1],r=s[0],h=s[1],c=[.75*o+.25*r,.75*n+.25*h],l=[.25*o+.75*r,.25*n+.75*h];t.push(c),t.push(l)}return a.length>1&&t.push(wn([0,0],a[a.length-1])),t}});var Ln=ne((wg,Tn)=>{var to=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((t,e)=>t.priority-e.priority)}set(t,e){let i=Number(e);if(isNaN(i))throw new TypeError('"priority" must be a number');return this.keys.has(t)?this.queue.map(s=>(s.key===t&&Object.assign(s,{priority:i}),s)):(this.keys.add(t),this.queue.push({key:t,priority:i})),this.sort(),this.queue.length}next(){let t=this.queue.shift();return this.keys.delete(t.key),t}isEmpty(){return this.queue.length===0}has(t){return this.keys.has(t)}get(t){return this.queue.find(e=>e.key===t)}};Tn.exports=to});var Dn=ne((_g,An)=>{function kn(a,t){let e=new Map;for(let[i,s]of a)i!==t&&s instanceof Map?e.set(i,kn(s,t)):i!==t&&e.set(i,s);return e}An.exports=kn});var Fn=ne((Pg,On)=>{function uh(a){let t=Number(a);return!(isNaN(t)||t<=0)}function Rn(a){let t=new Map;return Object.keys(a).forEach(i=>{let s=a[i];if(s!==null&&typeof s=="object"&&!Array.isArray(s))return t.set(i,Rn(s));if(!uh(s))throw new Error(`Could not add node at key "${i}", make sure it's a valid node`,s);return t.set(i,Number(s))}),t}On.exports=Rn});var Bn=ne((Mg,Gn)=>{function In(a){if(!(a instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof a}`);a.forEach((t,e)=>{if(typeof t=="object"&&t instanceof Map){In(t);return}if(typeof t!="number"||t<=0)throw new Error(`Values must be numbers greater than 0. Found value ${t} at ${e}`)})}Gn.exports=In});var io=ne((bg,Un)=>{var mh=Ln(),fh=Dn(),zn=Fn(),Wn=Bn(),eo=class{constructor(t){t instanceof Map?(Wn(t),this.graph=t):t?this.graph=zn(t):this.graph=new Map}addNode(t,e){let i;return e instanceof Map?(Wn(e),i=e):i=zn(e),this.graph.set(t,i),this}addVertex(t,e){return this.addNode(t,e)}removeNode(t){return this.graph=fh(this.graph,t),this}path(t,e,i={}){if(!this.graph.size)return i.cost?{path:null,cost:0}:null;let s=new Set,o=new mh,n=new Map,r=[],h=0,c=[];if(i.avoid&&(c=[].concat(i.avoid)),c.includes(t))throw new Error(`Starting node (${t}) cannot be avoided`);if(c.includes(e))throw new Error(`Ending node (${e}) cannot be avoided`);for(o.set(t,0);!o.isEmpty();){let l=o.next();if(l.key===e){h=l.priority;let d=l.key;for(;n.has(d);)r.push(d),d=n.get(d);break}s.add(l.key),(this.graph.get(l.key)||new Map).forEach((d,u)=>{if(s.has(u)||c.includes(u))return null;if(!o.has(u))return n.set(u,l.key),o.set(u,l.priority+d);let f=o.get(u).priority,x=l.priority+d;return x<f?(n.set(u,l.key),o.set(u,x)):null})}return r.length?(i.trim?r.shift():r=r.concat([t]),i.reverse||(r=r.reverse()),i.cost?{path:r,cost:h}:r):i.cost?{path:null,cost:0}:null}shortestPath(...t){return this.path(...t)}};Un.exports=eo});function w(){return w=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},w.apply(this,arguments)}import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.json.stringify.js";import{Box3 as ku,EventDispatcher as Au,Sprite as Do,Vector3 as Ro}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var K=class{requestAnimationFrame(t){let e=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(e),t()});return this.tasks.requestAnimation.add(e),e}cancelAnimationFrame(t){this.tasks.requestAnimation.delete(t),window.cancelAnimationFrame(t)}setTimeout(t,e){let i=window.setTimeout(()=>{this.tasks.timeout.delete(i),t()},e);return this.tasks.timeout.add(i),i}clearTimeout(t){this.tasks.timeout.delete(t),window.clearTimeout(t)}setInterval(t,e){let i=window.setInterval(()=>{t()},e);return this.tasks.interval.add(i),i}clearInterval(t){this.tasks.interval.delete(t),window.clearInterval(t)}requestIdleCallback(t,e){let i=window.requestIdleCallback(s=>{this.tasks.requestIdleCallback.delete(i),t(s)},e);return this.tasks.requestIdleCallback.add(i),i}cancelIdleCallback(t){this.tasks.requestIdleCallback.delete(t),window.cancelIdleCallback(t)}dispose(){this.tasks.requestAnimation.forEach(t=>{window.cancelAnimationFrame(t)}),this.tasks.requestAnimation.clear(),this.tasks.requestIdleCallback.forEach(t=>{window.cancelIdleCallback(t)}),this.tasks.requestIdleCallback.clear(),this.tasks.timeout.forEach(t=>{window.clearTimeout(t)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(t=>{window.clearInterval(t)}),this.tasks.interval.clear()}constructor(){this.tasks={requestAnimation:new Set,requestIdleCallback:new Set,timeout:new Set,interval:new Set}}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Shape as $a,Group as Ja,DirectionalLight as Qa,AmbientLight as th,Path as eh,Vector2 as on}from"three";function nn(){let a=new Ja,t=new th(16777215,.3);return a.add(t),a}function ui(a,t){t===void 0&&(t=[]);let e=new $a(a.map(i=>new on(...i)));return t.length&&t.forEach(i=>{var s=new eh(i.map(o=>new on(...o)));e.holes.push(s)}),e}function rn(a,t){a===void 0&&(a=16777215),t===void 0&&(t=1);let e=new Qa(a,t);return e.castShadow=!0,e.shadow.radius=8,e.shadow.bias=-.001,e.shadow.mapSize.set(256,256),e.shadow.camera.left=-200,e.shadow.camera.right=200,e.shadow.camera.top=200,e.shadow.camera.bottom=-200,e}function F(a,t){if(t&&a.children&&a.children.length&&a.children.forEach(e=>{F(e,t)}),a.isMesh){let e=a;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}a.isLight&&(a.dispose==null||a.dispose.call(a))}import"core-js/modules/es.regexp.exec.js";function an(a){return/[\u4E00-\u9FA5]+/g.test(a)}import"core-js/modules/web.dom-collections.iterator.js";import{Vector3 as fi,Vector2 as jt,Matrix3 as mi}from"three";import{point as ih,featureCollection as sh,center as oh}from"@turf/turf";function L(a,t,e,i){let s=a.clone().project(t),o=e/2,n=i/2,r=Math.round(s.x*o+o),h=Math.round(-s.y*n+n);return{x:r,y:h}}function yf(a,t,e,i,s){if(!s)return null;e=Math.min(1,e),i=Math.min(1,i);let o=a/e*2-1,n=1-t/i*2;return new fi(o,n,0).unproject(s)}function gi(a){let t=sh(a.map(i=>ih(i)));return oh(t).geometry.coordinates}function te(a,t,e){return a.x>=t.x&&a.x<=e.x&&a.y>=t.y&&a.y<=e.y}function vf(a){let t=0,e=new fi;for(let i=1;i<a.length;i++){let s=new fi(a[i-1][0],a[i-1][1],0),o=new fi(a[i][0],a[i][1],0),n=o.distanceTo(s);n>t&&(t=n,e=o.clone().sub(s).normalize())}return e}function A(a,t){return Math.sqrt((t[0]-a[0])**2+(t[1]-a[1])**2)}function ft(a){let t=0;for(let e=0;e<a.length-1;e++)t+=A(a[e],a[e+1]);return t}function ge(a,t,e){let i=new jt(t[0]-a[0],t[1]-a[1]),s=new jt(t[0]-e[0],t[1]-e[1]),n=i.angleTo(s)*180/Math.PI,r=new jt(t[0]-a[0],t[1]-a[1]);return new jt(e[0]-a[0],e[1]-a[1]).cross(r)>0?n:-n}function xf(a,t){let e=Math.min(A(a[0][0],a[0][1]),A(a[0][2],a[0][1]))-1;t||(t=gi(a[0]));let i=nh(t,e),s=new jt(a[0][0][0],a[0][0][1]),o=new jt(a[0][1][0],a[0][1][1]),n=new jt(a[0][2][0],a[0][2][1]),h=(s.distanceTo(o)>o.distanceTo(n)?o.clone().sub(s):n.clone().sub(o)).angleTo(new jt(0,1)),c=new mi;return c.multiply(new mi().translate(t[0],t[1])).multiply(new mi().rotate(h)).multiply(new mi().translate(-t[0],-t[1])),[i.map(l=>{let p=new jt(l[0],l[1]).applyMatrix3(c);return[p.x,p.y]})]}function nh(a,t){let e=t/2;return[[a[0]-e,a[1]+e],[a[0]+e,a[1]+e],[a[0]+e,a[1]-e],[a[0]-e,a[1]-e],[a[0]-e,a[1]+e]]}function Vt(a,t){let e=0,i=1/0,[s,o]=t;for(let n=0;n<a.length-1;n++){let[r,h]=a[n],[c,l]=a[n+1],p=Math.min(r,c)<=s&&s<=Math.max(r,c),d=Math.min(h,l)<=o&&o<=Math.max(h,l);if(p&&d){let u=Math.abs((c-r)*(o-h)-(l-h)*(s-r));u<i&&(i=u,e=n)}}return e}function hn(a,t){let e=a[0],i=a[1],s=!1;for(let o=0,n=t.length-1;o<t.length;n=o++){let r=t[o][0],h=t[o][1],c=t[n][0],l=t[n][1];h>i!=l>i&&e<(c-r)*(i-h)/(l-h)+r&&(s=!s)}return s}import"core-js/modules/es.reflect.to-string-tag.js";function ye(a,t){return new Proxy(a,{get:(e,i,s)=>Reflect.get(e,i,s),set:(e,i,s,o)=>{let n=Reflect.get(e,i,o),r=Reflect.set(e,i,s,o);return n!==s&&t.dispatchEvent({type:"change-"+i,value:s}),r}})}import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.error.cause.js";function Mt(a,t){return Promise.race([a,new Promise((e,i)=>{setTimeout(()=>i(new Error("Promise timeout")),t)})])}function yi(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function cn(a,t){let e=yi("svg");return e.setAttribute("width",a),e.setAttribute("height",t),e.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",e}function Gt(a,t){a===void 0&&(a="2");let e=yi("circle");return e.setAttribute("r",a),e.setAttribute("fill",t),e}function Kt(a){let t=yi("line");return t.setAttribute("stroke",a),t}function gt(a,t){let e=yi("rect");return e.setAttribute("stroke",a),e.setAttribute("fill",t),e}function yt(a,t,e){a.setAttribute("cx",""+t),a.setAttribute("cy",""+e)}function rt(a,t,e){t&&(a.setAttribute("x1",""+t.x),a.setAttribute("y1",""+t.y)),e&&(a.setAttribute("x2",""+e.x),a.setAttribute("y2",""+e.y))}function j(a,t,e,i,s){a.setAttribute("x",""+t),a.setAttribute("y",""+e),a.setAttribute("width",""+i),a.setAttribute("height",""+s)}function ln(){return Promise.resolve()}function qs(){return new Promise(a=>{requestAnimationFrame(a)})}function pn(a){return a===void 0&&(a=1),new Promise(t=>{function e(){a<=0?t(!0):(a--,window.requestAnimationFrame(e))}window.requestAnimationFrame(e)})}import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.trim.js";function Af(a){return parseInt(a.replace("#","0x"),16)}function Df(a,t){let e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16),o=Math.round(e*t),n=Math.round(i*t),r=Math.round(s*t);return"#"+(1<<24|o<<16|n<<8|r).toString(16).slice(1)}function Xt(a,t){t===void 0&&(t=.85);let e,i,s;if(a.startsWith("#"))e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16);else{let n=a.slice(4,-1).split(",");e=parseInt(n[0].trim()),i=parseInt(n[1].trim()),s=parseInt(n[2].trim())}return e=Math.min(Math.floor(e*t),255),i=Math.min(Math.floor(i*t),255),s=Math.min(Math.floor(s*t),255),"#"+((1<<24)+(e<<16)+(i<<8)+s).toString(16).slice(1)}function Rf(a,t){a=a.replace(/^#/,"");let e=parseInt(a.substring(0,2),16),i=parseInt(a.substring(2,4),16),s=parseInt(a.substring(4,6),16);return t!==void 0?"rgba("+e+", "+i+", "+s+", "+t+")":"rgb("+e+", "+i+", "+s+")"}import"core-js/modules/es.regexp.exec.js";var re=navigator.userAgent.toUpperCase().indexOf("MAC")>=0,dn=(navigator.userAgent||"").toLocaleLowerCase(),ee=/ios|iphone/i.test(dn),If=/android|adr|linux/gi.test(dn),vi=ee||re&&navigator.maxTouchPoints>1;function ve(a){return re?a==="Meta":a==="Control"}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var $s="__once__",un=class{on(t,e){if(typeof e!="function")return;let i=this.events.get(t);return i?i.add(e):this.events.set(t,new Set([e]))}once(t,e){if(typeof e!="function")return;let i=""+$s+t,s=this.events.get(i);return s?s.add(e):this.events.set(i,new Set([e]))}off(t,e){let i=this.events.get(t),s=this.events.get(""+$s+t);!i&&!s||(e===void 0&&(i==null||i.clear(),s==null||s.clear()),i!=null&&i.has(e)&&i.delete(e),s!=null&&s.has(e)&&s.delete(e))}offAll(){this.events.clear()}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];let o=this.events.get(t),n=this.events.get(""+$s+t);!o&&!n||(o==null||o.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.clear())}constructor(){this.events=new Map}};var lt=function(a){return a.SWITCH_FLOOR_BEFORE="switch_floor_before",a.SWITCH_FLOOR_GROUND="switch_floor_ground",a.SWITCH_FLOOR_AFTER="switch_floor_after",a}({});import"core-js/modules/es.array.sort.js";function ae(a){return a?typeof a=="string"||typeof a=="number"||typeof a=="boolean"?a.toString():Object.keys(a).sort().map(t=>t+"="+ae(a[t])).join("&"):""}import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";import{BufferGeometry as rh,Float32BufferAttribute as gn}from"three";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";function mn(a){return a.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function fn(a){let t=[],e=/(\([^()]*\))|([^()]*)/g,i=0,s;for(;(s=e.exec(a))!==null;)s.index>i&&t.push(a.substring(i,s.index)),t.push(s[0]),i=s.index+s[0].length;return i<a.length&&t.push(a.substring(i)),t}var xi=28,ah=.88,hh=.12,ch=.125;function yn(a,t,e){if(/[\r\n]/.test(a)){let n=[];for(let r of a.split(/\r?\n/)){if(!r){n.push("");continue}n.push(...yn(r,t,e))}for(;n.length>1&&!n[n.length-1];)n.pop();return n}let i=fn(a),s=[],o="";for(let n of i)if(n.startsWith("(")||n.startsWith("\uFF08"))s.push(n.slice(1,-1));else{let r=n.split(" ");for(let h of r){let c=o?o+" "+h:h;if(e(c)>t)if(o&&s.push(o),e(h)>t||an(h)){let l="";for(let p of Array.from(h)){let d=l+p;e(d)>t&&l?(s.push(l),l=p):l=d}l&&(o=l)}else o=h;else o=c}}return o&&s.push(o),s}function wi(a,t,e,i){i===void 0&&(i=600);let s=W=>{var J;return(J=t.get(W))!=null?J:null},o=W=>{let J=0;for(let Q of Array.from(W)){var z,mt;J+=(mt=(z=s(Q))==null?void 0:z.glyphAdvance)!=null?mt:e.fontSize*.5}return J},n=e.fontSize/xi,r=Math.max(0,i*n),h=yn(a,r,o),c=h.length||1;var l;let p=(l=e.ascentRatio)!=null?l:ah;var d;let u=(d=e.descentRatio)!=null?d:hh;var f;let x=e.fontSize*(1+((f=e.lineGapRatio)!=null?f:ch)),m=e.fontSize*p,y=e.fontSize*u,_=e.buffer,P=(c-1)*x+m+y,S=h.map((W,J)=>{let z=Array.from(W),mt=z.map(D=>s(D)),Q=mt.reduce((D,V)=>{var Z;return D+((Z=V==null?void 0:V.glyphAdvance)!=null?Z:e.fontSize*.5)},0),I=P-(J*x+m);return{chars:z,records:mt,advance:Q,baselineY:I}}),k=S.reduce((W,J)=>Math.max(W,J.advance),0)||1,b=[],G=1/0,R=-1/0;S.forEach(W=>{let J=(k-W.advance)/2;W.chars.forEach((z,mt)=>{let Q=W.records[mt];if(Q&&!Q.blank&&Q.width>0&&Q.height>0){let D=W.baselineY+Q.glyphTop-Q.glyphHeight-_;b.push({char:z,record:Q,x:J+Q.glyphLeft-_,y:D}),G=Math.min(G,D+_),R=Math.max(R,D+_+Q.glyphHeight)}var I;J+=(I=Q==null?void 0:Q.glyphAdvance)!=null?I:e.fontSize*.5})});let O=Number.isFinite(G)&&Number.isFinite(R),$=O?G:0,nt=O?Math.max(R-$,1):P;return{lines:h,glyphs:b,width:k,height:P,aspect:k/P,linesCount:c,inkBottom:$,inkHeight:nt}}function Ue(a,t){t===void 0&&(t={});let{glyphs:e,width:i,height:s}=a,{pivotY:o=.5,pivotX:n=.5,normalizeBottom:r=0,normalizeHeight:h=s}=t;if(!e.length||s<=0||i<=0||h<=0)return[];let c=1/h,l=i*c,p=new Map;e.forEach(u=>{let{record:f}=u;var x;let m=(x=f.page)!=null?x:0,y=p.get(m);y||(y={positions:[],uvs:[],indices:[]},p.set(m,y));let _=u.x*c-l*n,P=(u.x+f.width)*c-l*n,S=(u.y-r)*c-o,E=(u.y+f.height-r)*c-o,{u0:k,u1:b,v0:G,v1:R}=f,O=y.positions.length/3;y.positions.push(_,S,0),y.uvs.push(k,R),y.positions.push(P,S,0),y.uvs.push(b,R),y.positions.push(P,E,0),y.uvs.push(b,G),y.positions.push(_,E,0),y.uvs.push(k,G),y.indices.push(O,O+1,O+2,O,O+2,O+3)});let d=[];return p.forEach((u,f)=>{if(!u.positions.length)return;let x=new rh;x.setAttribute("position",new gn(u.positions,3)),x.setAttribute("uv",new gn(u.uvs,2)),x.setIndex(u.indices),x.computeBoundingSphere(),d.push({page:f,geometry:x})}),d.sort((u,f)=>u.page-f.page),d}function lg(a,t){return new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",a,!0),Object.keys(t.headers||{}).forEach(o=>{s.setRequestHeader(o,t.headers[o])}),t.responseType&&(s.responseType=t.responseType),s.onload=()=>{if(s.status>=200&&s.status<300)if(t.responseType==="arraybuffer")e(s.response);else try{let o=JSON.parse(s.responseText);e(o)}catch(o){i(o)}else i(s.statusText)},s.onerror=()=>{i(s.statusText)},s.send()})}var Mn=Ys(Pn(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Vector2 as He}from"three";function lh(a,t){let e=a.clone().normalize(),i=t.clone().normalize();return Math.acos(e.dot(i))}function ph(a){let t=0;return a.reduce((e,i)=>{let[s,o]=e,[n,r]=i;return t+=Math.sqrt((n-s)**2+(r-o)**2),[n,r]}),t/a.length}function bn(a,t){if(t===void 0&&(t=.25),ph(a)<t)return a;let e=(0,Mn.default)(a);return bn(e,t)}function _i(a,t,e,i,s,o){t===void 0&&(t=!1),e===void 0&&(e=!0),i===void 0&&(i=5),s===void 0&&(s=150),o===void 0&&(o=3);let n=[],r=!t;if(n.push(a[0]),a.length<2)return n;for(let c=0;c<a.length-2;c+=1){let l=a[c],p=a[c+1],d=a[c+2],u=new He(l[0]-p[0],l[1]-p[1]),f=new He(d[0]-p[0],d[1]-p[1]),x=lh(u,f)/Math.PI*180,m=u.length()+f.length();(!r||x<s&&m>.01||m>i)&&(n.push(a[c+1]),r=!0)}if(n.push(a[a.length-1]),!e)return n;let h=[];h.push(n[0]);for(let c=0;c<n.length-2;c+=1){let l=new He(n[c][0],n[c][1]),p=new He(n[c+1][0],n[c+1][1]),d=new He(n[c+2][0],n[c+2][1]),u=l.distanceTo(p)/2,f=d.distanceTo(p)/2,x=p.clone(),m=p.clone();x.add(l.clone().sub(p).normalize().multiplyScalar(u>o?o/2:u)),m.add(d.clone().sub(p).normalize().multiplyScalar(f>o?o/2:f));let y=[[x.x,x.y],[p.x,p.y],[m.x,m.y]];h.push(...bn(y,o/25))}return h.push(n[n.length-1]),dh(h)}function dh(a){if(a.length<=1)return a;let t=[],e;return a.forEach(i=>{let[s,o]=i;e?s===e[0]&&o===e[1]||(e=[s,o],t.push([s,o])):(e=[s,o],t.push([s,o]))}),t}function En(a,t,e){let i=Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2);if(i===0)return{distance:Math.sqrt((a[0]-t[0])**2+(a[1]-t[1])**2),closestPoint:t.slice(0)};let s=Math.max(0,Math.min(1,((a[0]-t[0])*(e[0]-t[0])+(a[1]-t[1])*(e[1]-t[1]))/i**2)),o=[t[0]+s*(e[0]-t[0]),t[1]+s*(e[1]-t[1])];return{distance:Math.sqrt((a[0]-o[0])**2+(a[1]-o[1])**2),closestPoint:o}}function vg(a,t,e){let[i,s]=a,[o,n]=t,r=Math.sqrt(Math.pow(o-i,2)+Math.pow(n-s,2));if(r===0||r<e)return[...t];let h=e/r,c=i+(o-i)*h,l=s+(n-s)*h;return[c,l]}var Yt=function(a){return 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}({});function Js(a,t,e){let i=ge(a,t,e);return Qs(i)}function Qs(a){return 180-Math.abs(a)<15?"front":a>135?"right_front":a<-135?"left_front":a<=135&&a>=60?"right":a>=-135&&a<=-60?"left":a<60&&a>0?"right_back":a>-60&&a<0?"left_back":"front"}function Sn(a){if(!a.length)return[];if(a.length===1)return[{direction:"start",distance:0,points:a}];let t=[{direction:"start",distance:A(a[0],a[1]),points:[a[0],a[1]]}];for(let e=2;e<a.length;e++){let i=Js(a[e-2],a[e-1],a[e]);if(i==="front"){let s=t[t.length-1],o=A(a[e-1],a[e]);s.distance+=o,e!==2&&s.points.push(a[e-1])}else t.push({direction:i,distance:A(a[e-1],a[e]),points:[a[e-1],a[e]]})}return t.push({direction:"end",distance:0,points:[a[a.length-1]]}),t}function Cn(a,t){if(a.length<2)return-1;let e=0;for(let i=1;i<a.length;i++){let s=a[i-1],o=a[i],n=[t[0]-s[0],t[1]-s[1]],r=[o[0]-s[0],o[1]-s[1]],h=Math.min(o[0],s[0])<=t[0]&&t[0]<=Math.max(o[0],s[0]),c=Math.min(o[1],s[1])<=t[1]&&t[1]<=Math.max(o[1],s[1]);if(h&&c){let l=n[0]*r[1]-n[1]*r[0];if(Math.abs(l)<1e-6){let p=Math.sqrt((t[0]-s[0])**2+(t[1]-s[1])**2);return e+p}}e+=Math.sqrt((o[0]-s[0])**2+(o[1]-s[1])**2)}return-1}function xe(a,t){if(a.length<2){var e;return(e=a[0])!=null?e:null}let i=0;for(let s=1;s<a.length;s++){let o=a[s-1],n=a[s],r=Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2);if(i+=r,i>=t){let h=(t-(i-r))/r,c=o[0]+(n[0]-o[0])*h,l=o[1]+(n[1]-o[1])*h;return[c,l]}}return null}var Bt=Ys(io(),1);import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";var bt="___",Hn=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(i=>{let s=""+e.floor+bt+i.id;if(this.pointMap.set(s,i),this.nodeMap.set(""+i.floor+bt+i.nodeId,s),i.type==="straightLadder"){let o=this.straightLadderMap.get(i.name)||[];o.push(w({},i)),this.straightLadderMap.set(i.name,o)}if(i.type==="staircase"){let o=this.staircaseMap.get(i.name)||[];o.push(w({},i)),this.staircaseMap.set(i.name,o)}if(i.type==="escalator"){let o=this.escalatorMap.get(i.name)||{};i.escalatorDirection==="exit"?o.end={floor:i.floor,id:i.id}:o.start={floor:i.floor,id:i.id},this.escalatorMap.set(i.name,o)}if(i.type==="facility"){let o=this.facilityMap.get(i.targetId)||[];o.push(w({},i)),this.facilityMap.set(i.targetId,o)}}),e.lines.filter(i=>i.direction!=="no").forEach(i=>{var s,o;let n=""+e.floor+bt+i.from,r=""+e.floor+bt+i.to,h=(s=this.pointMap.get(n))==null?void 0:s.cds,c=(o=this.pointMap.get(r))==null?void 0:o.cds;if(h!=null&&h.length&&(c!=null&&c.length)){let l=A(h,c);this.addLineItem(n,r,l),i.direction==="double"&&this.addLineItem(r,n,l)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map;o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let l=0;l<r.length;l++){let p=""+r[l].floor+bt+r[l].id;for(let d=0;d<r.length;d++)if(l!==d){var h,c;let u=""+r[d].floor+bt+r[d].id,f=(h=this.pointMap.get(p))==null?void 0:h.cds,x=(c=this.pointMap.get(u))==null?void 0:c.cds;if(f!=null&&f.length&&(x!=null&&x.length))if(r[l].type==="straightLadder"){let m=e;this.addLineItem(p,u,m,s)}else{let m=i;this.addLineItem(p,u,m,s)}}}}),this.escalatorMap.forEach((o,n)=>{if(o.start&&o.end){var r,h;let c=""+o.start.floor+bt+o.start.id,l=""+o.end.floor+bt+o.end.id,p=(r=this.pointMap.get(c))==null?void 0:r.cds,d=(h=this.pointMap.get(l))==null?void 0:h.cds;if(p!=null&&p.length&&(d!=null&&d.length)){let u=t;this.addLineItem(c,l,u,s)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Bt.default(t)}initEscalatorRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Bt.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Bt.default(t)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let i=this.nodeMap.get(""+t.floor+bt+t.nodeId);if(i){let[s,o]=i.split(bt);return{floor:s,id:o}}}if((e=t.coord)!=null&&e.length){let i=this.roadInfo.find(o=>o.floor===t.floor);if(!i)return null;let s=i.points.reduce((o,n)=>{let r=A(t.coord,n.cds);return r<o.min&&(o.min=r,o.point=n),o},{min:1/0,point:i.points[0]});return{floor:s.point.floor,id:s.point.id}}return null}transformEnd(t){if(t.floor){let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i){if(i===void 0&&(i=""),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let s=this.transformStart(t);if(!s)return"no-start";let o=this.transformEnd(e);if(!o)return"no-end";let n=this.getBasePath.bind(this);switch(i){case"escalator":n=this.getEscalatorPath.bind(this);break;case"straightLadder":n=this.getStraightLadderPath.bind(this);break;default:n=this.getBasePath.bind(this);break}if(o.id)return n(s,o);if(o.facility){let r=this.facilityMap.get(o.facility).filter(c=>o.floor?c.floor===o.floor:!0);if(!r.length)return null;let h=r.map(c=>n(s,{floor:c.floor,id:c.id})).filter(c=>!!c);return h.reduce((c,l)=>{let p=l.reduce((d,u)=>d+ft(u.points),0);return p<c.distance&&(c.distance=p,c.path=l),c},{distance:1/0,path:h[0]}).path}}getRoutePath(t,e,i){let s=""+t.floor+bt+t.id,o=""+e.floor+bt+e.id,n=i.path(s,o);if(!n)return null;let r=[];return n.map(h=>{let c=this.pointMap.get(h);if(c){var l;let{floor:p}=c;if(((l=r[r.length-1])==null?void 0:l.floor)===p){let d=r[r.length-1];d.points.push(c.cds),d.endType=c.type,d.destId=c.nodeId,d.distance=ft(d.points)}else r.push({floor:p,points:[c.cds],endType:c.type,destId:c.nodeId,distance:0})}}),r}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new Bt.default,this.escalatorRoute=new Bt.default,this.straightLadderRoute=new Bt.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.staircaseMap=new Map,this.lineMap=new Map,this.baseRoute=new Bt.default,this.escalatorRoute=new Bt.default,this.straightLadderRoute=new Bt.default}};var at=Ys(io(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{isNil as Ne}from"lodash";import{Vector2 as so}from"three";var Kg=function(a){return a.SunProof="sunProof",a.Rain="rain",a}({}),T="___",gh=1e4;function qt(a){let t=new Map;return a.forEach((e,i)=>{t.set(i,new Map(e))}),t}var we=class{setLiftPriority(t){this.lift_priority=t}isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp","connectionPoint"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let i=[];try{i=JSON.parse(e.entry_end_floor)}catch(o){i=[]}let s=[];try{s=JSON.parse(e.entry_start_floor)}catch(o){s=[]}return w({},e,{entry_start_floor:s,entry_end_floor:i})})}getParkingSpaceInfo(t,e){let i=""+t+T+e;var s;return(s=this.parkingMap.get(i))!=null?s:null}getNodeInfo(t,e){let i=""+t+T+e,s=this.nodeMap.get(i);if(!(s!=null&&s.length))return null;let o=this.pointMap.get(s[0]);return o!=null?o:null}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e);let i=new Date,s=i.getHours()*60+i.getMinutes();t.length&&(t.forEach(o=>{let n=(o.points||[]).filter(r=>!Ne(r.passWeight)&&r.passWeight!==1&&!Ne(r.coverageArea)&&r.coverageArea!==0);this.weightPointMap.set(o.floor,n),(o.points||[]).filter(r=>r.openStatus!==!1).filter(r=>{if(!r.startTime||!r.endTime)return!0;let[h,c]=r.startTime.split(":").map(f=>+f),[l,p]=r.endTime.split(":").map(f=>+f),d=h*60+c,u=l*60+p;return s>=d&&s<=u}).forEach(r=>{r.floor=o.floor;let h=""+o.floor+T+r.id,c=""+o.floor+T+r.nodeId,l=this.nodeMap.get(c)||[];if(l.push(""+o.floor+T+(r.relatedId||r.id)),this.nodeMap.set(""+o.floor+T+r.nodeId,l),this.pointMap.set(h,r),this.isFacilityByType(r.type)){let p=this.facilities.find(d=>d.id===+r.targetId);if(p){switch(p.entry_infra_type){case"straightLadder":if(p.entry_end_floor.find(m=>m.floor===o.floor)&&p.entry_start_floor.find(m=>m.floor===o.floor)){let m=this.straightLadderMap.get(r.targetId)||[];m.push(w({},r)),this.straightLadderMap.set(r.targetId,m)}break;case"staircase":if(p.entry_end_floor.find(m=>m.floor===o.floor)&&p.entry_start_floor.find(m=>m.floor===o.floor)){let m=this.staircaseMap.get(r.targetId)||[];m.push(w({},r)),this.staircaseMap.set(r.targetId,m)}break;case"escalator":let u=this.escalatorMap.get(r.targetId)||[];if(p.entry_start_floor.find(m=>m.floor===o.floor)){let m=u.find(y=>{var _;return((_=y.end)==null?void 0:_.floor)!==o.floor&&!y.start});m?m.start=r:u.push({start:r})}if(p.entry_end_floor.find(m=>m.floor===o.floor)){let m=u.find(y=>{var _;return((_=y.start)==null?void 0:_.floor)!==o.floor&&!y.end});m?m.end=r:u.push({end:r})}this.escalatorMap.set(r.targetId,u);break;case"ramp":let f=this.rampMap.get(r.targetId)||[];if(p.entry_start_floor.find(m=>m.floor===o.floor)){let m=f.find(y=>{var _;return((_=y.end)==null?void 0:_.floor)!==o.floor&&!y.start});m?m.start=r:f.push({start:r})}if(p.entry_end_floor.find(m=>m.floor===o.floor)){let m=f.find(y=>{var _;return((_=y.start)==null?void 0:_.floor)!==o.floor&&!y.end});m?m.end=r:f.push({end:r})}this.rampMap.set(r.targetId,f);break;case"connectionPoint":let x=this.connectionPointMap.get(r.targetId)||[];if(p.entry_start_floor.find(m=>m.floor===o.floor)){let m=x.find(y=>{var _;return((_=y.end)==null?void 0:_.floor)!==o.floor&&!y.start});m?m.start=r:x.push({start:r})}if(p.entry_end_floor.find(m=>m.floor===o.floor)){let m=x.find(y=>{var _;return((_=y.start)==null?void 0:_.floor)!==o.floor&&!y.end});m?m.end=r:x.push({end:r})}this.connectionPointMap.set(r.targetId,x);break}let d=this.facilityMap.get(r.targetId)||[];d.push(w({},r)),this.facilityMap.set(r.targetId,d)}}r.type==="parkingSpace"&&r.name.split(/[,,]/).forEach(d=>{this.parkingMap.set(""+o.floor+T+d,r)})}),(o.lines||[]).filter(r=>r.to!==r.from).forEach(r=>{let h=""+o.floor+T+r.from,c=""+o.floor+T+r.to,l=this.pointMap.get(h),p=this.pointMap.get(c);if(!l||!p)return;let d=l.cds,u=p.cds,f=A(d,u);if(!l.permission&&!p.permission){switch(r.direction){case"single-people":this.addLineItem(h,c,f);break;case"back-people":this.addLineItem(c,h,f);break;default:this.addLineItem(h,c,f),this.addLineItem(c,h,f)}switch(r.direction){case"double":this.addLineItem(h,c,f,this.forwardLineMap),this.addLineItem(c,h,f,this.forwardLineMap);break;case"single":this.addLineItem(h,c,f,this.forwardLineMap);break;case"back":this.addLineItem(c,h,f,this.forwardLineMap);break}(l.type==="parkingSpace"||p.type==="parkingSpace")&&r.direction==="noDir"&&(this.addLineItem(h,c,f,this.forwardLineMap),this.addLineItem(c,h,f,this.forwardLineMap))}else l.permission&&this.setPermissionLine(h,c,l.permission,f,"",r.direction),p.permission&&p.permission!==l.permission&&this.setPermissionLine(h,c,p.permission,f,"",r.direction)})}),this.addPermissionFacility(),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}getPermissionMap(t){return this["permission_"+t]||(this["permission_"+t]=new Set),this["permission_"+t]}setPermissionLine(t,e,i,s,o,n){this.getPermissionMap(i).add({fromKey:t,toKey:e,distance:s,type:o,direction:n})}addPermissionFacility(){this.straightLadderMap.forEach((t,e)=>{if(t.length<2){this.straightLadderMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"straightLadder"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"straightLadder")}}}}),this.staircaseMap.forEach((t,e)=>{if(t.length<2){this.staircaseMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"staircase"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"staircase")}}}}),this.escalatorMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"escalator"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"escalator"))}})}),this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,10,"ramp"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,10,"ramp"))}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"connectionPoint"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"connectionPoint"))}})})}addPermissionLineToMap(t,e,i,s){this.getPermissionMap(t).forEach(n=>{if(e.includes(n.type))if(n.type==="")switch(n.direction){case"single":this.addLineItem(n.fromKey,n.toKey,n.distance,i);break;case"back":this.addLineItem(n.toKey,n.fromKey,n.distance,i);break;case"single-people":this.addLineItem(n.fromKey,n.toKey,n.distance,i);break;case"back-people":this.addLineItem(n.toKey,n.fromKey,n.distance,i);break;default:this.addLineItem(n.fromKey,n.toKey,n.distance,i),this.addLineItem(n.toKey,n.fromKey,n.distance,i);break}else this.addLineItem(n.fromKey,n.toKey,s.get(n.type),i)})}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map,n=this.pointMap.get(t),r=this.pointMap.get(e);if(!n||!r)return;let h=this.weightPointMap.get(n.floor)||[],c=this.weightPointMap.get(r.floor)||[];h.forEach(l=>{l.id===n.id&&(i=i/l.passWeight),A(n.cds,l.cds)<=l.coverageArea&&(i=i/l.passWeight)}),c.forEach(l=>{l.id===r.id&&(i=i/l.passWeight),A(r.cds,l.cds)<=l.coverageArea&&(i=i/l.passWeight)}),o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let h=0;h<r.length;h++){let c=""+r[h].floor+T+r[h].id,l=this.pointMap.get(c);if(!(!l||l.permission)){for(let p=0;p<r.length;p++)if(h!==p){let d=""+r[p].floor+T+r[p].id,u=this.pointMap.get(d);if(!u||u.permission)continue;if(r[h].type==="straightLadder"){let f=e;this.addLineItem(c,d,f,s)}else{let f=i;this.addLineItem(c,d,f,s)}}}}}),this.escalatorMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);if(l&&p&&!l.permission&&!p.permission){let d=t;this.addLineItem(h,c,d,s)}}})}),this.connectionPointMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);l&&p&&!l.permission&&!p.permission&&this.addLineItem(h,c,100,s)}})})}initBaseRoute(){let t=new Map(qt(this.lineMap));this.addFacilityToLineMap(100,100*this.lift_priority,3e4,t),this.baseRoute=new at.default(t)}initEscalatorRoute(){let t=new Map(qt(this.lineMap)),e=1e4;this.addFacilityToLineMap(100,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new at.default(t)}initStraightLadderRoute(){let t=new Map(qt(this.lineMap)),e=1e4;this.addFacilityToLineMap(3*e,300,3e4*e,t),this.straightLadderRoute=new at.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,10,this.forwardLineMap)}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,100,this.forwardLineMap)}})}),this.forwardRoute=new at.default(this.forwardLineMap)}addNoProofWeight(t,e){let i=(s,o)=>{let n=t.get(s),r=n==null?void 0:n.get(o);n&&!Ne(r)&&n.set(o,r*gh)};this.roadInfo.forEach(s=>{(s.lines||[]).filter(o=>o.to!==o.from&&o[e]===!1).forEach(o=>{let n=""+s.floor+T+o.from,r=""+s.floor+T+o.to;switch(o.direction){case"single-people":i(n,r);break;case"back-people":i(r,n);break;default:i(n,r),i(r,n)}})})}getRouteByType(t){switch(t){case"escalator":return this.escalatorRoute;case"straightLadder":return this.straightLadderRoute;case"forward":return this.forwardRoute;default:return this.baseRoute}}getProofRoute(t,e,i){let s=""+t+T+e+T+i,o=this.proofRouteMap.get(s);if(o)return o;let n=new Map(qt(this.getRouteByType(t).graph));e&&this.addNoProofWeight(n,"sunProof"),i&&this.addNoProofWeight(n,"rain");let r=new at.default(n);return this.proofRouteMap.set(s,r),r}checkStart(t){return t.floor?t.parkingSpace?!0:!(!t.routePointId&&!t.nodeId&&(!t.coord||t.coord.length<2)):!1}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t,e,i){i===void 0&&(i={});var s;if(t.routePointId)return[{floor:t.floor,id:t.routePointId}];if(t.floor&&t.parkingSpace){let o=this.getParkingSpaceInfo(t.floor,t.parkingSpace);if(o)return[{floor:o.floor,id:o.id}]}if(t.nodeId){let o=this.nodeMap.get(""+t.floor+T+t.nodeId);if(o!=null&&o.length)return o.map(n=>{let[r,h]=n.split(T);return{floor:r,id:h}})}if((s=t.coord)!=null&&s.length){let o=this.roadInfo.find(c=>c.floor===t.floor);if(!o)return null;let n=o.points.filter(c=>c.isStarted),r=o.points.filter(c=>{let l=""+c.floor+T+c.id;if(e==="forward"){if(!this.forwardLineMap.has(l)||i.adsorptionIntersection&&n.length&&!c.isStarted)return!1}else if(!this.lineMap.has(l))return!1;return!0});if(!r.length)return null;let h=r.reduce((c,l)=>{if(l.relatedId)return c;let p=A(t.coord,l.cds);return p<c.min&&(c.min=p,c.point=l),c},{min:1/0,point:r[0]});return[{floor:o.floor,id:h.point.id}]}return null}transformEnd(t,e){if(t.routePointId&&t.floor)return[{floor:t.floor,id:t.routePointId}];if(t.floor){let i=this.transformStart(t,e);if(i)return i}if(t.facility){let s=this.facilities.filter(o=>+o.type_id==+t.facility).map(o=>o.id).map(o=>this.facilityMap.get(""+o)).flat(2);if(s!=null&&s.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i,s,o,n){if(i===void 0&&(i=""),n===void 0&&(n={}),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let r=this.transformStart(t,i,n);if(!r)return"no-start";let h=this.transformEnd(e,i);if(!h)return"no-end";let c=[];if(Array.isArray(h))for(let x=0;x<r.length;x++){let m=r[x];for(let y=0;y<h.length;y++){let _=h[y];if(m.floor===_.floor&&m.id===_.id)return"near"}}else{c=this.facilities.filter(m=>+m.type_id==+e.facility).map(m=>m.id).map(m=>this.facilityMap.get(""+m)).flat(2).filter(m=>m).filter(m=>h.floor?m.floor===h.floor:!0);for(let m=0;m<r.length;m++){let y=r[m];for(let _=0;_<c.length;_++){let P=c[_];if(y.floor===P.floor&&y.id===P.id)return"near"}}}let l=Array.isArray(n.proof)?n.proof:n.proof?[n.proof]:[],p=i!=="forward"&&l.includes("sunProof"),d=i!=="forward"&&l.includes("rain"),u;switch(i){case"escalator":u=(x,m,y)=>this.getEscalatorPath(x,m,y,p,d);break;case"straightLadder":u=(x,m,y)=>this.getStraightLadderPath(x,m,y,p,d);break;case"forward":u=this.getForwardPath.bind(this);break;default:u=(x,m,y)=>this.getBasePath(x,m,y,p,d);break}let f=null;return r.forEach(x=>{if(Array.isArray(h))h.forEach(m=>{let y=u(x,m,s,o);y&&y&&(!f||y[0].consume<f[0].consume)&&(f=y)});else{if(!c.length)return null;let m=c.map(y=>u(x,{floor:y.floor,id:y.id},s,o)).filter(y=>!!y);f=m.reduce((y,_)=>{let P=_[0].consume;return P<y.distance&&(y.distance=P,y.path=_),y},{distance:1/0,path:m[0]}).path}}),f}getRoutePath(t,e,i){let s=""+t.floor+T+t.id,o=this.pointMap.get(s),n=""+e.floor+T+e.id,r=this.pointMap.get(n);if(!o||!r)return null;let h=""+o.floor+T+(o.relatedId||o.id),c=""+r.floor+T+(r.relatedId||r.id),l=i.path(h,c);if(!l)return null;let p=[],d=l.reduce((u,f,x,m)=>{if(x===0)return 0;let y=m[x-1],_=i.graph.get(y).get(f);return u+_},0);return l.map(u=>{let f=this.pointMap.get(u);if(f){var x;let{floor:m}=f,y=f.type;if(this.isFacilityByType(f.type)){let _=this.facilities.find(P=>P.id===+f.targetId);_&&(y=_.entry_infra_type)}if(((x=p[p.length-1])==null?void 0:x.floor)===m){let _=p[p.length-1];_.points.push(f.cds),_.pointInfos.push(f),_.endType=y,_.destId=f.nodeId,_.distance=ft(_.points)}else p.push({floor:m,points:[f.cds],pointInfos:[f],endType:y,destId:f.nodeId,distance:0,consume:d})}}),p}getBasePath(t,e,i,s,o){s===void 0&&(s=!1),o===void 0&&(o=!1);let n=s||o?this.getProofRoute("",s,o):this.baseRoute;if(!i)return this.getRoutePath(t,e,n);let r=qt(n.graph),h=l=>{this.addPermissionLineToMap(l,["","escalator","staircase","straightLadder","connectionPoint"],r,new Map([["escalator",100],["connectionPoint",100],["straightLadder",100*this.lift_priority],["staircase",3e4]]))};Array.isArray(i)?i.forEach(l=>{h(l)}):h(i);let c=new at.default(r);return this.getRoutePath(t,e,c)}getEscalatorPath(t,e,i,s,o){s===void 0&&(s=!1),o===void 0&&(o=!1);let n=s||o?this.getProofRoute("escalator",s,o):this.escalatorRoute;if(!i)return this.getRoutePath(t,e,n);let r=qt(n.graph),h=1e4,c=p=>{this.addPermissionLineToMap(p,["","escalator","staircase","straightLadder","connectionPoint"],r,new Map([["escalator",100],["connectionPoint",100],["straightLadder",this.lift_priority*h],["staircase",3e4*h]]))};Array.isArray(i)?i.forEach(p=>{c(p)}):c(i);let l=new at.default(r);return this.getRoutePath(t,e,l)}getStraightLadderPath(t,e,i,s,o){s===void 0&&(s=!1),o===void 0&&(o=!1);let n=s||o?this.getProofRoute("straightLadder",s,o):this.straightLadderRoute;if(!i)return this.getRoutePath(t,e,n);let r=qt(n.graph),h=1e4,c=p=>{this.addPermissionLineToMap(p,["","escalator","staircase","straightLadder","connectionPoint"],r,new Map([["escalator",3*h],["connectionPoint",100],["straightLadder",300],["staircase",3e4*h]]))};Array.isArray(i)?i.forEach(p=>{c(p)}):c(i);let l=new at.default(r);return this.getRoutePath(t,e,l)}getSunProofPath(t,e,i,s,o,n){return i===void 0&&(i=""),n===void 0&&(n={}),this.getPath(t,e,i,s,o,w({},n,{proof:"sunProof"}))}getRainProofPath(t,e,i,s,o,n){return i===void 0&&(i=""),n===void 0&&(n={}),this.getPath(t,e,i,s,o,w({},n,{proof:"rain"}))}getForwardPath(t,e,i,s){let o=new Map,n=u=>{let f=this.forwardRoute.graph.get(h);u.forEach(x=>{let m=f.get(x);Ne(m)||(o.set(x,m),f.delete(x))})},r=()=>{let u=this.forwardRoute.graph.get(h);o.forEach((f,x)=>{u.set(x,f)})},h=""+t.floor+T+t.id;if(!Ne(s)){let u=this.forwardLineMap.get(h),f=this.pointMap.get(h);if(f&&(u!=null&&u.size)&&u.size>1){let x=new so(f.cds[0],f.cds[1]),m=new Map;u.forEach((_,P)=>{let S=this.pointMap.get(P);if(S){let E=new so(S.cds[0],S.cds[1]),b=360-(new so().subVectors(E,x).angle()/Math.PI*180-90+360)%360;m.set(P,b)}});let y=Array.from(m).filter(_=>{let[P,S]=_;return Math.abs(S-s)<=60}).map(_=>{let[P]=_;return P});if(y.length)y.forEach(_=>m.delete(_)),n([...m.keys()]);else{let _=Array.from(m).reduce((P,S)=>{let E=Math.abs(S[1]-s);return E<P.diff?{diff:E,key:S[0]}:P},{diff:1/0,key:""});m.delete(_.key),n([...m.keys()])}}}if(!i){let u=this.getRoutePath(t,e,this.forwardRoute);return r(),u||this.getRoutePath(t,e,this.forwardRoute)}let c=qt(this.forwardRoute.graph),l=u=>{this.addPermissionLineToMap(u,["","ramp"],c,new Map([["ramp",10]]))};Array.isArray(i)?i.forEach(u=>{l(u)}):l(i);let p=new at.default(c),d=this.getRoutePath(t,e,p);if(r(),d)return d;{let u=qt(this.forwardRoute.graph);Array.isArray(i)?i.forEach(m=>{l(m)}):l(i);let f=new at.default(u);return this.getRoutePath(t,e,f)}}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 at.default,this.escalatorRoute=new at.default,this.straightLadderRoute=new at.default,this.proofRouteMap.clear()}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.facilities=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.rampMap=new Map,this.staircaseMap=new Map,this.connectionPointMap=new Map,this.parkingMap=new Map,this.lineMap=new Map,this.weightPointMap=new Map,this.baseRoute=new at.default,this.escalatorRoute=new at.default,this.straightLadderRoute=new at.default,this.forwardLineMap=new Map,this.forwardRoute=new at.default,this.proofRouteMap=new Map}};import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var vt=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static registerKey(t){this.keySet.add(t)}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};vt.keySet=new Set;function H(a,t,e){return new Promise((i,s)=>{let o=vt.genUniqueKey(),n=r=>{let{data:h}=r;h.type===""+t+"_result"&&h.key===o&&(vt.removeKey(o),self.removeEventListener("message",n),h.error?s(h.error):i(h.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}function ry(a){let t={};for(let i in a)i.startsWith("on")&&(t[mn(i.slice(2))]=a[i],t[i]=a[i]);let e=i=>g(this,null,function*(){let{data:s}=i;if(t[s.type])try{let o=yield t[s.type](s.data);if(o!=null&&o.$transfer&&Array.isArray(o.$transfer)){let n=o.$transfer;delete o.$transfer,self.postMessage({type:""+s.type+"_result",key:s.key,data:o},n)}else self.postMessage({type:""+s.type+"_result",key:s.key,data:o})}catch(o){self.postMessage({type:""+s.type+"_result",key:s.key,error:o})}else self.postMessage({type:""+s.type+"_result",key:s.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}import{BoxGeometry as yh,BufferGeometry as vh,Line as xh,LineBasicMaterial as wh,Mesh as _h,MeshBasicMaterial as Ph}from"three";function ly(a,t){t===void 0&&(t=16711680);let e=new wh({color:t}),i=new vh().setFromPoints(a);return new xh(i,e)}function py(a,t){t===void 0&&(t=16711680);let e=new Ph({color:t,depthTest:!1,transparent:!0}),i=new yh(1,1,1),s=new _h(i,e);return s.position.copy(a),s.renderOrder=100100,s}import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.sort.js";function Pi(a,t,e){e===void 0&&(e=0),a.forEach(i=>{if(i.geometry.coords=JSON.parse(JSON.stringify(i.geometry.cds)),i.geometry.type==="polygon"){var s;i.geometry.coords.map(o=>{Array.isArray(o)&&o.forEach(n=>{n[0]-=t[0],n[1]-=t[1]})}),i.geometry.otherCds&&(i.geometry.otherCoords=i.geometry.otherCds.map(o=>o.map(n=>_e(n,t)))),(s=i.doors)!=null&&s.length&&i.doors.map(o=>{o.coord=_e(o.coordinate,t)}),i.center&&(i.centerCoords=_e(i.center,t))}else i.geometry.coords=_e(i.geometry.cds,t),i.center&&(i.centerCoords=_e(i.center,t));if(i.center_x&&i.center_y){let[o,n]=_e([i.center_x,i.center_y],t);i.center_coord_x=o,i.center_coord_y=n}}),Sh(a,e)}function _e(a,t){return[a[0]-t[0],a[1]-t[1]]}var Mh=.008,Nn=32;function bh(a){let t=a.geometry;if(!t)return null;if(t.type==="point"){let[r,h]=t.coords;return typeof r=="number"&&typeof h=="number"?[r,h,r,h]:null}let e=t.coords;if(!Array.isArray(e))return null;let i=1/0,s=1/0,o=-1/0,n=-1/0;return e.forEach(r=>{Array.isArray(r)&&r.forEach(h=>{let c=h==null?void 0:h[0],l=h==null?void 0:h[1];typeof c!="number"||typeof l!="number"||(c<i&&(i=c),c>o&&(o=c),l<s&&(s=l),l>n&&(n=l))})}),i===1/0?null:[i,s,o,n]}function Eh(a,t,e){let i=a.get(t);i||a.set(t,i=new Set),i.add(e);let s=a.get(e);s||a.set(e,s=new Set),s.add(t)}function Sh(a,t){t===void 0&&(t=0);let e=a.map(bh),i=new Map;for(let o=0;o<a.length;o++){if(!e[o])continue;a[o].deltaHeight=0;let r=(a[o].airHeight||0)+(a[o].height||0),h=i.get(r);h?h.push(o):i.set(r,[o])}let s=t>0?t%Nn:0;i.forEach(o=>{if(o.length<2)return;o.sort((c,l)=>e[c][0]-e[l][0]);let n=new Map;for(let c=0;c<o.length;c++){let l=e[o[c]];for(let p=c+1;p<o.length;p++){let d=e[o[p]];if(d[0]>l[2])break;l[3]<d[1]||d[3]<l[1]||Eh(n,c,p)}}let r=[...n.keys()].sort((c,l)=>n.get(l).size-n.get(c).size),h=new Map;r.forEach(c=>{let l=new Set;n.get(c).forEach(d=>{let u=h.get(d);u!==void 0&&l.add(u)});let p=0;for(;l.has(p);)p++;h.set(c,p)}),h.forEach((c,l)=>{a[o[l]].deltaHeight=Mh*((c+s)%Nn)})})}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import{Group as Ch}from"@tweenjs/tween.js";var ie=class{update(){this.group.update()}pause(){this.pauseTween=!0,this.getAll().forEach(t=>{this.tweenStore.add(t),t.pause()})}continue(){this.pauseTween&&(this.tweenStore.forEach(t=>{t.resume()}),this.tweenStore.clear(),this.pauseTween=!1)}remove(t){this.group.remove(t)}getAll(){return this.group.getAll()}clear(){this.getAll().forEach(t=>t.stop()),this.group.removeAll()}dispose(){this.clear()}constructor(){this.pauseTween=!1,this.tweenStore=new Set,this.group=new Ch}};import{EventDispatcher as Th}from"three";var Mi=class extends Th{registryEvent(){this.ctn.addEventListener("pointerdown",this._pointerDown),this.ctn.addEventListener("pointerup",this._pointerUp)}unRegistryEvent(){this.ctn.removeEventListener("pointerdown",this._pointerDown),this.ctn.removeEventListener("pointerup",this._pointerUp)}dispose(){this.unRegistryEvent()}constructor(t){super(),this.ctn=t,this._pointerDown=e=>{this.point={x:e.offsetX,y:e.offsetY}},this._pointerUp=e=>{if(!this.point)return;let{offsetX:i,offsetY:s}=e,{x:o,y:n}=this.point;Math.hypot(o-i+(n-s))>3||this.dispatchEvent({type:"click",e})},this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import{isNil as Lh}from"lodash";import{EventDispatcher as kh}from"three";var Pe=class extends kh{_isEffectiveTask(t){return t&&typeof t.run=="function"}_getIndexByTid(t){return this._task.findIndex(e=>e.tid===t)}_createTask(t){return this._isEffectiveTask(t)?w({},t,{tid:++this._id,meta:t.meta||{}}):!1}get task(){return[...this._task]}getTasks(){return[...this._task]}add(t){if(this._isEffectiveTask(t)){let e=this._createTask(t);return this._task.push(e),this.started&&!this.activeTask&&this.start(),e.tid}return!1}replace(t,e){if(!this._isEffectiveTask(e))return console.warn("[TaskQueue] replace\u65B9\u6CD5\u4F20\u5165\u7684task\u53C2\u6570\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;let i=this._getIndexByTid(t);if(i===-1)return console.warn("[TaskQueue] \u6CA1\u6709\u627E\u5230id="+t+"\u7684\u4EFB\u52A1"),!1;let s=this._createTask(e);return this._task.splice(i,1,s),s.tid}replaceByMetaType(t){var e;let i=(e=t.meta)==null?void 0:e.type;if(Lh(i))return this.add(t);{let s=this._task.find(o=>o.meta.type===i);return s?this.replace(s.tid,t):this.add(t)}}remove(t){let e=this._getIndexByTid(t);return e===-1?(console.warn("[TaskQueue] remove\u65B9\u6CD5\u4F20\u5165\u7684id\uFF1A"+t+"\u627E\u4E0D\u5230\u5BF9\u5E94\u7684task"),!1):(this._task.splice(e,1),!0)}clear(){this._task.length=0}start(){this.started=!0,!this.activeTask&&this._task.length&&this.exec()}stop(){this.started=!1}exec(){return g(this,null,function*(){if(!this.started||!this._task.length)return!1;let t=this._task.shift();this.activeTask=t,this.dispatchEvent({type:"active-task-start",task:t});let e;try{e=yield t.run()}catch(i){console.warn("[task run err]",i,t)}return this.activeTask=null,this.dispatchEvent({type:"active-task-end",task:t,res:e}),this.exec()})}constructor(t=!0){super(),this._task=[],this.started=!1,this.activeTask=null,this._id=0,t&&this.start()}};import"core-js/modules/es.array.push.js";import{EventDispatcher as Ah}from"three";var bi=class extends Ah{getWorker(){return new Promise(t=>{let e=this.pool.find(s=>s.state==="leisure");if(e){e.state="used",t(e.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let s=this.workerConstructor();this.pool.push({worker:s,state:"used"}),t(s);return}let i=()=>{let s=this.pool.find(o=>o.state==="leisure");s&&(this.removeEventListener("release",i),s.state="used",t(s.worker))};this.addEventListener("release",i)})}releaseWorker(t){let e=this.pool.find(i=>i.worker===t);e&&(e.state="leisure",this.dispatchEvent({type:"release",worker:t}))}dispose(){this._listeners={},this.pool.forEach(t=>{t.worker.terminate()}),this.pool=[]}constructor(t=10,e){super(),this.max=10,this.pool=[],this.max=t,this.workerConstructor=e}};import{EventDispatcher as Dh}from"three";var st=class extends Dh{dispose(){this._listeners={}}};var Ei=class{filter(t){let e=this.estimate,i=this.errorEstimate+this.processNoise,s=i/(i+this.measurementNoise);return this.estimate=e+s*(t-e),this.errorEstimate=(1-s)*i,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{BufferAttribute as Me,BufferGeometry as Rh,Color as oo,ExtrudeGeometry as Oh,Matrix4 as Fh,Quaternion as Ih,Vector3 as Ze}from"three";import{mergeGeometries as Gh}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{polygon as Bh,center as zh}from"@turf/turf";function _v(a,t,e){t===void 0&&(t=!0),e===void 0&&(e=!1);let i=a.filter(r=>r.geometry.type==="polygon");if(!i.length)return null;let s=i.map(r=>{var h;let c=r.geometry.coords,l=ui(c[0],c.slice(1)),p=new Oh(l,{steps:1,bevelEnabled:!1,depth:r.height,curveSegments:4});(h=r).deltaHeight||(h.deltaHeight=0),p.translate(0,0,r.airHeight+r.deltaHeight);let d=p.attributes.position.count;p.deleteAttribute("normal"),p.deleteAttribute("uv");let u=new Float32Array(d).fill(r.height+r.airHeight+r.deltaHeight);if(p.setAttribute("maxZ",new Me(u,1)),p.setAttribute("opacity",new Me(new Float32Array(d).fill(r.fillOpacity),1)),e){let m=new Float32Array(d).fill(r.airHeight+r.deltaHeight);p.setAttribute("minZ",new Me(m,1))}let f=new oo(r.fillColor).convertLinearToSRGB(),x=new Uint8Array(d*3);for(let m=0;m<d;m++)x[m*3]=Math.round(f.r*255),x[m*3+1]=Math.round(f.g*255),x[m*3+2]=Math.round(f.b*255);return p.setAttribute("color",new Me(x,3,!0)),p}),o=Gh(s);s.forEach(r=>r.dispose());let n={geometry:o};return o.dispose(),t&&(n.lineGeometry=Wh(i)||void 0),n}function Pv(a){let t=a.filter(h=>h.geometry.type==="polygon");if(!t.length)return null;let e=[],i=[],s=[],o=[],n=[],r=[];return t.map((h,c)=>{var l;(l=h).deltaHeight||(l.deltaHeight=0);let p=h.geometry.coords,d=A(p[0][0],p[0][1]),u=A(p[0][1],p[0][2]),f=p[0][1][0]-p[0][0][0],x=p[0][1][1]-p[0][0][1],m=Math.atan2(x,f),y=zh(Bh(p)),_=y.geometry.coordinates[0],P=y.geometry.coordinates[1],S=new Fh().compose(new Ze(_,P,h.deltaHeight+h.airHeight+h.height/2),new Ih().setFromAxisAngle(new Ze(0,0,1),m),new Ze(d,u,h.height));e.push(...S.toArray()),i.push(...new oo(h.fillColor).convertLinearToSRGB().toArray());var E;s[c]=(E=h.fillOpacity)!=null?E:1;var k;o[c]=((k=h.deltaHeight)!=null?k:0)+h.airHeight+h.height,n[c]=h.id,r[c]=h.airHeight+h.deltaHeight}),{size:t.length,ids:n,matrixes:e,colors:i,opacities:s,maxZs:o,minZs:r}}function Wh(a){let{points:t,colors:e,opacities:i}=no(a);if(!t.length)return null;let s=new Rh().setFromPoints(t),o=new Uint8Array(e.length);for(let n=0;n<e.length;n++)o[n]=Math.max(0,Math.min(255,Math.round(e[n]*255)));return s.setAttribute("color",new Me(o,3,!0)),s.setAttribute("opacity",new Me(new Float32Array(i),1)),s}function no(a){let t=[],e=[],i=[];return a.filter(s=>s.strokeOpacity>0).map(s=>{let o=s.height+(s.deltaHeight||0)+s.airHeight,{coords:n}=s.geometry,{strokeColor:r,strokeOpacity:h}=s,c=new oo(r).convertLinearToSRGB();for(let l=0;l<n.length;l++){let p=n[l];for(let d=0;d<p.length;d++){let u=p[d],f=d+1===p.length?p[0]:p[d+1];t.push(new Ze(u[0],u[1],o)),t.push(new Ze(f[0],f[1],o)),e.push(c.r,c.g,c.b),e.push(c.r,c.g,c.b),i.push(h),i.push(h)}}}),{points:t,colors:e,opacities:i}}function Mv(a){if(a.length>1)return!1;let t=a[0];if(t.length!==5)return!1;let[e]=t,i=t[t.length-1];if(e[0]!==i[0]||e[1]!==i[1])return!1;let s=[Math.round(A(t[0],t[1])),Math.round(A(t[1],t[2])),Math.round(A(t[2],t[3])),Math.round(A(t[3],t[4]))];if(!(s[2]===s[0]&&s[3]===s[1]))return!1;let o=ge(t[0],t[1],t[2]);return Math.abs(Math.abs(o)-90)<1}import{Vector3 as Uh}from"three";var Si=class{setBuildingCenter(t){this.buildingCenter=t}getBuildingCenter(){return this.buildingCenter}mercatorToWorld(t){return new Uh(t[0]-this.buildingCenter[0],t[1]-this.buildingCenter[1],0)}worldToMercator(t){return[t.x+this.buildingCenter[0],t.y+this.buildingCenter[1]]}constructor(t=[0,0]){this.buildingCenter=t}};import{EventDispatcher as ou,Box2 as nu,Vector3 as Dt,Vector2 as me,Raycaster as Vr,Box3 as ru,Color as au,AmbientLight as hu,Plane as cu}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{EventDispatcher as zd}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Object3D as Ec,ExtrudeGeometry as Sc,Mesh as Cc,Box3 as Oi,Vector3 as Et,BufferGeometry as Tc,LineSegments as Lc,Vector2 as $t,DoubleSide as kc,RepeatWrapping as fr}from"three";import"core-js/modules/web.dom-collections.iterator.js";import{LineMaterial as Hh}from"three/examples/jsm/lines/LineMaterial.js";import{Color as je,LineBasicMaterial as Nh,MeshStandardMaterial as Zh,MeshBasicMaterial as jh,ShaderMaterial as be,DoubleSide as Vh,LineDashedMaterial as Kh}from"three";function Zn(a){return a.x+"-"+a.y+"-"+a.z}var C=class{static generateLineMaterialKey(t){let{color:e,opacity:i}=t;return e+"-"+i}static createLineMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=this.generateLineMaterialKey({color:e,opacity:i,vertexColors:s});if(this.lineMaterialMap.has(o))return this.lineMaterialMap.get(o);let n=new Nh({color:new je(e).convertLinearToSRGB(),transparent:!0,opacity:i,vertexColors:s!=null?s:!1});return this.lineMaterialMap.set(o,n),n}static createMeshStandardMaterial(t){let{color:e,opacity:i}=t,s=e+"-"+i;if(this.meshStandardMaterialMap.has(s))return this.meshStandardMaterialMap.get(s);let o=new Zh({color:new je(e).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:i,depthWrite:!0});return this.meshStandardMaterialMap.set(s,o),o}static createMeshBasicMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=e+"-"+i+"-"+s;if(this.meshBasicMaterialMap.has(o))return this.meshBasicMaterialMap.get(o);let n=new jh({color:e,transparent:!0,opacity:i,depthWrite:!0,vertexColors:s!=null?s:!1});return this.meshBasicMaterialMap.set(o,n),n}static createShaderMaterial(t){let{gradualColor:e,opacity:i,max:s,min:o}=t,n=e.toString()+"-"+i+"-"+Zn(o)+"-"+Zn(s);if(this.shaderMaterialMap.has(n))return this.shaderMaterialMap.get(n);let r=`
1
+ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames,en=Object.getOwnPropertySymbols,Xa=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty,Ya=Object.prototype.propertyIsEnumerable;var Ks=(a,t,e)=>t in a?Xs(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,We=(a,t)=>{for(var e in t||(t={}))sn.call(t,e)&&Ks(a,e,t[e]);if(en)for(var e of en(t))Ya.call(t,e)&&Ks(a,e,t[e]);return a};var ne=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var qa=(a,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ka(t))!sn.call(a,s)&&s!==e&&Xs(a,s,{get:()=>t[s],enumerable:!(i=Va(t,s))||i.enumerable});return a};var Ys=(a,t,e)=>(e=a!=null?ja(Xa(a)):{},qa(t||!a||!a.__esModule?Xs(e,"default",{value:a,enumerable:!0}):e,a));var it=(a,t,e)=>Ks(a,typeof t!="symbol"?t+"":t,e);var g=(a,t,e)=>new Promise((i,s)=>{var o=h=>{try{r(e.next(h))}catch(c){s(c)}},n=h=>{try{r(e.throw(h))}catch(c){s(c)}},r=h=>h.done?i(h.value):Promise.resolve(h.value).then(o,n);r((e=e.apply(a,t)).next())});var xn=ne((dg,vn)=>{vn.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t}});var Pn=ne((ug,_n)=>{var wn=xn();_n.exports=function(a,t){Array.isArray(t)||(t=[]),a.length>0&&t.push(wn([0,0],a[0]));for(var e=0;e<a.length-1;e++){var i=a[e],s=a[e+1],o=i[0],n=i[1],r=s[0],h=s[1],c=[.75*o+.25*r,.75*n+.25*h],l=[.25*o+.75*r,.25*n+.75*h];t.push(c),t.push(l)}return a.length>1&&t.push(wn([0,0],a[a.length-1])),t}});var Ln=ne((wg,Tn)=>{var to=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((t,e)=>t.priority-e.priority)}set(t,e){let i=Number(e);if(isNaN(i))throw new TypeError('"priority" must be a number');return this.keys.has(t)?this.queue.map(s=>(s.key===t&&Object.assign(s,{priority:i}),s)):(this.keys.add(t),this.queue.push({key:t,priority:i})),this.sort(),this.queue.length}next(){let t=this.queue.shift();return this.keys.delete(t.key),t}isEmpty(){return this.queue.length===0}has(t){return this.keys.has(t)}get(t){return this.queue.find(e=>e.key===t)}};Tn.exports=to});var Dn=ne((_g,An)=>{function kn(a,t){let e=new Map;for(let[i,s]of a)i!==t&&s instanceof Map?e.set(i,kn(s,t)):i!==t&&e.set(i,s);return e}An.exports=kn});var Fn=ne((Pg,On)=>{function uh(a){let t=Number(a);return!(isNaN(t)||t<=0)}function Rn(a){let t=new Map;return Object.keys(a).forEach(i=>{let s=a[i];if(s!==null&&typeof s=="object"&&!Array.isArray(s))return t.set(i,Rn(s));if(!uh(s))throw new Error(`Could not add node at key "${i}", make sure it's a valid node`,s);return t.set(i,Number(s))}),t}On.exports=Rn});var Bn=ne((bg,Gn)=>{function In(a){if(!(a instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof a}`);a.forEach((t,e)=>{if(typeof t=="object"&&t instanceof Map){In(t);return}if(typeof t!="number"||t<=0)throw new Error(`Values must be numbers greater than 0. Found value ${t} at ${e}`)})}Gn.exports=In});var io=ne((Mg,Un)=>{var mh=Ln(),fh=Dn(),zn=Fn(),Wn=Bn(),eo=class{constructor(t){t instanceof Map?(Wn(t),this.graph=t):t?this.graph=zn(t):this.graph=new Map}addNode(t,e){let i;return e instanceof Map?(Wn(e),i=e):i=zn(e),this.graph.set(t,i),this}addVertex(t,e){return this.addNode(t,e)}removeNode(t){return this.graph=fh(this.graph,t),this}path(t,e,i={}){if(!this.graph.size)return i.cost?{path:null,cost:0}:null;let s=new Set,o=new mh,n=new Map,r=[],h=0,c=[];if(i.avoid&&(c=[].concat(i.avoid)),c.includes(t))throw new Error(`Starting node (${t}) cannot be avoided`);if(c.includes(e))throw new Error(`Ending node (${e}) cannot be avoided`);for(o.set(t,0);!o.isEmpty();){let l=o.next();if(l.key===e){h=l.priority;let d=l.key;for(;n.has(d);)r.push(d),d=n.get(d);break}s.add(l.key),(this.graph.get(l.key)||new Map).forEach((d,u)=>{if(s.has(u)||c.includes(u))return null;if(!o.has(u))return n.set(u,l.key),o.set(u,l.priority+d);let f=o.get(u).priority,x=l.priority+d;return x<f?(n.set(u,l.key),o.set(u,x)):null})}return r.length?(i.trim?r.shift():r=r.concat([t]),i.reverse||(r=r.reverse()),i.cost?{path:r,cost:h}:r):i.cost?{path:null,cost:0}:null}shortestPath(...t){return this.path(...t)}};Un.exports=eo});function w(){return w=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},w.apply(this,arguments)}import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.json.stringify.js";import{Box3 as ku,EventDispatcher as Au,Sprite as Do,Vector3 as Ro}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var K=class{requestAnimationFrame(t){let e=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(e),t()});return this.tasks.requestAnimation.add(e),e}cancelAnimationFrame(t){this.tasks.requestAnimation.delete(t),window.cancelAnimationFrame(t)}setTimeout(t,e){let i=window.setTimeout(()=>{this.tasks.timeout.delete(i),t()},e);return this.tasks.timeout.add(i),i}clearTimeout(t){this.tasks.timeout.delete(t),window.clearTimeout(t)}setInterval(t,e){let i=window.setInterval(()=>{t()},e);return this.tasks.interval.add(i),i}clearInterval(t){this.tasks.interval.delete(t),window.clearInterval(t)}requestIdleCallback(t,e){let i=window.requestIdleCallback(s=>{this.tasks.requestIdleCallback.delete(i),t(s)},e);return this.tasks.requestIdleCallback.add(i),i}cancelIdleCallback(t){this.tasks.requestIdleCallback.delete(t),window.cancelIdleCallback(t)}dispose(){this.tasks.requestAnimation.forEach(t=>{window.cancelAnimationFrame(t)}),this.tasks.requestAnimation.clear(),this.tasks.requestIdleCallback.forEach(t=>{window.cancelIdleCallback(t)}),this.tasks.requestIdleCallback.clear(),this.tasks.timeout.forEach(t=>{window.clearTimeout(t)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(t=>{window.clearInterval(t)}),this.tasks.interval.clear()}constructor(){this.tasks={requestAnimation:new Set,requestIdleCallback:new Set,timeout:new Set,interval:new Set}}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Shape as $a,Group as Ja,DirectionalLight as Qa,AmbientLight as th,Path as eh,Vector2 as on}from"three";function nn(){let a=new Ja,t=new th(16777215,.3);return a.add(t),a}function ui(a,t){t===void 0&&(t=[]);let e=new $a(a.map(i=>new on(...i)));return t.length&&t.forEach(i=>{var s=new eh(i.map(o=>new on(...o)));e.holes.push(s)}),e}function rn(a,t){a===void 0&&(a=16777215),t===void 0&&(t=1);let e=new Qa(a,t);return e.castShadow=!0,e.shadow.radius=8,e.shadow.bias=-.001,e.shadow.mapSize.set(256,256),e.shadow.camera.left=-200,e.shadow.camera.right=200,e.shadow.camera.top=200,e.shadow.camera.bottom=-200,e}function F(a,t){if(t&&a.children&&a.children.length&&a.children.forEach(e=>{F(e,t)}),a.isMesh){let e=a;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}a.isLight&&(a.dispose==null||a.dispose.call(a))}import"core-js/modules/es.regexp.exec.js";function an(a){return/[\u4E00-\u9FA5]+/g.test(a)}import"core-js/modules/web.dom-collections.iterator.js";import{Vector3 as fi,Vector2 as jt,Matrix3 as mi}from"three";import{point as ih,featureCollection as sh,center as oh}from"@turf/turf";function L(a,t,e,i){let s=a.clone().project(t),o=e/2,n=i/2,r=Math.round(s.x*o+o),h=Math.round(-s.y*n+n);return{x:r,y:h}}function yf(a,t,e,i,s){if(!s)return null;e=Math.min(1,e),i=Math.min(1,i);let o=a/e*2-1,n=1-t/i*2;return new fi(o,n,0).unproject(s)}function gi(a){let t=sh(a.map(i=>ih(i)));return oh(t).geometry.coordinates}function te(a,t,e){return a.x>=t.x&&a.x<=e.x&&a.y>=t.y&&a.y<=e.y}function vf(a){let t=0,e=new fi;for(let i=1;i<a.length;i++){let s=new fi(a[i-1][0],a[i-1][1],0),o=new fi(a[i][0],a[i][1],0),n=o.distanceTo(s);n>t&&(t=n,e=o.clone().sub(s).normalize())}return e}function A(a,t){return Math.sqrt((t[0]-a[0])**2+(t[1]-a[1])**2)}function ft(a){let t=0;for(let e=0;e<a.length-1;e++)t+=A(a[e],a[e+1]);return t}function ge(a,t,e){let i=new jt(t[0]-a[0],t[1]-a[1]),s=new jt(t[0]-e[0],t[1]-e[1]),n=i.angleTo(s)*180/Math.PI,r=new jt(t[0]-a[0],t[1]-a[1]);return new jt(e[0]-a[0],e[1]-a[1]).cross(r)>0?n:-n}function xf(a,t){let e=Math.min(A(a[0][0],a[0][1]),A(a[0][2],a[0][1]))-1;t||(t=gi(a[0]));let i=nh(t,e),s=new jt(a[0][0][0],a[0][0][1]),o=new jt(a[0][1][0],a[0][1][1]),n=new jt(a[0][2][0],a[0][2][1]),h=(s.distanceTo(o)>o.distanceTo(n)?o.clone().sub(s):n.clone().sub(o)).angleTo(new jt(0,1)),c=new mi;return c.multiply(new mi().translate(t[0],t[1])).multiply(new mi().rotate(h)).multiply(new mi().translate(-t[0],-t[1])),[i.map(l=>{let p=new jt(l[0],l[1]).applyMatrix3(c);return[p.x,p.y]})]}function nh(a,t){let e=t/2;return[[a[0]-e,a[1]+e],[a[0]+e,a[1]+e],[a[0]+e,a[1]-e],[a[0]-e,a[1]-e],[a[0]-e,a[1]+e]]}function Vt(a,t){let e=0,i=1/0,[s,o]=t;for(let n=0;n<a.length-1;n++){let[r,h]=a[n],[c,l]=a[n+1],p=Math.min(r,c)<=s&&s<=Math.max(r,c),d=Math.min(h,l)<=o&&o<=Math.max(h,l);if(p&&d){let u=Math.abs((c-r)*(o-h)-(l-h)*(s-r));u<i&&(i=u,e=n)}}return e}function hn(a,t){let e=a[0],i=a[1],s=!1;for(let o=0,n=t.length-1;o<t.length;n=o++){let r=t[o][0],h=t[o][1],c=t[n][0],l=t[n][1];h>i!=l>i&&e<(c-r)*(i-h)/(l-h)+r&&(s=!s)}return s}import"core-js/modules/es.reflect.to-string-tag.js";function ye(a,t){return new Proxy(a,{get:(e,i,s)=>Reflect.get(e,i,s),set:(e,i,s,o)=>{let n=Reflect.get(e,i,o),r=Reflect.set(e,i,s,o);return n!==s&&t.dispatchEvent({type:"change-"+i,value:s}),r}})}import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.error.cause.js";function bt(a,t){return Promise.race([a,new Promise((e,i)=>{setTimeout(()=>i(new Error("Promise timeout")),t)})])}function yi(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function cn(a,t){let e=yi("svg");return e.setAttribute("width",a),e.setAttribute("height",t),e.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",e}function Gt(a,t){a===void 0&&(a="2");let e=yi("circle");return e.setAttribute("r",a),e.setAttribute("fill",t),e}function Kt(a){let t=yi("line");return t.setAttribute("stroke",a),t}function gt(a,t){let e=yi("rect");return e.setAttribute("stroke",a),e.setAttribute("fill",t),e}function yt(a,t,e){a.setAttribute("cx",""+t),a.setAttribute("cy",""+e)}function rt(a,t,e){t&&(a.setAttribute("x1",""+t.x),a.setAttribute("y1",""+t.y)),e&&(a.setAttribute("x2",""+e.x),a.setAttribute("y2",""+e.y))}function j(a,t,e,i,s){a.setAttribute("x",""+t),a.setAttribute("y",""+e),a.setAttribute("width",""+i),a.setAttribute("height",""+s)}function ln(){return Promise.resolve()}function qs(){return new Promise(a=>{requestAnimationFrame(a)})}function pn(a){return a===void 0&&(a=1),new Promise(t=>{function e(){a<=0?t(!0):(a--,window.requestAnimationFrame(e))}window.requestAnimationFrame(e)})}import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.trim.js";function Af(a){return parseInt(a.replace("#","0x"),16)}function Df(a,t){let e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16),o=Math.round(e*t),n=Math.round(i*t),r=Math.round(s*t);return"#"+(1<<24|o<<16|n<<8|r).toString(16).slice(1)}function Xt(a,t){t===void 0&&(t=.85);let e,i,s;if(a.startsWith("#"))e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16);else{let n=a.slice(4,-1).split(",");e=parseInt(n[0].trim()),i=parseInt(n[1].trim()),s=parseInt(n[2].trim())}return e=Math.min(Math.floor(e*t),255),i=Math.min(Math.floor(i*t),255),s=Math.min(Math.floor(s*t),255),"#"+((1<<24)+(e<<16)+(i<<8)+s).toString(16).slice(1)}function Rf(a,t){a=a.replace(/^#/,"");let e=parseInt(a.substring(0,2),16),i=parseInt(a.substring(2,4),16),s=parseInt(a.substring(4,6),16);return t!==void 0?"rgba("+e+", "+i+", "+s+", "+t+")":"rgb("+e+", "+i+", "+s+")"}import"core-js/modules/es.regexp.exec.js";var re=navigator.userAgent.toUpperCase().indexOf("MAC")>=0,dn=(navigator.userAgent||"").toLocaleLowerCase(),ee=/ios|iphone/i.test(dn),If=/android|adr|linux/gi.test(dn),vi=ee||re&&navigator.maxTouchPoints>1;function ve(a){return re?a==="Meta":a==="Control"}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var $s="__once__",un=class{on(t,e){if(typeof e!="function")return;let i=this.events.get(t);return i?i.add(e):this.events.set(t,new Set([e]))}once(t,e){if(typeof e!="function")return;let i=""+$s+t,s=this.events.get(i);return s?s.add(e):this.events.set(i,new Set([e]))}off(t,e){let i=this.events.get(t),s=this.events.get(""+$s+t);!i&&!s||(e===void 0&&(i==null||i.clear(),s==null||s.clear()),i!=null&&i.has(e)&&i.delete(e),s!=null&&s.has(e)&&s.delete(e))}offAll(){this.events.clear()}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];let o=this.events.get(t),n=this.events.get(""+$s+t);!o&&!n||(o==null||o.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.clear())}constructor(){this.events=new Map}};var lt=function(a){return a.SWITCH_FLOOR_BEFORE="switch_floor_before",a.SWITCH_FLOOR_GROUND="switch_floor_ground",a.SWITCH_FLOOR_AFTER="switch_floor_after",a}({});import"core-js/modules/es.array.sort.js";function ae(a){return a?typeof a=="string"||typeof a=="number"||typeof a=="boolean"?a.toString():Object.keys(a).sort().map(t=>t+"="+ae(a[t])).join("&"):""}import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";import{BufferGeometry as rh,Float32BufferAttribute as gn}from"three";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";function mn(a){return a.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function fn(a){let t=[],e=/(\([^()]*\))|([^()]*)/g,i=0,s;for(;(s=e.exec(a))!==null;)s.index>i&&t.push(a.substring(i,s.index)),t.push(s[0]),i=s.index+s[0].length;return i<a.length&&t.push(a.substring(i)),t}var xi=28,ah=.88,hh=.12,ch=.125;function yn(a,t,e){if(/[\r\n]/.test(a)){let n=[];for(let r of a.split(/\r?\n/)){if(!r){n.push("");continue}n.push(...yn(r,t,e))}for(;n.length>1&&!n[n.length-1];)n.pop();return n}let i=fn(a),s=[],o="";for(let n of i)if(n.startsWith("(")||n.startsWith("\uFF08"))s.push(n.slice(1,-1));else{let r=n.split(" ");for(let h of r){let c=o?o+" "+h:h;if(e(c)>t)if(o&&s.push(o),e(h)>t||an(h)){let l="";for(let p of Array.from(h)){let d=l+p;e(d)>t&&l?(s.push(l),l=p):l=d}l&&(o=l)}else o=h;else o=c}}return o&&s.push(o),s}function wi(a,t,e,i){i===void 0&&(i=600);let s=W=>{var J;return(J=t.get(W))!=null?J:null},o=W=>{let J=0;for(let Q of Array.from(W)){var z,mt;J+=(mt=(z=s(Q))==null?void 0:z.glyphAdvance)!=null?mt:e.fontSize*.5}return J},n=e.fontSize/xi,r=Math.max(0,i*n),h=yn(a,r,o),c=h.length||1;var l;let p=(l=e.ascentRatio)!=null?l:ah;var d;let u=(d=e.descentRatio)!=null?d:hh;var f;let x=e.fontSize*(1+((f=e.lineGapRatio)!=null?f:ch)),m=e.fontSize*p,y=e.fontSize*u,_=e.buffer,P=(c-1)*x+m+y,S=h.map((W,J)=>{let z=Array.from(W),mt=z.map(D=>s(D)),Q=mt.reduce((D,V)=>{var Z;return D+((Z=V==null?void 0:V.glyphAdvance)!=null?Z:e.fontSize*.5)},0),I=P-(J*x+m);return{chars:z,records:mt,advance:Q,baselineY:I}}),k=S.reduce((W,J)=>Math.max(W,J.advance),0)||1,M=[],G=1/0,R=-1/0;S.forEach(W=>{let J=(k-W.advance)/2;W.chars.forEach((z,mt)=>{let Q=W.records[mt];if(Q&&!Q.blank&&Q.width>0&&Q.height>0){let D=W.baselineY+Q.glyphTop-Q.glyphHeight-_;M.push({char:z,record:Q,x:J+Q.glyphLeft-_,y:D}),G=Math.min(G,D+_),R=Math.max(R,D+_+Q.glyphHeight)}var I;J+=(I=Q==null?void 0:Q.glyphAdvance)!=null?I:e.fontSize*.5})});let O=Number.isFinite(G)&&Number.isFinite(R),$=O?G:0,nt=O?Math.max(R-$,1):P;return{lines:h,glyphs:M,width:k,height:P,aspect:k/P,linesCount:c,inkBottom:$,inkHeight:nt}}function Ue(a,t){t===void 0&&(t={});let{glyphs:e,width:i,height:s}=a,{pivotY:o=.5,pivotX:n=.5,normalizeBottom:r=0,normalizeHeight:h=s}=t;if(!e.length||s<=0||i<=0||h<=0)return[];let c=1/h,l=i*c,p=new Map;e.forEach(u=>{let{record:f}=u;var x;let m=(x=f.page)!=null?x:0,y=p.get(m);y||(y={positions:[],uvs:[],indices:[]},p.set(m,y));let _=u.x*c-l*n,P=(u.x+f.width)*c-l*n,S=(u.y-r)*c-o,E=(u.y+f.height-r)*c-o,{u0:k,u1:M,v0:G,v1:R}=f,O=y.positions.length/3;y.positions.push(_,S,0),y.uvs.push(k,R),y.positions.push(P,S,0),y.uvs.push(M,R),y.positions.push(P,E,0),y.uvs.push(M,G),y.positions.push(_,E,0),y.uvs.push(k,G),y.indices.push(O,O+1,O+2,O,O+2,O+3)});let d=[];return p.forEach((u,f)=>{if(!u.positions.length)return;let x=new rh;x.setAttribute("position",new gn(u.positions,3)),x.setAttribute("uv",new gn(u.uvs,2)),x.setIndex(u.indices),x.computeBoundingSphere(),d.push({page:f,geometry:x})}),d.sort((u,f)=>u.page-f.page),d}function lg(a,t){return new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",a,!0),Object.keys(t.headers||{}).forEach(o=>{s.setRequestHeader(o,t.headers[o])}),t.responseType&&(s.responseType=t.responseType),s.onload=()=>{if(s.status>=200&&s.status<300)if(t.responseType==="arraybuffer")e(s.response);else try{let o=JSON.parse(s.responseText);e(o)}catch(o){i(o)}else i(s.statusText)},s.onerror=()=>{i(s.statusText)},s.send()})}var bn=Ys(Pn(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Vector2 as He}from"three";function lh(a,t){let e=a.clone().normalize(),i=t.clone().normalize();return Math.acos(e.dot(i))}function ph(a){let t=0;return a.reduce((e,i)=>{let[s,o]=e,[n,r]=i;return t+=Math.sqrt((n-s)**2+(r-o)**2),[n,r]}),t/a.length}function Mn(a,t){if(t===void 0&&(t=.25),ph(a)<t)return a;let e=(0,bn.default)(a);return Mn(e,t)}function _i(a,t,e,i,s,o){t===void 0&&(t=!1),e===void 0&&(e=!0),i===void 0&&(i=5),s===void 0&&(s=150),o===void 0&&(o=3);let n=[],r=!t;if(n.push(a[0]),a.length<2)return n;for(let c=0;c<a.length-2;c+=1){let l=a[c],p=a[c+1],d=a[c+2],u=new He(l[0]-p[0],l[1]-p[1]),f=new He(d[0]-p[0],d[1]-p[1]),x=lh(u,f)/Math.PI*180,m=u.length()+f.length();(!r||x<s&&m>.01||m>i)&&(n.push(a[c+1]),r=!0)}if(n.push(a[a.length-1]),!e)return n;let h=[];h.push(n[0]);for(let c=0;c<n.length-2;c+=1){let l=new He(n[c][0],n[c][1]),p=new He(n[c+1][0],n[c+1][1]),d=new He(n[c+2][0],n[c+2][1]),u=l.distanceTo(p)/2,f=d.distanceTo(p)/2,x=p.clone(),m=p.clone();x.add(l.clone().sub(p).normalize().multiplyScalar(u>o?o/2:u)),m.add(d.clone().sub(p).normalize().multiplyScalar(f>o?o/2:f));let y=[[x.x,x.y],[p.x,p.y],[m.x,m.y]];h.push(...Mn(y,o/25))}return h.push(n[n.length-1]),dh(h)}function dh(a){if(a.length<=1)return a;let t=[],e;return a.forEach(i=>{let[s,o]=i;e?s===e[0]&&o===e[1]||(e=[s,o],t.push([s,o])):(e=[s,o],t.push([s,o]))}),t}function En(a,t,e){let i=Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2);if(i===0)return{distance:Math.sqrt((a[0]-t[0])**2+(a[1]-t[1])**2),closestPoint:t.slice(0)};let s=Math.max(0,Math.min(1,((a[0]-t[0])*(e[0]-t[0])+(a[1]-t[1])*(e[1]-t[1]))/i**2)),o=[t[0]+s*(e[0]-t[0]),t[1]+s*(e[1]-t[1])];return{distance:Math.sqrt((a[0]-o[0])**2+(a[1]-o[1])**2),closestPoint:o}}function vg(a,t,e){let[i,s]=a,[o,n]=t,r=Math.sqrt(Math.pow(o-i,2)+Math.pow(n-s,2));if(r===0||r<e)return[...t];let h=e/r,c=i+(o-i)*h,l=s+(n-s)*h;return[c,l]}var Yt=function(a){return 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}({});function Js(a,t,e){let i=ge(a,t,e);return Qs(i)}function Qs(a){return 180-Math.abs(a)<15?"front":a>135?"right_front":a<-135?"left_front":a<=135&&a>=60?"right":a>=-135&&a<=-60?"left":a<60&&a>0?"right_back":a>-60&&a<0?"left_back":"front"}function Sn(a){if(!a.length)return[];if(a.length===1)return[{direction:"start",distance:0,points:a}];let t=[{direction:"start",distance:A(a[0],a[1]),points:[a[0],a[1]]}];for(let e=2;e<a.length;e++){let i=Js(a[e-2],a[e-1],a[e]);if(i==="front"){let s=t[t.length-1],o=A(a[e-1],a[e]);s.distance+=o,e!==2&&s.points.push(a[e-1])}else t.push({direction:i,distance:A(a[e-1],a[e]),points:[a[e-1],a[e]]})}return t.push({direction:"end",distance:0,points:[a[a.length-1]]}),t}function Cn(a,t){if(a.length<2)return-1;let e=0;for(let i=1;i<a.length;i++){let s=a[i-1],o=a[i],n=[t[0]-s[0],t[1]-s[1]],r=[o[0]-s[0],o[1]-s[1]],h=Math.min(o[0],s[0])<=t[0]&&t[0]<=Math.max(o[0],s[0]),c=Math.min(o[1],s[1])<=t[1]&&t[1]<=Math.max(o[1],s[1]);if(h&&c){let l=n[0]*r[1]-n[1]*r[0];if(Math.abs(l)<1e-6){let p=Math.sqrt((t[0]-s[0])**2+(t[1]-s[1])**2);return e+p}}e+=Math.sqrt((o[0]-s[0])**2+(o[1]-s[1])**2)}return-1}function xe(a,t){if(a.length<2){var e;return(e=a[0])!=null?e:null}let i=0;for(let s=1;s<a.length;s++){let o=a[s-1],n=a[s],r=Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2);if(i+=r,i>=t){let h=(t-(i-r))/r,c=o[0]+(n[0]-o[0])*h,l=o[1]+(n[1]-o[1])*h;return[c,l]}}return null}var Bt=Ys(io(),1);import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";var Mt="___",Hn=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(i=>{let s=""+e.floor+Mt+i.id;if(this.pointMap.set(s,i),this.nodeMap.set(""+i.floor+Mt+i.nodeId,s),i.type==="straightLadder"){let o=this.straightLadderMap.get(i.name)||[];o.push(w({},i)),this.straightLadderMap.set(i.name,o)}if(i.type==="staircase"){let o=this.staircaseMap.get(i.name)||[];o.push(w({},i)),this.staircaseMap.set(i.name,o)}if(i.type==="escalator"){let o=this.escalatorMap.get(i.name)||{};i.escalatorDirection==="exit"?o.end={floor:i.floor,id:i.id}:o.start={floor:i.floor,id:i.id},this.escalatorMap.set(i.name,o)}if(i.type==="facility"){let o=this.facilityMap.get(i.targetId)||[];o.push(w({},i)),this.facilityMap.set(i.targetId,o)}}),e.lines.filter(i=>i.direction!=="no").forEach(i=>{var s,o;let n=""+e.floor+Mt+i.from,r=""+e.floor+Mt+i.to,h=(s=this.pointMap.get(n))==null?void 0:s.cds,c=(o=this.pointMap.get(r))==null?void 0:o.cds;if(h!=null&&h.length&&(c!=null&&c.length)){let l=A(h,c);this.addLineItem(n,r,l),i.direction==="double"&&this.addLineItem(r,n,l)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map;o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let l=0;l<r.length;l++){let p=""+r[l].floor+Mt+r[l].id;for(let d=0;d<r.length;d++)if(l!==d){var h,c;let u=""+r[d].floor+Mt+r[d].id,f=(h=this.pointMap.get(p))==null?void 0:h.cds,x=(c=this.pointMap.get(u))==null?void 0:c.cds;if(f!=null&&f.length&&(x!=null&&x.length))if(r[l].type==="straightLadder"){let m=e;this.addLineItem(p,u,m,s)}else{let m=i;this.addLineItem(p,u,m,s)}}}}),this.escalatorMap.forEach((o,n)=>{if(o.start&&o.end){var r,h;let c=""+o.start.floor+Mt+o.start.id,l=""+o.end.floor+Mt+o.end.id,p=(r=this.pointMap.get(c))==null?void 0:r.cds,d=(h=this.pointMap.get(l))==null?void 0:h.cds;if(p!=null&&p.length&&(d!=null&&d.length)){let u=t;this.addLineItem(c,l,u,s)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Bt.default(t)}initEscalatorRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Bt.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Bt.default(t)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let i=this.nodeMap.get(""+t.floor+Mt+t.nodeId);if(i){let[s,o]=i.split(Mt);return{floor:s,id:o}}}if((e=t.coord)!=null&&e.length){let i=this.roadInfo.find(o=>o.floor===t.floor);if(!i)return null;let s=i.points.reduce((o,n)=>{let r=A(t.coord,n.cds);return r<o.min&&(o.min=r,o.point=n),o},{min:1/0,point:i.points[0]});return{floor:s.point.floor,id:s.point.id}}return null}transformEnd(t){if(t.floor){let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i){if(i===void 0&&(i=""),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let s=this.transformStart(t);if(!s)return"no-start";let o=this.transformEnd(e);if(!o)return"no-end";let n=this.getBasePath.bind(this);switch(i){case"escalator":n=this.getEscalatorPath.bind(this);break;case"straightLadder":n=this.getStraightLadderPath.bind(this);break;default:n=this.getBasePath.bind(this);break}if(o.id)return n(s,o);if(o.facility){let r=this.facilityMap.get(o.facility).filter(c=>o.floor?c.floor===o.floor:!0);if(!r.length)return null;let h=r.map(c=>n(s,{floor:c.floor,id:c.id})).filter(c=>!!c);return h.reduce((c,l)=>{let p=l.reduce((d,u)=>d+ft(u.points),0);return p<c.distance&&(c.distance=p,c.path=l),c},{distance:1/0,path:h[0]}).path}}getRoutePath(t,e,i){let s=""+t.floor+Mt+t.id,o=""+e.floor+Mt+e.id,n=i.path(s,o);if(!n)return null;let r=[];return n.map(h=>{let c=this.pointMap.get(h);if(c){var l;let{floor:p}=c;if(((l=r[r.length-1])==null?void 0:l.floor)===p){let d=r[r.length-1];d.points.push(c.cds),d.endType=c.type,d.destId=c.nodeId,d.distance=ft(d.points)}else r.push({floor:p,points:[c.cds],endType:c.type,destId:c.nodeId,distance:0})}}),r}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new Bt.default,this.escalatorRoute=new Bt.default,this.straightLadderRoute=new Bt.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.staircaseMap=new Map,this.lineMap=new Map,this.baseRoute=new Bt.default,this.escalatorRoute=new Bt.default,this.straightLadderRoute=new Bt.default}};var at=Ys(io(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{isNil as Ne}from"lodash";import{Vector2 as so}from"three";var Kg=function(a){return a.SunProof="sunProof",a.Rain="rain",a}({}),T="___",gh=1e4;function qt(a){let t=new Map;return a.forEach((e,i)=>{t.set(i,new Map(e))}),t}var we=class{setLiftPriority(t){this.lift_priority=t}isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp","connectionPoint"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let i=[];try{i=JSON.parse(e.entry_end_floor)}catch(o){i=[]}let s=[];try{s=JSON.parse(e.entry_start_floor)}catch(o){s=[]}return w({},e,{entry_start_floor:s,entry_end_floor:i})})}getParkingSpaceInfo(t,e){let i=""+t+T+e;var s;return(s=this.parkingMap.get(i))!=null?s:null}getNodeInfo(t,e){let i=""+t+T+e,s=this.nodeMap.get(i);if(!(s!=null&&s.length))return null;let o=this.pointMap.get(s[0]);return o!=null?o:null}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e);let i=new Date,s=i.getHours()*60+i.getMinutes();t.length&&(t.forEach(o=>{let n=(o.points||[]).filter(r=>!Ne(r.passWeight)&&r.passWeight!==1&&!Ne(r.coverageArea)&&r.coverageArea!==0);this.weightPointMap.set(o.floor,n),(o.points||[]).filter(r=>r.openStatus!==!1).filter(r=>{if(!r.startTime||!r.endTime)return!0;let[h,c]=r.startTime.split(":").map(f=>+f),[l,p]=r.endTime.split(":").map(f=>+f),d=h*60+c,u=l*60+p;return s>=d&&s<=u}).forEach(r=>{r.floor=o.floor;let h=""+o.floor+T+r.id,c=""+o.floor+T+r.nodeId,l=this.nodeMap.get(c)||[];if(l.push(""+o.floor+T+(r.relatedId||r.id)),this.nodeMap.set(""+o.floor+T+r.nodeId,l),this.pointMap.set(h,r),this.isFacilityByType(r.type)){let p=this.facilities.find(d=>d.id===+r.targetId);if(p){switch(p.entry_infra_type){case"straightLadder":if(p.entry_end_floor.find(m=>m.floor===o.floor)&&p.entry_start_floor.find(m=>m.floor===o.floor)){let m=this.straightLadderMap.get(r.targetId)||[];m.push(w({},r)),this.straightLadderMap.set(r.targetId,m)}break;case"staircase":if(p.entry_end_floor.find(m=>m.floor===o.floor)&&p.entry_start_floor.find(m=>m.floor===o.floor)){let m=this.staircaseMap.get(r.targetId)||[];m.push(w({},r)),this.staircaseMap.set(r.targetId,m)}break;case"escalator":let u=this.escalatorMap.get(r.targetId)||[];if(p.entry_start_floor.find(m=>m.floor===o.floor)){let m=u.find(y=>{var _;return((_=y.end)==null?void 0:_.floor)!==o.floor&&!y.start});m?m.start=r:u.push({start:r})}if(p.entry_end_floor.find(m=>m.floor===o.floor)){let m=u.find(y=>{var _;return((_=y.start)==null?void 0:_.floor)!==o.floor&&!y.end});m?m.end=r:u.push({end:r})}this.escalatorMap.set(r.targetId,u);break;case"ramp":let f=this.rampMap.get(r.targetId)||[];if(p.entry_start_floor.find(m=>m.floor===o.floor)){let m=f.find(y=>{var _;return((_=y.end)==null?void 0:_.floor)!==o.floor&&!y.start});m?m.start=r:f.push({start:r})}if(p.entry_end_floor.find(m=>m.floor===o.floor)){let m=f.find(y=>{var _;return((_=y.start)==null?void 0:_.floor)!==o.floor&&!y.end});m?m.end=r:f.push({end:r})}this.rampMap.set(r.targetId,f);break;case"connectionPoint":let x=this.connectionPointMap.get(r.targetId)||[];if(p.entry_start_floor.find(m=>m.floor===o.floor)){let m=x.find(y=>{var _;return((_=y.end)==null?void 0:_.floor)!==o.floor&&!y.start});m?m.start=r:x.push({start:r})}if(p.entry_end_floor.find(m=>m.floor===o.floor)){let m=x.find(y=>{var _;return((_=y.start)==null?void 0:_.floor)!==o.floor&&!y.end});m?m.end=r:x.push({end:r})}this.connectionPointMap.set(r.targetId,x);break}let d=this.facilityMap.get(r.targetId)||[];d.push(w({},r)),this.facilityMap.set(r.targetId,d)}}r.type==="parkingSpace"&&r.name.split(/[,,]/).forEach(d=>{this.parkingMap.set(""+o.floor+T+d,r)})}),(o.lines||[]).filter(r=>r.to!==r.from).forEach(r=>{let h=""+o.floor+T+r.from,c=""+o.floor+T+r.to,l=this.pointMap.get(h),p=this.pointMap.get(c);if(!l||!p)return;let d=l.cds,u=p.cds,f=A(d,u);if(!l.permission&&!p.permission){switch(r.direction){case"single-people":this.addLineItem(h,c,f);break;case"back-people":this.addLineItem(c,h,f);break;default:this.addLineItem(h,c,f),this.addLineItem(c,h,f)}switch(r.direction){case"double":this.addLineItem(h,c,f,this.forwardLineMap),this.addLineItem(c,h,f,this.forwardLineMap);break;case"single":this.addLineItem(h,c,f,this.forwardLineMap);break;case"back":this.addLineItem(c,h,f,this.forwardLineMap);break}(l.type==="parkingSpace"||p.type==="parkingSpace")&&r.direction==="noDir"&&(this.addLineItem(h,c,f,this.forwardLineMap),this.addLineItem(c,h,f,this.forwardLineMap))}else l.permission&&this.setPermissionLine(h,c,l.permission,f,"",r.direction),p.permission&&p.permission!==l.permission&&this.setPermissionLine(h,c,p.permission,f,"",r.direction)})}),this.addPermissionFacility(),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}getPermissionMap(t){return this["permission_"+t]||(this["permission_"+t]=new Set),this["permission_"+t]}setPermissionLine(t,e,i,s,o,n){this.getPermissionMap(i).add({fromKey:t,toKey:e,distance:s,type:o,direction:n})}addPermissionFacility(){this.straightLadderMap.forEach((t,e)=>{if(t.length<2){this.straightLadderMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"straightLadder"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"straightLadder")}}}}),this.staircaseMap.forEach((t,e)=>{if(t.length<2){this.staircaseMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"staircase"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"staircase")}}}}),this.escalatorMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"escalator"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"escalator"))}})}),this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,10,"ramp"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,10,"ramp"))}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"connectionPoint"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"connectionPoint"))}})})}addPermissionLineToMap(t,e,i,s){this.getPermissionMap(t).forEach(n=>{if(e.includes(n.type))if(n.type==="")switch(n.direction){case"single":this.addLineItem(n.fromKey,n.toKey,n.distance,i);break;case"back":this.addLineItem(n.toKey,n.fromKey,n.distance,i);break;case"single-people":this.addLineItem(n.fromKey,n.toKey,n.distance,i);break;case"back-people":this.addLineItem(n.toKey,n.fromKey,n.distance,i);break;default:this.addLineItem(n.fromKey,n.toKey,n.distance,i),this.addLineItem(n.toKey,n.fromKey,n.distance,i);break}else this.addLineItem(n.fromKey,n.toKey,s.get(n.type),i)})}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map,n=this.pointMap.get(t),r=this.pointMap.get(e);if(!n||!r)return;let h=this.weightPointMap.get(n.floor)||[],c=this.weightPointMap.get(r.floor)||[];h.forEach(l=>{l.id===n.id&&(i=i/l.passWeight),A(n.cds,l.cds)<=l.coverageArea&&(i=i/l.passWeight)}),c.forEach(l=>{l.id===r.id&&(i=i/l.passWeight),A(r.cds,l.cds)<=l.coverageArea&&(i=i/l.passWeight)}),o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let h=0;h<r.length;h++){let c=""+r[h].floor+T+r[h].id,l=this.pointMap.get(c);if(!(!l||l.permission)){for(let p=0;p<r.length;p++)if(h!==p){let d=""+r[p].floor+T+r[p].id,u=this.pointMap.get(d);if(!u||u.permission)continue;if(r[h].type==="straightLadder"){let f=e;this.addLineItem(c,d,f,s)}else{let f=i;this.addLineItem(c,d,f,s)}}}}}),this.escalatorMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);if(l&&p&&!l.permission&&!p.permission){let d=t;this.addLineItem(h,c,d,s)}}})}),this.connectionPointMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);l&&p&&!l.permission&&!p.permission&&this.addLineItem(h,c,100,s)}})})}initBaseRoute(){let t=new Map(qt(this.lineMap));this.addFacilityToLineMap(100,100*this.lift_priority,3e4,t),this.baseRoute=new at.default(t)}initEscalatorRoute(){let t=new Map(qt(this.lineMap)),e=1e4;this.addFacilityToLineMap(100,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new at.default(t)}initStraightLadderRoute(){let t=new Map(qt(this.lineMap)),e=1e4;this.addFacilityToLineMap(3*e,300,3e4*e,t),this.straightLadderRoute=new at.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,10,this.forwardLineMap)}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,100,this.forwardLineMap)}})}),this.forwardRoute=new at.default(this.forwardLineMap)}addNoProofWeight(t,e){let i=(s,o)=>{let n=t.get(s),r=n==null?void 0:n.get(o);n&&!Ne(r)&&n.set(o,r*gh)};this.roadInfo.forEach(s=>{(s.lines||[]).filter(o=>o.to!==o.from&&o[e]===!1).forEach(o=>{let n=""+s.floor+T+o.from,r=""+s.floor+T+o.to;switch(o.direction){case"single-people":i(n,r);break;case"back-people":i(r,n);break;default:i(n,r),i(r,n)}})})}getRouteByType(t){switch(t){case"escalator":return this.escalatorRoute;case"straightLadder":return this.straightLadderRoute;case"forward":return this.forwardRoute;default:return this.baseRoute}}getProofRoute(t,e,i){let s=""+t+T+e+T+i,o=this.proofRouteMap.get(s);if(o)return o;let n=new Map(qt(this.getRouteByType(t).graph));e&&this.addNoProofWeight(n,"sunProof"),i&&this.addNoProofWeight(n,"rain");let r=new at.default(n);return this.proofRouteMap.set(s,r),r}checkStart(t){return t.floor?t.parkingSpace?!0:!(!t.routePointId&&!t.nodeId&&(!t.coord||t.coord.length<2)):!1}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t,e,i){i===void 0&&(i={});var s;if(t.routePointId)return[{floor:t.floor,id:t.routePointId}];if(t.floor&&t.parkingSpace){let o=this.getParkingSpaceInfo(t.floor,t.parkingSpace);if(o)return[{floor:o.floor,id:o.id}]}if(t.nodeId){let o=this.nodeMap.get(""+t.floor+T+t.nodeId);if(o!=null&&o.length)return o.map(n=>{let[r,h]=n.split(T);return{floor:r,id:h}})}if((s=t.coord)!=null&&s.length){let o=this.roadInfo.find(c=>c.floor===t.floor);if(!o)return null;let n=o.points.filter(c=>c.isStarted),r=o.points.filter(c=>{let l=""+c.floor+T+c.id;if(e==="forward"){if(!this.forwardLineMap.has(l)||i.adsorptionIntersection&&n.length&&!c.isStarted)return!1}else if(!this.lineMap.has(l))return!1;return!0});if(!r.length)return null;let h=r.reduce((c,l)=>{if(l.relatedId)return c;let p=A(t.coord,l.cds);return p<c.min&&(c.min=p,c.point=l),c},{min:1/0,point:r[0]});return[{floor:o.floor,id:h.point.id}]}return null}transformEnd(t,e){if(t.routePointId&&t.floor)return[{floor:t.floor,id:t.routePointId}];if(t.floor){let i=this.transformStart(t,e);if(i)return i}if(t.facility){let s=this.facilities.filter(o=>+o.type_id==+t.facility).map(o=>o.id).map(o=>this.facilityMap.get(""+o)).flat(2);if(s!=null&&s.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i,s,o,n){if(i===void 0&&(i=""),n===void 0&&(n={}),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let r=this.transformStart(t,i,n);if(!r)return"no-start";let h=this.transformEnd(e,i);if(!h)return"no-end";let c=[];if(Array.isArray(h))for(let x=0;x<r.length;x++){let m=r[x];for(let y=0;y<h.length;y++){let _=h[y];if(m.floor===_.floor&&m.id===_.id)return"near"}}else{c=this.facilities.filter(m=>+m.type_id==+e.facility).map(m=>m.id).map(m=>this.facilityMap.get(""+m)).flat(2).filter(m=>m).filter(m=>h.floor?m.floor===h.floor:!0);for(let m=0;m<r.length;m++){let y=r[m];for(let _=0;_<c.length;_++){let P=c[_];if(y.floor===P.floor&&y.id===P.id)return"near"}}}let l=Array.isArray(n.proof)?n.proof:n.proof?[n.proof]:[],p=i!=="forward"&&l.includes("sunProof"),d=i!=="forward"&&l.includes("rain"),u;switch(i){case"escalator":u=(x,m,y)=>this.getEscalatorPath(x,m,y,p,d);break;case"straightLadder":u=(x,m,y)=>this.getStraightLadderPath(x,m,y,p,d);break;case"forward":u=this.getForwardPath.bind(this);break;default:u=(x,m,y)=>this.getBasePath(x,m,y,p,d);break}let f=null;return r.forEach(x=>{if(Array.isArray(h))h.forEach(m=>{let y=u(x,m,s,o);y&&y&&(!f||y[0].consume<f[0].consume)&&(f=y)});else{if(!c.length)return null;let m=c.map(y=>u(x,{floor:y.floor,id:y.id},s,o)).filter(y=>!!y);f=m.reduce((y,_)=>{let P=_[0].consume;return P<y.distance&&(y.distance=P,y.path=_),y},{distance:1/0,path:m[0]}).path}}),f}getRoutePath(t,e,i){let s=""+t.floor+T+t.id,o=this.pointMap.get(s),n=""+e.floor+T+e.id,r=this.pointMap.get(n);if(!o||!r)return null;let h=""+o.floor+T+(o.relatedId||o.id),c=""+r.floor+T+(r.relatedId||r.id),l=i.path(h,c);if(!l)return null;let p=[],d=l.reduce((u,f,x,m)=>{if(x===0)return 0;let y=m[x-1],_=i.graph.get(y).get(f);return u+_},0);return l.map(u=>{let f=this.pointMap.get(u);if(f){var x;let{floor:m}=f,y=f.type;if(this.isFacilityByType(f.type)){let _=this.facilities.find(P=>P.id===+f.targetId);_&&(y=_.entry_infra_type)}if(((x=p[p.length-1])==null?void 0:x.floor)===m){let _=p[p.length-1];_.points.push(f.cds),_.pointInfos.push(f),_.endType=y,_.destId=f.nodeId,_.distance=ft(_.points)}else p.push({floor:m,points:[f.cds],pointInfos:[f],endType:y,destId:f.nodeId,distance:0,consume:d})}}),p}getBasePath(t,e,i,s,o){s===void 0&&(s=!1),o===void 0&&(o=!1);let n=s||o?this.getProofRoute("",s,o):this.baseRoute;if(!i)return this.getRoutePath(t,e,n);let r=qt(n.graph),h=l=>{this.addPermissionLineToMap(l,["","escalator","staircase","straightLadder","connectionPoint"],r,new Map([["escalator",100],["connectionPoint",100],["straightLadder",100*this.lift_priority],["staircase",3e4]]))};Array.isArray(i)?i.forEach(l=>{h(l)}):h(i);let c=new at.default(r);return this.getRoutePath(t,e,c)}getEscalatorPath(t,e,i,s,o){s===void 0&&(s=!1),o===void 0&&(o=!1);let n=s||o?this.getProofRoute("escalator",s,o):this.escalatorRoute;if(!i)return this.getRoutePath(t,e,n);let r=qt(n.graph),h=1e4,c=p=>{this.addPermissionLineToMap(p,["","escalator","staircase","straightLadder","connectionPoint"],r,new Map([["escalator",100],["connectionPoint",100],["straightLadder",this.lift_priority*h],["staircase",3e4*h]]))};Array.isArray(i)?i.forEach(p=>{c(p)}):c(i);let l=new at.default(r);return this.getRoutePath(t,e,l)}getStraightLadderPath(t,e,i,s,o){s===void 0&&(s=!1),o===void 0&&(o=!1);let n=s||o?this.getProofRoute("straightLadder",s,o):this.straightLadderRoute;if(!i)return this.getRoutePath(t,e,n);let r=qt(n.graph),h=1e4,c=p=>{this.addPermissionLineToMap(p,["","escalator","staircase","straightLadder","connectionPoint"],r,new Map([["escalator",3*h],["connectionPoint",100],["straightLadder",300],["staircase",3e4*h]]))};Array.isArray(i)?i.forEach(p=>{c(p)}):c(i);let l=new at.default(r);return this.getRoutePath(t,e,l)}getSunProofPath(t,e,i,s,o,n){return i===void 0&&(i=""),n===void 0&&(n={}),this.getPath(t,e,i,s,o,w({},n,{proof:"sunProof"}))}getRainProofPath(t,e,i,s,o,n){return i===void 0&&(i=""),n===void 0&&(n={}),this.getPath(t,e,i,s,o,w({},n,{proof:"rain"}))}getForwardPath(t,e,i,s){let o=new Map,n=u=>{let f=this.forwardRoute.graph.get(h);u.forEach(x=>{let m=f.get(x);Ne(m)||(o.set(x,m),f.delete(x))})},r=()=>{let u=this.forwardRoute.graph.get(h);o.forEach((f,x)=>{u.set(x,f)})},h=""+t.floor+T+t.id;if(!Ne(s)){let u=this.forwardLineMap.get(h),f=this.pointMap.get(h);if(f&&(u!=null&&u.size)&&u.size>1){let x=new so(f.cds[0],f.cds[1]),m=new Map;u.forEach((_,P)=>{let S=this.pointMap.get(P);if(S){let E=new so(S.cds[0],S.cds[1]),M=360-(new so().subVectors(E,x).angle()/Math.PI*180-90+360)%360;m.set(P,M)}});let y=Array.from(m).filter(_=>{let[P,S]=_;return Math.abs(S-s)<=60}).map(_=>{let[P]=_;return P});if(y.length)y.forEach(_=>m.delete(_)),n([...m.keys()]);else{let _=Array.from(m).reduce((P,S)=>{let E=Math.abs(S[1]-s);return E<P.diff?{diff:E,key:S[0]}:P},{diff:1/0,key:""});m.delete(_.key),n([...m.keys()])}}}if(!i){let u=this.getRoutePath(t,e,this.forwardRoute);return r(),u||this.getRoutePath(t,e,this.forwardRoute)}let c=qt(this.forwardRoute.graph),l=u=>{this.addPermissionLineToMap(u,["","ramp"],c,new Map([["ramp",10]]))};Array.isArray(i)?i.forEach(u=>{l(u)}):l(i);let p=new at.default(c),d=this.getRoutePath(t,e,p);if(r(),d)return d;{let u=qt(this.forwardRoute.graph);Array.isArray(i)?i.forEach(m=>{l(m)}):l(i);let f=new at.default(u);return this.getRoutePath(t,e,f)}}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 at.default,this.escalatorRoute=new at.default,this.straightLadderRoute=new at.default,this.proofRouteMap.clear()}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.facilities=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.rampMap=new Map,this.staircaseMap=new Map,this.connectionPointMap=new Map,this.parkingMap=new Map,this.lineMap=new Map,this.weightPointMap=new Map,this.baseRoute=new at.default,this.escalatorRoute=new at.default,this.straightLadderRoute=new at.default,this.forwardLineMap=new Map,this.forwardRoute=new at.default,this.proofRouteMap=new Map}};import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var vt=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static registerKey(t){this.keySet.add(t)}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};vt.keySet=new Set;function H(a,t,e){return new Promise((i,s)=>{let o=vt.genUniqueKey(),n=r=>{let{data:h}=r;h.type===""+t+"_result"&&h.key===o&&(vt.removeKey(o),self.removeEventListener("message",n),h.error?s(h.error):i(h.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}function ry(a){let t={};for(let i in a)i.startsWith("on")&&(t[mn(i.slice(2))]=a[i],t[i]=a[i]);let e=i=>g(this,null,function*(){let{data:s}=i;if(t[s.type])try{let o=yield t[s.type](s.data);if(o!=null&&o.$transfer&&Array.isArray(o.$transfer)){let n=o.$transfer;delete o.$transfer,self.postMessage({type:""+s.type+"_result",key:s.key,data:o},n)}else self.postMessage({type:""+s.type+"_result",key:s.key,data:o})}catch(o){self.postMessage({type:""+s.type+"_result",key:s.key,error:o})}else self.postMessage({type:""+s.type+"_result",key:s.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}import{BoxGeometry as yh,BufferGeometry as vh,Line as xh,LineBasicMaterial as wh,Mesh as _h,MeshBasicMaterial as Ph}from"three";function ly(a,t){t===void 0&&(t=16711680);let e=new wh({color:t}),i=new vh().setFromPoints(a);return new xh(i,e)}function py(a,t){t===void 0&&(t=16711680);let e=new Ph({color:t,depthTest:!1,transparent:!0}),i=new yh(1,1,1),s=new _h(i,e);return s.position.copy(a),s.renderOrder=100100,s}import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.sort.js";function Pi(a,t,e){e===void 0&&(e=0),a.forEach(i=>{if(i.geometry.coords=JSON.parse(JSON.stringify(i.geometry.cds)),i.geometry.type==="polygon"){var s;i.geometry.coords.map(o=>{Array.isArray(o)&&o.forEach(n=>{n[0]-=t[0],n[1]-=t[1]})}),i.geometry.otherCds&&(i.geometry.otherCoords=i.geometry.otherCds.map(o=>o.map(n=>_e(n,t)))),(s=i.doors)!=null&&s.length&&i.doors.map(o=>{o.coord=_e(o.coordinate,t)}),i.center&&(i.centerCoords=_e(i.center,t))}else i.geometry.coords=_e(i.geometry.cds,t),i.center&&(i.centerCoords=_e(i.center,t));if(i.center_x&&i.center_y){let[o,n]=_e([i.center_x,i.center_y],t);i.center_coord_x=o,i.center_coord_y=n}}),Sh(a,e)}function _e(a,t){return[a[0]-t[0],a[1]-t[1]]}var bh=.008,Nn=32;function Mh(a){let t=a.geometry;if(!t)return null;if(t.type==="point"){let[r,h]=t.coords;return typeof r=="number"&&typeof h=="number"?[r,h,r,h]:null}let e=t.coords;if(!Array.isArray(e))return null;let i=1/0,s=1/0,o=-1/0,n=-1/0;return e.forEach(r=>{Array.isArray(r)&&r.forEach(h=>{let c=h==null?void 0:h[0],l=h==null?void 0:h[1];typeof c!="number"||typeof l!="number"||(c<i&&(i=c),c>o&&(o=c),l<s&&(s=l),l>n&&(n=l))})}),i===1/0?null:[i,s,o,n]}function Eh(a,t,e){let i=a.get(t);i||a.set(t,i=new Set),i.add(e);let s=a.get(e);s||a.set(e,s=new Set),s.add(t)}function Sh(a,t){t===void 0&&(t=0);let e=a.map(Mh),i=new Map;for(let o=0;o<a.length;o++){if(!e[o])continue;a[o].deltaHeight=0;let r=(a[o].airHeight||0)+(a[o].height||0),h=i.get(r);h?h.push(o):i.set(r,[o])}let s=t>0?t%Nn:0;i.forEach(o=>{if(o.length<2)return;o.sort((c,l)=>e[c][0]-e[l][0]);let n=new Map;for(let c=0;c<o.length;c++){let l=e[o[c]];for(let p=c+1;p<o.length;p++){let d=e[o[p]];if(d[0]>l[2])break;l[3]<d[1]||d[3]<l[1]||Eh(n,c,p)}}let r=[...n.keys()].sort((c,l)=>n.get(l).size-n.get(c).size),h=new Map;r.forEach(c=>{let l=new Set;n.get(c).forEach(d=>{let u=h.get(d);u!==void 0&&l.add(u)});let p=0;for(;l.has(p);)p++;h.set(c,p)}),h.forEach((c,l)=>{a[o[l]].deltaHeight=bh*((c+s)%Nn)})})}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import{Group as Ch}from"@tweenjs/tween.js";var ie=class{update(){this.group.update()}pause(){this.pauseTween=!0,this.getAll().forEach(t=>{this.tweenStore.add(t),t.pause()})}continue(){this.pauseTween&&(this.tweenStore.forEach(t=>{t.resume()}),this.tweenStore.clear(),this.pauseTween=!1)}remove(t){this.group.remove(t)}getAll(){return this.group.getAll()}clear(){this.getAll().forEach(t=>t.stop()),this.group.removeAll()}dispose(){this.clear()}constructor(){this.pauseTween=!1,this.tweenStore=new Set,this.group=new Ch}};import{EventDispatcher as Th}from"three";var bi=class extends Th{registryEvent(){this.ctn.addEventListener("pointerdown",this._pointerDown),this.ctn.addEventListener("pointerup",this._pointerUp)}unRegistryEvent(){this.ctn.removeEventListener("pointerdown",this._pointerDown),this.ctn.removeEventListener("pointerup",this._pointerUp)}dispose(){this.unRegistryEvent()}constructor(t){super(),this.ctn=t,this._pointerDown=e=>{this.point={x:e.offsetX,y:e.offsetY}},this._pointerUp=e=>{if(!this.point)return;let{offsetX:i,offsetY:s}=e,{x:o,y:n}=this.point;Math.hypot(o-i+(n-s))>3||this.dispatchEvent({type:"click",e})},this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import{isNil as Lh}from"lodash";import{EventDispatcher as kh}from"three";var Pe=class extends kh{_isEffectiveTask(t){return t&&typeof t.run=="function"}_getIndexByTid(t){return this._task.findIndex(e=>e.tid===t)}_createTask(t){return this._isEffectiveTask(t)?w({},t,{tid:++this._id,meta:t.meta||{}}):!1}get task(){return[...this._task]}getTasks(){return[...this._task]}add(t){if(this._isEffectiveTask(t)){let e=this._createTask(t);return this._task.push(e),this.started&&!this.activeTask&&this.start(),e.tid}return!1}replace(t,e){if(!this._isEffectiveTask(e))return console.warn("[TaskQueue] replace\u65B9\u6CD5\u4F20\u5165\u7684task\u53C2\u6570\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;let i=this._getIndexByTid(t);if(i===-1)return console.warn("[TaskQueue] \u6CA1\u6709\u627E\u5230id="+t+"\u7684\u4EFB\u52A1"),!1;let s=this._createTask(e);return this._task.splice(i,1,s),s.tid}replaceByMetaType(t){var e;let i=(e=t.meta)==null?void 0:e.type;if(Lh(i))return this.add(t);{let s=this._task.find(o=>o.meta.type===i);return s?this.replace(s.tid,t):this.add(t)}}remove(t){let e=this._getIndexByTid(t);return e===-1?(console.warn("[TaskQueue] remove\u65B9\u6CD5\u4F20\u5165\u7684id\uFF1A"+t+"\u627E\u4E0D\u5230\u5BF9\u5E94\u7684task"),!1):(this._task.splice(e,1),!0)}clear(){this._task.length=0}start(){this.started=!0,!this.activeTask&&this._task.length&&this.exec()}stop(){this.started=!1}exec(){return g(this,null,function*(){if(!this.started||!this._task.length)return!1;let t=this._task.shift();this.activeTask=t,this.dispatchEvent({type:"active-task-start",task:t});let e;try{e=yield t.run()}catch(i){console.warn("[task run err]",i,t)}return this.activeTask=null,this.dispatchEvent({type:"active-task-end",task:t,res:e}),this.exec()})}constructor(t=!0){super(),this._task=[],this.started=!1,this.activeTask=null,this._id=0,t&&this.start()}};import"core-js/modules/es.array.push.js";import{EventDispatcher as Ah}from"three";var Mi=class extends Ah{getWorker(){return new Promise(t=>{let e=this.pool.find(s=>s.state==="leisure");if(e){e.state="used",t(e.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let s=this.workerConstructor();this.pool.push({worker:s,state:"used"}),t(s);return}let i=()=>{let s=this.pool.find(o=>o.state==="leisure");s&&(this.removeEventListener("release",i),s.state="used",t(s.worker))};this.addEventListener("release",i)})}releaseWorker(t){let e=this.pool.find(i=>i.worker===t);e&&(e.state="leisure",this.dispatchEvent({type:"release",worker:t}))}dispose(){this._listeners={},this.pool.forEach(t=>{t.worker.terminate()}),this.pool=[]}constructor(t=10,e){super(),this.max=10,this.pool=[],this.max=t,this.workerConstructor=e}};import{EventDispatcher as Dh}from"three";var st=class extends Dh{dispose(){this._listeners={}}};var Ei=class{filter(t){let e=this.estimate,i=this.errorEstimate+this.processNoise,s=i/(i+this.measurementNoise);return this.estimate=e+s*(t-e),this.errorEstimate=(1-s)*i,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{BufferAttribute as be,BufferGeometry as Rh,Color as oo,ExtrudeGeometry as Oh,Matrix4 as Fh,Quaternion as Ih,Vector3 as Ze}from"three";import{mergeGeometries as Gh}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{polygon as Bh,center as zh}from"@turf/turf";function _v(a,t,e){t===void 0&&(t=!0),e===void 0&&(e=!1);let i=a.filter(r=>r.geometry.type==="polygon");if(!i.length)return null;let s=i.map(r=>{var h;let c=r.geometry.coords,l=ui(c[0],c.slice(1)),p=new Oh(l,{steps:1,bevelEnabled:!1,depth:r.height,curveSegments:4});(h=r).deltaHeight||(h.deltaHeight=0),p.translate(0,0,r.airHeight+r.deltaHeight);let d=p.attributes.position.count;p.deleteAttribute("normal"),p.deleteAttribute("uv");let u=new Float32Array(d).fill(r.height+r.airHeight+r.deltaHeight);if(p.setAttribute("maxZ",new be(u,1)),p.setAttribute("opacity",new be(new Float32Array(d).fill(r.fillOpacity),1)),e){let m=new Float32Array(d).fill(r.airHeight+r.deltaHeight);p.setAttribute("minZ",new be(m,1))}let f=new oo(r.fillColor).convertLinearToSRGB(),x=new Uint8Array(d*3);for(let m=0;m<d;m++)x[m*3]=Math.round(f.r*255),x[m*3+1]=Math.round(f.g*255),x[m*3+2]=Math.round(f.b*255);return p.setAttribute("color",new be(x,3,!0)),p}),o=Gh(s);s.forEach(r=>r.dispose());let n={geometry:o};return o.dispose(),t&&(n.lineGeometry=Wh(i)||void 0),n}function Pv(a){let t=a.filter(h=>h.geometry.type==="polygon");if(!t.length)return null;let e=[],i=[],s=[],o=[],n=[],r=[];return t.map((h,c)=>{var l;(l=h).deltaHeight||(l.deltaHeight=0);let p=h.geometry.coords,d=A(p[0][0],p[0][1]),u=A(p[0][1],p[0][2]),f=p[0][1][0]-p[0][0][0],x=p[0][1][1]-p[0][0][1],m=Math.atan2(x,f),y=zh(Bh(p)),_=y.geometry.coordinates[0],P=y.geometry.coordinates[1],S=new Fh().compose(new Ze(_,P,h.deltaHeight+h.airHeight+h.height/2),new Ih().setFromAxisAngle(new Ze(0,0,1),m),new Ze(d,u,h.height));e.push(...S.toArray()),i.push(...new oo(h.fillColor).convertLinearToSRGB().toArray());var E;s[c]=(E=h.fillOpacity)!=null?E:1;var k;o[c]=((k=h.deltaHeight)!=null?k:0)+h.airHeight+h.height,n[c]=h.id,r[c]=h.airHeight+h.deltaHeight}),{size:t.length,ids:n,matrixes:e,colors:i,opacities:s,maxZs:o,minZs:r}}function Wh(a){let{points:t,colors:e,opacities:i}=no(a);if(!t.length)return null;let s=new Rh().setFromPoints(t),o=new Uint8Array(e.length);for(let n=0;n<e.length;n++)o[n]=Math.max(0,Math.min(255,Math.round(e[n]*255)));return s.setAttribute("color",new be(o,3,!0)),s.setAttribute("opacity",new be(new Float32Array(i),1)),s}function no(a){let t=[],e=[],i=[];return a.filter(s=>s.strokeOpacity>0).map(s=>{let o=s.height+(s.deltaHeight||0)+s.airHeight,{coords:n}=s.geometry,{strokeColor:r,strokeOpacity:h}=s,c=new oo(r).convertLinearToSRGB();for(let l=0;l<n.length;l++){let p=n[l];for(let d=0;d<p.length;d++){let u=p[d],f=d+1===p.length?p[0]:p[d+1];t.push(new Ze(u[0],u[1],o)),t.push(new Ze(f[0],f[1],o)),e.push(c.r,c.g,c.b),e.push(c.r,c.g,c.b),i.push(h),i.push(h)}}}),{points:t,colors:e,opacities:i}}function bv(a){if(a.length>1)return!1;let t=a[0];if(t.length!==5)return!1;let[e]=t,i=t[t.length-1];if(e[0]!==i[0]||e[1]!==i[1])return!1;let s=[Math.round(A(t[0],t[1])),Math.round(A(t[1],t[2])),Math.round(A(t[2],t[3])),Math.round(A(t[3],t[4]))];if(!(s[2]===s[0]&&s[3]===s[1]))return!1;let o=ge(t[0],t[1],t[2]);return Math.abs(Math.abs(o)-90)<1}import{Vector3 as Uh}from"three";var Si=class{setBuildingCenter(t){this.buildingCenter=t}getBuildingCenter(){return this.buildingCenter}mercatorToWorld(t){return new Uh(t[0]-this.buildingCenter[0],t[1]-this.buildingCenter[1],0)}worldToMercator(t){return[t.x+this.buildingCenter[0],t.y+this.buildingCenter[1]]}constructor(t=[0,0]){this.buildingCenter=t}};import{EventDispatcher as ou,Box2 as nu,Vector3 as Dt,Vector2 as me,Raycaster as Vr,Box3 as ru,Color as au,AmbientLight as hu,Plane as cu}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{EventDispatcher as zd}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Object3D as Ec,ExtrudeGeometry as Sc,Mesh as Cc,Box3 as Oi,Vector3 as Et,BufferGeometry as Tc,LineSegments as Lc,Vector2 as $t,DoubleSide as kc,RepeatWrapping as fr}from"three";import"core-js/modules/web.dom-collections.iterator.js";import{LineMaterial as Hh}from"three/examples/jsm/lines/LineMaterial.js";import{Color as je,LineBasicMaterial as Nh,MeshStandardMaterial as Zh,MeshBasicMaterial as jh,ShaderMaterial as Me,DoubleSide as Vh,LineDashedMaterial as Kh}from"three";function Zn(a){return a.x+"-"+a.y+"-"+a.z}var C=class{static generateLineMaterialKey(t){let{color:e,opacity:i}=t;return e+"-"+i}static createLineMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=this.generateLineMaterialKey({color:e,opacity:i,vertexColors:s});if(this.lineMaterialMap.has(o))return this.lineMaterialMap.get(o);let n=new Nh({color:new je(e).convertLinearToSRGB(),transparent:!0,opacity:i,vertexColors:s!=null?s:!1});return this.lineMaterialMap.set(o,n),n}static createMeshStandardMaterial(t){let{color:e,opacity:i}=t,s=e+"-"+i;if(this.meshStandardMaterialMap.has(s))return this.meshStandardMaterialMap.get(s);let o=new Zh({color:new je(e).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:i,depthWrite:!0});return this.meshStandardMaterialMap.set(s,o),o}static createMeshBasicMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=e+"-"+i+"-"+s;if(this.meshBasicMaterialMap.has(o))return this.meshBasicMaterialMap.get(o);let n=new jh({color:e,transparent:!0,opacity:i,depthWrite:!0,vertexColors:s!=null?s:!1});return this.meshBasicMaterialMap.set(o,n),n}static createShaderMaterial(t){let{gradualColor:e,opacity:i,max:s,min:o}=t,n=e.toString()+"-"+i+"-"+Zn(o)+"-"+Zn(s);if(this.shaderMaterialMap.has(n))return this.shaderMaterialMap.get(n);let r=`
2
2
  uniform vec3 uColor;
3
3
  uniform vec3 uGradualColor;
4
4
  uniform vec3 uMax;
@@ -25,7 +25,7 @@ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDe
25
25
  void main() {
26
26
  gl_FragColor = vec4(vColor.x, vColor.y, vColor.z, opacity);
27
27
  }
28
- `,c=new be({uniforms:{uColor:{value:new je(e[0]).convertLinearToSRGB()},uGradualColor:{value:new je(e[1]).convertLinearToSRGB()},opacity:{value:i},uMax:{value:s},uMin:{value:o}},vertexShader:r,fragmentShader:h,side:Vh});return this.shaderMaterialMap.set(n,c),c}static createLine2MaterialMap(t){let{color:e,width:i,dashed:s,resolution:o,vertexColors:n}=t,r=e+"-"+i+"-"+s+"-"+o.x+"-"+o.y+"-"+n;if(this.line2MaterialMap.has(r))return this.line2MaterialMap.get(r);let h=new Hh({color:new je(e),dashed:s,linewidth:i,worldUnits:!0,dashSize:1,gapSize:3,dashScale:1,resolution:o,vertexColors:n!=null?n:!1});return this.line2MaterialMap.set(r,h),h}static createLineDashedMaterial(t){let e="dashed-"+t.color+"-"+t.opacity+"-"+t.dashSize+"-"+t.gapSize+"-"+t.scale;if(this.lineDashedMaterialMap.has(e))return this.lineDashedMaterialMap.get(e);let i=new Kh({color:t.color,transparent:!0,opacity:t.opacity,dashSize:t.dashSize||.2,gapSize:t.gapSize||.1,scale:t.scale||1});return this.lineDashedMaterialMap.set(e,i),i}static GetMergeAttributeGraphicMaterial(){if(this.mergeAttributeGraphicMaterial)return this.mergeAttributeGraphicMaterial;let t=`
28
+ `,c=new Me({uniforms:{uColor:{value:new je(e[0]).convertLinearToSRGB()},uGradualColor:{value:new je(e[1]).convertLinearToSRGB()},opacity:{value:i},uMax:{value:s},uMin:{value:o}},vertexShader:r,fragmentShader:h,side:Vh});return this.shaderMaterialMap.set(n,c),c}static createLine2MaterialMap(t){let{color:e,width:i,dashed:s,resolution:o,vertexColors:n}=t,r=e+"-"+i+"-"+s+"-"+o.x+"-"+o.y+"-"+n;if(this.line2MaterialMap.has(r))return this.line2MaterialMap.get(r);let h=new Hh({color:new je(e),dashed:s,linewidth:i,worldUnits:!0,dashSize:1,gapSize:3,dashScale:1,resolution:o,vertexColors:n!=null?n:!1});return this.line2MaterialMap.set(r,h),h}static createLineDashedMaterial(t){let e="dashed-"+t.color+"-"+t.opacity+"-"+t.dashSize+"-"+t.gapSize+"-"+t.scale;if(this.lineDashedMaterialMap.has(e))return this.lineDashedMaterialMap.get(e);let i=new Kh({color:t.color,transparent:!0,opacity:t.opacity,dashSize:t.dashSize||.2,gapSize:t.gapSize||.1,scale:t.scale||1});return this.lineDashedMaterialMap.set(e,i),i}static GetMergeAttributeGraphicMaterial(){if(this.mergeAttributeGraphicMaterial)return this.mergeAttributeGraphicMaterial;let t=`
29
29
  attribute float maxZ; // \u58F0\u660E\u4E00\u4E2Aattribute\u53D8\u91CF
30
30
  attribute vec3 color; // \u58F0\u660E\u4E00\u4E2Aattribute\u53D8\u91CF
31
31
  attribute float opacity; // \u58F0\u660E\u4E00\u4E2Aattribute\u53D8\u91CF
@@ -55,7 +55,7 @@ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDe
55
55
  gl_FragColor = vec4(vColor * 0.85, vOpacity); // \u5176\u4ED6\u9762\u989C\u8272\uFF09
56
56
  }
57
57
  }
58
- `;return this.mergeAttributeGraphicMaterial=new be({vertexShader:t,fragmentShader:e,transparent:!0})}static GetMergeAttributeWallMaterial(){if(this.mergeAttributeWallMaterial)return this.mergeAttributeWallMaterial;let t=`
58
+ `;return this.mergeAttributeGraphicMaterial=new Me({vertexShader:t,fragmentShader:e,transparent:!0})}static GetMergeAttributeWallMaterial(){if(this.mergeAttributeWallMaterial)return this.mergeAttributeWallMaterial;let t=`
59
59
  attribute float maxZ;
60
60
  attribute float minZ;
61
61
  attribute vec3 color;
@@ -104,7 +104,7 @@ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDe
104
104
  gl_FragColor = vec4(newColor, vOpacity); // \u5176\u4ED6\u9762\u989C\u8272\uFF09
105
105
  }
106
106
  }
107
- `;return this.mergeAttributeWallMaterial=new be({vertexShader:t,fragmentShader:e,transparent:!0})}static GetMergeAttributeGraphicLineMaterial(){if(this.mergeAttributeGraphicLineMaterial)return this.mergeAttributeGraphicLineMaterial;let t=`
107
+ `;return this.mergeAttributeWallMaterial=new Me({vertexShader:t,fragmentShader:e,transparent:!0})}static GetMergeAttributeGraphicLineMaterial(){if(this.mergeAttributeGraphicLineMaterial)return this.mergeAttributeGraphicLineMaterial;let t=`
108
108
  attribute vec3 color; // \u58F0\u660E\u4E00\u4E2Aattribute\u53D8\u91CF
109
109
  attribute float opacity; // \u58F0\u660E\u4E00\u4E2Aattribute\u53D8\u91CF
110
110
  varying vec3 vColor;
@@ -122,7 +122,7 @@ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDe
122
122
  void main() {
123
123
  gl_FragColor = vec4(vColor, vOpacity); //\uFF08\u9876\u9762\u989C\u8272\uFF09
124
124
  }
125
- `;return this.mergeAttributeGraphicLineMaterial=new be({vertexShader:t,fragmentShader:e,transparent:!0})}static GetInstancedGraphicMaterial(){if(this.instancedGraphicMaterial)return this.instancedGraphicMaterial;let t=`
125
+ `;return this.mergeAttributeGraphicLineMaterial=new Me({vertexShader:t,fragmentShader:e,transparent:!0})}static GetInstancedGraphicMaterial(){if(this.instancedGraphicMaterial)return this.instancedGraphicMaterial;let t=`
126
126
  attribute float opacity;
127
127
  attribute float maxZ;
128
128
  varying vec3 vPosition; // \u63A5\u6536\u9876\u70B9\u4F4D\u7F6E
@@ -154,7 +154,7 @@ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDe
154
154
  gl_FragColor = vec4(vColor * 0.85, vOpacity); // \u5176\u4ED6\u9762\u989C\u8272\uFF09
155
155
  }
156
156
  }
157
- `;return this.instancedGraphicMaterial=new be({vertexShader:t,fragmentShader:e,transparent:!0})}static GetInstancedWallMaterial(){if(this.instancedWallMaterial)return this.instancedWallMaterial;let t=`
157
+ `;return this.instancedGraphicMaterial=new Me({vertexShader:t,fragmentShader:e,transparent:!0})}static GetInstancedWallMaterial(){if(this.instancedWallMaterial)return this.instancedWallMaterial;let t=`
158
158
  attribute float opacity;
159
159
  attribute float maxZ;
160
160
  attribute float minZ;
@@ -205,7 +205,7 @@ var ja=Object.create;var Xs=Object.defineProperty;var Va=Object.getOwnPropertyDe
205
205
  gl_FragColor = vec4(newColor, vOpacity);
206
206
  }
207
207
  }
208
- `;return this.instancedWallMaterial=new be({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};C.lineMaterialMap=new Map;C.meshStandardMaterialMap=new Map;C.meshBasicMaterialMap=new Map;C.shaderMaterialMap=new Map;C.line2MaterialMap=new Map;C.mergeAttributeGraphicMaterial=null;C.mergeAttributeWallMaterial=null;C.mergeAttributeGraphicLineMaterial=null;C.instancedGraphicMaterial=null;C.instancedWallMaterial=null;C.lineDashedMaterialMap=new Map;import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import{DataTexture as qh,LinearFilter as qn,RedFormat as $h,UnsignedByteType as Jh}from"three";var ro=new Float64Array(256);for(let a=0;a<256;a++){let t=.5-Math.pow(a/255,.45454545454545453);ro[a]=t*Math.abs(t)}ro[255]=-1e20;var Ve=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:s=.25,fontFamily:o="sans-serif",fontWeight:n="normal",fontStyle:r="normal",lang:h=null}={}){e=this.buffer=Math.round(e),this.radius=i,this.cutoff=s,this.lang=h;let c=this.size=Math.ceil(t)+e*4,l=this._createCanvas(c),p=this.ctx=l.getContext("2d",{willReadFrequently:!0});p.font=`${r} ${n} ${t}px ${o}`,p.textBaseline="alphabetic",p.textAlign="left",p.fillStyle="black",h&&(p.lang=h);let u=(this.maxGlyphDim=c-e)+2*e;this.gridOuter=new Float64Array(u*u),this.gridInner=new Float64Array(u*u),this.f=new Float64Array(u),this.z=new Float64Array(u+1),this.v=new Uint16Array(u)}_createCanvas(t){if(typeof OffscreenCanvas!="undefined")return new OffscreenCanvas(t,t);let e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:s,actualBoundingBoxLeft:o,actualBoundingBoxRight:n}=this.ctx.measureText(t),r=Math.ceil(i),h=Math.floor(-o),c=Math.max(0,Math.min(this.maxGlyphDim,Math.ceil(n)-h)),l=Math.max(0,Math.min(this.maxGlyphDim,r+Math.ceil(s))),p=c+2*this.buffer,d=l+2*this.buffer,u=p*d,f=new Uint8ClampedArray(u),x={data:f,width:p,height:d,glyphWidth:c,glyphHeight:l,glyphTop:r,glyphLeft:h,glyphAdvance:e};if(c===0||l===0)return x;let{ctx:m,buffer:y,gridInner:_,gridOuter:P}=this;m.clearRect(y,y,c,l),m.fillText(t,y-h,y+r);let S=m.getImageData(y,y,c,l);P.fill(1e20,0,u),_.fill(0,0,u);let E=3;for(let R=0;R<l;R++){let O=(R+y)*p+y;for(let $=0;$<c;$++,E+=4,O++){let nt=S.data[E];if(nt===0)continue;let W=ro[nt];P[O]=Math.max(0,W),_[O]=Math.max(0,-W)}}jn(P,0,0,p,d,p,this.f,this.v,this.z,y);let k=Math.min(y,1);jn(_,y-k,y-k,c+2*k,l+2*k,p,this.f,this.v,this.z);let b=255/this.radius,G=255*(1-this.cutoff);for(let R=0;R<u;R++){let O=Math.sqrt(P[R])-Math.sqrt(_[R]);f[R]=G-b*O}return x}};function jn(a,t,e,i,s,o,n,r,h,c=0){for(let l=t+c;l<t+i-c;l++)Vn(a,e*o+l,o,s,n,r,h);for(let l=e;l<e+s;l++)Vn(a,l*o+t,1,i,n,r,h)}function Vn(a,t,e,i,s,o,n){o[0]=0,n[0]=-1e20,n[1]=1e20,s[0]=a[t];for(let r=1,h=0;r<i;r++){let c=s[r]=a[t+r*e],l=r*r,p;do{let d=o[h];p=(c-s[d]+l-d*d)/(r-d)/2}while(p<=n[h]&&--h>-1);h++,o[h]=r,n[h]=p,n[h+1]=1e20}for(let r=0,h=0;r<i;r++){for(;n[h+1]<r;)h++;let c=o[h],l=r-c;a[t+r*e]=s[c]+l*l}}import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-exception.constructor.js";import"core-js/modules/web.dom-exception.stack.js";import"core-js/modules/web.dom-exception.to-string-tag.js";var Lt=null,he=null,Ke=0,Ci=!1,ct=function(a){return a.MAP_VERSION="map_version",a.ROUTE_VERSION="route_version",a.FACILITY_VERSION="facility_version",a.MAP_DATA="map_data",a.ROAD_NETWORK_DATA="road_network_data",a.FACILITY_DATA="facility_data",a.POI_TEXT="poi_text_1",a.POI_TEXT_RECT="poi_text_rect",a.LAZY_TEXTURE="lazy_texture",a.LAZY_POI="lazy_poi",a.SDF_GLYPH="sdf_glyph_1",a}({});function Kn(){Ke+=1,Ci=!1}function Xn(){Ke=Math.max(0,Ke-1),Ke===0&&(Ci=!0,Yh())}function Xe(){return g(this,null,function*(){if(Lt)return Lt;if(typeof window!="undefined"&&Ke===0)throw new Error("\u6CA1\u6709db");return(yield Ye()).db})}function Ye(a,t){return a===void 0&&(a="aibee_map"),t===void 0&&(t=10),Lt?Promise.resolve({db:Lt,type:"success"}):he?he.then(e=>({db:e,type:"success"})):(he=new Promise((e,i)=>{let s;try{s=indexedDB.open(a,t)}catch(o){he=null,i(o);return}s.onupgradeneeded=function(o){let n=o.target.result;console.log("[open db is onupgradeneeded]"),Tt("map_version",n),Tt("route_version",n),Tt("facility_version",n),Tt("map_data",n),Tt("road_network_data",n),Tt("facility_data",n),Tt("poi_text_1",n),Tt("poi_text_rect",n),Tt("lazy_texture",n),Tt("lazy_poi",n),Tt("sdf_glyph_1",n)},s.onsuccess=()=>{he=null;let o=s.result;if(Ci){Ci=!1,o.close(),i(new Error("\u6CA1\u6709db"));return}Lt=o,e(o)},s.onerror=()=>{he=null,console.log("[open db is onerror]"),i(s.error||new Error("open db error"))}}),he.then(e=>({db:e,type:"success"})))}function Xh(a){return typeof DOMException!="undefined"&&a instanceof DOMException&&(a.name==="InvalidStateError"||a.name==="TransactionInactiveError")}function Yn(a,t){return g(this,null,function*(){let e=a!=null?a:yield Xe();try{return yield t(e)}catch(i){if(Xh(i))return Lt===e&&(Lt=null),t(yield Xe());throw i}})}function qe(a,t,e){return Yn(e,i=>new Promise((s,o)=>{try{let r=i.transaction([a],"readonly").objectStore(a).get(t);r.onsuccess=()=>{r.result?s(r.result.value):s(null)},r.onerror=h=>{console.log("[getVersionByKey]",h),s(null)}}catch(n){o(n)}}))}function Ti(a,t,e,i,s){return s===void 0&&(s=!1),Yn(i,o=>g(this,null,function*(){let n=s;return s||(n=!!(yield qe(a,t,o))),new Promise((r,h)=>{try{let c=o.transaction([a],"readwrite"),l=c.objectStore(a),p=n?l.put({key:t,value:e}):l.add({key:t,value:e});p.onerror=function(d){h(d)},c.oncomplete=function(){r(p.result)},c.onabort=function(){h(c.error||new Error("IndexedDB transaction aborted"))},c.onerror=function(){h(c.error||new Error("IndexedDB transaction failed"))}}catch(c){h(c)}})}))}function Tt(a,t){t===void 0&&(t=Lt),t&&(t.objectStoreNames.contains(a)||t.createObjectStore(a,{keyPath:"key"}))}function Yh(a){a===void 0&&(a=Lt),a&&a.close(),(!a||a===Lt)&&(Lt=null)}function ao(){return new Worker(new URL("./worker/sdf-text.worker-WGWC2SON.js",import.meta.url))}var Qh={fontFamily:"sans-serif",fontSize:64,fontWeight:400,radius:18,cutoff:.25,buffer:12,lineGapRatio:.125,ascentRatio:.88,descentRatio:.12},tc=4096,ec=2048,ic=1024,sc=64*1024*1024,ho=32,$n=4;function oc(a){let t=a*a*2;return Math.max(1,Math.min(Math.floor(sc/t),ho))}var nc=8;function rc(a){return Array.from(new Set(Array.from(a||"")))}function ac(a,t){let e=a.draw(t);return{data:new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength),width:e.width,height:e.height,glyphWidth:e.glyphWidth,glyphHeight:e.glyphHeight,glyphLeft:e.glyphLeft,glyphTop:e.glyphTop,glyphAdvance:e.glyphAdvance}}var X=class{static getSpec(t){return w({},Qh,t)}static getFontKey(t){return ae(t)}static getMaxTextureSize(){if(this.maxTextureSize!==null)return this.maxTextureSize;let t=2048;try{let i=document.createElement("canvas"),s=i.getContext("webgl2")||i.getContext("webgl");if(s){var e;let o=s.getParameter(s.MAX_TEXTURE_SIZE);typeof o=="number"&&o>0&&(t=o),(e=s.getExtension("WEBGL_lose_context"))==null||e.loseContext()}}catch(i){}return this.maxTextureSize=t,t}static getAtlasSize(){let t=vi?ec:tc,e=Math.max(ic,Math.min(t,this.getMaxTextureSize()));return e<t&&console.warn("[SdfTextFactory] \u8BBE\u5907\u6700\u5927\u7EB9\u7406\u5C3A\u5BF8\u4E3A "+this.getMaxTextureSize()+"\uFF0C\u56FE\u96C6\u964D\u7EA7\u4E3A "+e+"\xD7"+e+"\uFF0C\u53EF\u5BB9\u7EB3\u5B57\u5F62\u6570\u91CF\u76F8\u5E94\u51CF\u5C11\u3002"),e}static getAtlas(t){let e=this.getSpec(t),i=this.getFontKey(e),s=this.atlases.get(i);return s||(s=this.createAtlas(i,e),this.atlases.set(i,s)),s}static getAtlasByKey(t){return this.atlases.get(t)}static getTexture(t){return this.ensurePage(this.getAtlas(t)).texture}static getTextures(t){return this.getAtlas(t).pages.map(e=>e.texture)}static getGlyph(t,e){var i;return(i=this.getAtlas(e).charMap.get(t))!=null?i:null}static ensureText(t,e){return g(this,null,function*(){let i=this.getAtlas(e),s=rc(t);if(!s.length)return i;let o=s.filter(n=>!i.charMap.has(n));return o.length&&(yield this.generateMissing(i,o)),i})}static createAtlas(t,e){let i=this.getAtlasSize();return{key:t,spec:e,size:i,maxPages:oc(i),pages:[],charMap:new Map}}static ensurePage(t,e){e===void 0&&(e=0);let i=t.pages[e];return i||(i=this.createPage(t.size,e),t.pages[e]=i),i}static createPage(t,e){let i=new Uint8Array(t*t),s=new qh(i,t,t,$h,Jh);return s.minFilter=qn,s.magFilter=qn,s.generateMipmaps=!1,s.unpackAlignment=1,s.needsUpdate=!0,{index:e,buffer:i,texture:s,cursorX:0,cursorY:0,rowHeight:0}}static generateMissing(t,e){return g(this,null,function*(){let i=[],s=yield Promise.all(e.map(o=>g(this,null,function*(){return{char:o,data:yield this.readFromDb(t.key,o)}})));for(let o of s)o.data?this.insertGlyph(t,o.char,o.data):i.push(o.char);i.length&&(yield this.generate(t.spec,i)).forEach((n,r)=>{let h=i[r];this.insertGlyph(t,h,n),this.writeToDb(t.key,h,n)})})}static insertGlyph(t,e,i){let s=i.width<=0||i.height<=0,o={u0:0,v0:0,u1:0,v1:0,width:i.width,height:i.height,glyphWidth:i.glyphWidth,glyphHeight:i.glyphHeight,glyphLeft:i.glyphLeft,glyphTop:i.glyphTop,glyphAdvance:i.glyphAdvance,blank:s,page:0};if(s)return t.charMap.set(e,o),o;let n=this.pickPage(t,i.width,i.height);if(!n){if(!this.warnedFull){this.warnedFull=!0;let c=Math.min(ho,t.maxPages+$n);console.warn("[SdfTextFactory] \u56FE\u96C6\u9875\u6570\u5DF2\u8FBE\u786C\u4E0A\u9650\uFF08"+c+" \u9875\uFF0C\u7EA6 "+Math.round(c*t.size*t.size*2/1024/1024)+"MB\uFF09\uFF0C\u90E8\u5206\u5B57\u5F62\u5C06\u88AB\u8DF3\u8FC7\u3002\u8BF7\u51CF\u5C11\u5B57\u79CD\u6216\u8C03\u5927\u663E\u5B58\u9884\u7B97\u3002")}return o.blank=!0,t.charMap.set(e,o),o}(n.cursorX+i.width>t.size||n.cursorY+i.height>t.size)&&(n.cursorX=0,n.cursorY+=n.rowHeight+1,n.rowHeight=0);let r=n.cursorX,h=n.cursorY;for(let c=0;c<i.height;c++){let l=c*i.width,p=(h+c)*t.size+r;n.buffer.set(i.data.subarray(l,l+i.width),p)}return o.u0=r/t.size,o.u1=(r+i.width)/t.size,o.v0=h/t.size,o.v1=(h+i.height)/t.size,o.page=n.index,n.texture.needsUpdate=!0,n.cursorX=r+i.width+1,n.rowHeight=Math.max(n.rowHeight,i.height),t.charMap.set(e,o),o}static pageCanFit(t,e,i,s){return i>t.size||s>t.size?!1:e.cursorX+i<=t.size&&e.cursorY+s<=t.size?!0:e.cursorY+e.rowHeight+1+s<=t.size}static pickPage(t,e,i){for(let n of t.pages)if(this.pageCanFit(t,n,e,i))return n;let s=Math.min(ho,t.maxPages+$n);if(t.pages.length>=s)return null;let o=this.createPage(t.size,t.pages.length);return t.pages.push(o),o}static generate(t,e){return g(this,null,function*(){let i=this.getWorker();if(i&&typeof OffscreenCanvas!="undefined")try{return(yield H(i,"gen_sdf_glyphs",{chars:e,spec:t})).list.map(o=>({data:new Uint8Array(o.data),width:o.width,height:o.height,glyphWidth:o.glyphWidth,glyphHeight:o.glyphHeight,glyphLeft:o.glyphLeft,glyphTop:o.glyphTop,glyphAdvance:o.glyphAdvance}))}catch(s){console.warn("[SdfTextFactory] Worker \u751F\u6210\u5931\u8D25\uFF0C\u56DE\u9000\u4E3B\u7EBF\u7A0B",s),this.workerFailed=!0}return this.generateInMainThread(t,e)})}static getWorker(){if(this.workerFailed)return null;if(!this.worker)try{this.worker=ao()}catch(t){return this.workerFailed=!0,null}return this.worker}static generateInMainThread(t,e){return new Promise(i=>{let s=new Ve({fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight,radius:t.radius,cutoff:t.cutoff,buffer:t.buffer}),o=[],n=0,r=()=>{let h=Date.now();for(;n<e.length&&Date.now()-h<nc;)o.push(ac(s,e[n])),n++;if(n>=e.length){i(o);return}typeof window!="undefined"&&typeof window.requestIdleCallback=="function"?this.timer.requestIdleCallback(r):typeof window!="undefined"?this.timer.requestAnimationFrame(r):r()};r()})}static initDb(){return this.dbReady||(this.dbReady=Ye().then(()=>{}).catch(()=>{})),this.dbReady}static readFromDb(t,e){return g(this,null,function*(){try{yield this.initDb();let i=yield qe(ct.SDF_GLYPH,t+"|"+e);if(i&&i.data)return{data:new Uint8Array(i.data),width:i.width,height:i.height,glyphWidth:i.glyphWidth,glyphHeight:i.glyphHeight,glyphLeft:i.glyphLeft,glyphTop:i.glyphTop,glyphAdvance:i.glyphAdvance}}catch(i){}return null})}static writeToDb(t,e,i){this.initDb().then(()=>Ti(ct.SDF_GLYPH,t+"|"+e,{data:i.data.slice().buffer,width:i.width,height:i.height,glyphWidth:i.glyphWidth,glyphHeight:i.glyphHeight,glyphLeft:i.glyphLeft,glyphTop:i.glyphTop,glyphAdvance:i.glyphAdvance},void 0,!0)).catch(()=>{})}static dispose(){var t;this.atlases.forEach(e=>e.pages.forEach(i=>i.texture.dispose())),this.atlases.clear(),this.timer.dispose(),(t=this.worker)==null||t.terminate(),this.worker=null,this.workerFailed=!1,this.dbReady=null,this.warnedFull=!1}};X.atlases=new Map;X.timer=new K;X.worker=null;X.workerFailed=!1;X.dbReady=null;X.warnedFull=!1;X.maxTextureSize=null;import{Color as co,DoubleSide as Jn,ShaderMaterial as Qn}from"three";var hc=.25,cc=1-hc,lc=`
208
+ `;return this.instancedWallMaterial=new Me({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};C.lineMaterialMap=new Map;C.meshStandardMaterialMap=new Map;C.meshBasicMaterialMap=new Map;C.shaderMaterialMap=new Map;C.line2MaterialMap=new Map;C.mergeAttributeGraphicMaterial=null;C.mergeAttributeWallMaterial=null;C.mergeAttributeGraphicLineMaterial=null;C.instancedGraphicMaterial=null;C.instancedWallMaterial=null;C.lineDashedMaterialMap=new Map;import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import{DataTexture as qh,LinearFilter as qn,RedFormat as $h,UnsignedByteType as Jh}from"three";var ro=new Float64Array(256);for(let a=0;a<256;a++){let t=.5-Math.pow(a/255,.45454545454545453);ro[a]=t*Math.abs(t)}ro[255]=-1e20;var Ve=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:s=.25,fontFamily:o="sans-serif",fontWeight:n="normal",fontStyle:r="normal",lang:h=null}={}){e=this.buffer=Math.round(e),this.radius=i,this.cutoff=s,this.lang=h;let c=this.size=Math.ceil(t)+e*4,l=this._createCanvas(c),p=this.ctx=l.getContext("2d",{willReadFrequently:!0});p.font=`${r} ${n} ${t}px ${o}`,p.textBaseline="alphabetic",p.textAlign="left",p.fillStyle="black",h&&(p.lang=h);let u=(this.maxGlyphDim=c-e)+2*e;this.gridOuter=new Float64Array(u*u),this.gridInner=new Float64Array(u*u),this.f=new Float64Array(u),this.z=new Float64Array(u+1),this.v=new Uint16Array(u)}_createCanvas(t){if(typeof OffscreenCanvas!="undefined")return new OffscreenCanvas(t,t);let e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:s,actualBoundingBoxLeft:o,actualBoundingBoxRight:n}=this.ctx.measureText(t),r=Math.ceil(i),h=Math.floor(-o),c=Math.max(0,Math.min(this.maxGlyphDim,Math.ceil(n)-h)),l=Math.max(0,Math.min(this.maxGlyphDim,r+Math.ceil(s))),p=c+2*this.buffer,d=l+2*this.buffer,u=p*d,f=new Uint8ClampedArray(u),x={data:f,width:p,height:d,glyphWidth:c,glyphHeight:l,glyphTop:r,glyphLeft:h,glyphAdvance:e};if(c===0||l===0)return x;let{ctx:m,buffer:y,gridInner:_,gridOuter:P}=this;m.clearRect(y,y,c,l),m.fillText(t,y-h,y+r);let S=m.getImageData(y,y,c,l);P.fill(1e20,0,u),_.fill(0,0,u);let E=3;for(let R=0;R<l;R++){let O=(R+y)*p+y;for(let $=0;$<c;$++,E+=4,O++){let nt=S.data[E];if(nt===0)continue;let W=ro[nt];P[O]=Math.max(0,W),_[O]=Math.max(0,-W)}}jn(P,0,0,p,d,p,this.f,this.v,this.z,y);let k=Math.min(y,1);jn(_,y-k,y-k,c+2*k,l+2*k,p,this.f,this.v,this.z);let M=255/this.radius,G=255*(1-this.cutoff);for(let R=0;R<u;R++){let O=Math.sqrt(P[R])-Math.sqrt(_[R]);f[R]=G-M*O}return x}};function jn(a,t,e,i,s,o,n,r,h,c=0){for(let l=t+c;l<t+i-c;l++)Vn(a,e*o+l,o,s,n,r,h);for(let l=e;l<e+s;l++)Vn(a,l*o+t,1,i,n,r,h)}function Vn(a,t,e,i,s,o,n){o[0]=0,n[0]=-1e20,n[1]=1e20,s[0]=a[t];for(let r=1,h=0;r<i;r++){let c=s[r]=a[t+r*e],l=r*r,p;do{let d=o[h];p=(c-s[d]+l-d*d)/(r-d)/2}while(p<=n[h]&&--h>-1);h++,o[h]=r,n[h]=p,n[h+1]=1e20}for(let r=0,h=0;r<i;r++){for(;n[h+1]<r;)h++;let c=o[h],l=r-c;a[t+r*e]=s[c]+l*l}}import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-exception.constructor.js";import"core-js/modules/web.dom-exception.stack.js";import"core-js/modules/web.dom-exception.to-string-tag.js";var Lt=null,he=null,Ke=0,Ci=!1,ct=function(a){return a.MAP_VERSION="map_version",a.ROUTE_VERSION="route_version",a.FACILITY_VERSION="facility_version",a.MAP_DATA="map_data",a.ROAD_NETWORK_DATA="road_network_data",a.FACILITY_DATA="facility_data",a.POI_TEXT="poi_text_1",a.POI_TEXT_RECT="poi_text_rect",a.LAZY_TEXTURE="lazy_texture",a.LAZY_POI="lazy_poi",a.SDF_GLYPH="sdf_glyph_1",a}({});function Kn(){Ke+=1,Ci=!1}function Xn(){Ke=Math.max(0,Ke-1),Ke===0&&(Ci=!0,Yh())}function Xe(){return g(this,null,function*(){if(Lt)return Lt;if(typeof window!="undefined"&&Ke===0)throw new Error("\u6CA1\u6709db");return(yield Ye()).db})}function Ye(a,t){return a===void 0&&(a="aibee_map"),t===void 0&&(t=10),Lt?Promise.resolve({db:Lt,type:"success"}):he?he.then(e=>({db:e,type:"success"})):(he=new Promise((e,i)=>{let s;try{s=indexedDB.open(a,t)}catch(o){he=null,i(o);return}s.onupgradeneeded=function(o){let n=o.target.result;console.log("[open db is onupgradeneeded]"),Tt("map_version",n),Tt("route_version",n),Tt("facility_version",n),Tt("map_data",n),Tt("road_network_data",n),Tt("facility_data",n),Tt("poi_text_1",n),Tt("poi_text_rect",n),Tt("lazy_texture",n),Tt("lazy_poi",n),Tt("sdf_glyph_1",n)},s.onsuccess=()=>{he=null;let o=s.result;if(Ci){Ci=!1,o.close(),i(new Error("\u6CA1\u6709db"));return}Lt=o,e(o)},s.onerror=()=>{he=null,console.log("[open db is onerror]"),i(s.error||new Error("open db error"))}}),he.then(e=>({db:e,type:"success"})))}function Xh(a){return typeof DOMException!="undefined"&&a instanceof DOMException&&(a.name==="InvalidStateError"||a.name==="TransactionInactiveError")}function Yn(a,t){return g(this,null,function*(){let e=a!=null?a:yield Xe();try{return yield t(e)}catch(i){if(Xh(i))return Lt===e&&(Lt=null),t(yield Xe());throw i}})}function qe(a,t,e){return Yn(e,i=>new Promise((s,o)=>{try{let r=i.transaction([a],"readonly").objectStore(a).get(t);r.onsuccess=()=>{r.result?s(r.result.value):s(null)},r.onerror=h=>{console.log("[getVersionByKey]",h),s(null)}}catch(n){o(n)}}))}function Ti(a,t,e,i,s){return s===void 0&&(s=!1),Yn(i,o=>g(this,null,function*(){let n=s;return s||(n=!!(yield qe(a,t,o))),new Promise((r,h)=>{try{let c=o.transaction([a],"readwrite"),l=c.objectStore(a),p=n?l.put({key:t,value:e}):l.add({key:t,value:e});p.onerror=function(d){h(d)},c.oncomplete=function(){r(p.result)},c.onabort=function(){h(c.error||new Error("IndexedDB transaction aborted"))},c.onerror=function(){h(c.error||new Error("IndexedDB transaction failed"))}}catch(c){h(c)}})}))}function Tt(a,t){t===void 0&&(t=Lt),t&&(t.objectStoreNames.contains(a)||t.createObjectStore(a,{keyPath:"key"}))}function Yh(a){a===void 0&&(a=Lt),a&&a.close(),(!a||a===Lt)&&(Lt=null)}function ao(){return new Worker(new URL("./worker/sdf-text.worker-WGWC2SON.js",import.meta.url))}var Qh={fontFamily:"sans-serif",fontSize:64,fontWeight:400,radius:18,cutoff:.25,buffer:12,lineGapRatio:.125,ascentRatio:.88,descentRatio:.12},tc=4096,ec=2048,ic=1024,sc=64*1024*1024,ho=32,$n=4;function oc(a){let t=a*a*2;return Math.max(1,Math.min(Math.floor(sc/t),ho))}var nc=8;function rc(a){return Array.from(new Set(Array.from(a||"")))}function ac(a,t){let e=a.draw(t);return{data:new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength),width:e.width,height:e.height,glyphWidth:e.glyphWidth,glyphHeight:e.glyphHeight,glyphLeft:e.glyphLeft,glyphTop:e.glyphTop,glyphAdvance:e.glyphAdvance}}var X=class{static getSpec(t){return w({},Qh,t)}static getFontKey(t){return ae(t)}static getMaxTextureSize(){if(this.maxTextureSize!==null)return this.maxTextureSize;let t=2048;try{let i=document.createElement("canvas"),s=i.getContext("webgl2")||i.getContext("webgl");if(s){var e;let o=s.getParameter(s.MAX_TEXTURE_SIZE);typeof o=="number"&&o>0&&(t=o),(e=s.getExtension("WEBGL_lose_context"))==null||e.loseContext()}}catch(i){}return this.maxTextureSize=t,t}static getAtlasSize(){let t=vi?ec:tc,e=Math.max(ic,Math.min(t,this.getMaxTextureSize()));return e<t&&console.warn("[SdfTextFactory] \u8BBE\u5907\u6700\u5927\u7EB9\u7406\u5C3A\u5BF8\u4E3A "+this.getMaxTextureSize()+"\uFF0C\u56FE\u96C6\u964D\u7EA7\u4E3A "+e+"\xD7"+e+"\uFF0C\u53EF\u5BB9\u7EB3\u5B57\u5F62\u6570\u91CF\u76F8\u5E94\u51CF\u5C11\u3002"),e}static getAtlas(t){let e=this.getSpec(t),i=this.getFontKey(e),s=this.atlases.get(i);return s||(s=this.createAtlas(i,e),this.atlases.set(i,s)),s}static getAtlasByKey(t){return this.atlases.get(t)}static getTexture(t){return this.ensurePage(this.getAtlas(t)).texture}static getTextures(t){return this.getAtlas(t).pages.map(e=>e.texture)}static getGlyph(t,e){var i;return(i=this.getAtlas(e).charMap.get(t))!=null?i:null}static ensureText(t,e){return g(this,null,function*(){let i=this.getAtlas(e),s=rc(t);if(!s.length)return i;let o=s.filter(n=>!i.charMap.has(n));return o.length&&(yield this.generateMissing(i,o)),i})}static createAtlas(t,e){let i=this.getAtlasSize();return{key:t,spec:e,size:i,maxPages:oc(i),pages:[],charMap:new Map}}static ensurePage(t,e){e===void 0&&(e=0);let i=t.pages[e];return i||(i=this.createPage(t.size,e),t.pages[e]=i),i}static createPage(t,e){let i=new Uint8Array(t*t),s=new qh(i,t,t,$h,Jh);return s.minFilter=qn,s.magFilter=qn,s.generateMipmaps=!1,s.unpackAlignment=1,s.needsUpdate=!0,{index:e,buffer:i,texture:s,cursorX:0,cursorY:0,rowHeight:0}}static generateMissing(t,e){return g(this,null,function*(){let i=[],s=yield Promise.all(e.map(o=>g(this,null,function*(){return{char:o,data:yield this.readFromDb(t.key,o)}})));for(let o of s)o.data?this.insertGlyph(t,o.char,o.data):i.push(o.char);i.length&&(yield this.generate(t.spec,i)).forEach((n,r)=>{let h=i[r];this.insertGlyph(t,h,n),this.writeToDb(t.key,h,n)})})}static insertGlyph(t,e,i){let s=i.width<=0||i.height<=0,o={u0:0,v0:0,u1:0,v1:0,width:i.width,height:i.height,glyphWidth:i.glyphWidth,glyphHeight:i.glyphHeight,glyphLeft:i.glyphLeft,glyphTop:i.glyphTop,glyphAdvance:i.glyphAdvance,blank:s,page:0};if(s)return t.charMap.set(e,o),o;let n=this.pickPage(t,i.width,i.height);if(!n){if(!this.warnedFull){this.warnedFull=!0;let c=Math.min(ho,t.maxPages+$n);console.warn("[SdfTextFactory] \u56FE\u96C6\u9875\u6570\u5DF2\u8FBE\u786C\u4E0A\u9650\uFF08"+c+" \u9875\uFF0C\u7EA6 "+Math.round(c*t.size*t.size*2/1024/1024)+"MB\uFF09\uFF0C\u90E8\u5206\u5B57\u5F62\u5C06\u88AB\u8DF3\u8FC7\u3002\u8BF7\u51CF\u5C11\u5B57\u79CD\u6216\u8C03\u5927\u663E\u5B58\u9884\u7B97\u3002")}return o.blank=!0,t.charMap.set(e,o),o}(n.cursorX+i.width>t.size||n.cursorY+i.height>t.size)&&(n.cursorX=0,n.cursorY+=n.rowHeight+1,n.rowHeight=0);let r=n.cursorX,h=n.cursorY;for(let c=0;c<i.height;c++){let l=c*i.width,p=(h+c)*t.size+r;n.buffer.set(i.data.subarray(l,l+i.width),p)}return o.u0=r/t.size,o.u1=(r+i.width)/t.size,o.v0=h/t.size,o.v1=(h+i.height)/t.size,o.page=n.index,n.texture.needsUpdate=!0,n.cursorX=r+i.width+1,n.rowHeight=Math.max(n.rowHeight,i.height),t.charMap.set(e,o),o}static pageCanFit(t,e,i,s){return i>t.size||s>t.size?!1:e.cursorX+i<=t.size&&e.cursorY+s<=t.size?!0:e.cursorY+e.rowHeight+1+s<=t.size}static pickPage(t,e,i){for(let n of t.pages)if(this.pageCanFit(t,n,e,i))return n;let s=Math.min(ho,t.maxPages+$n);if(t.pages.length>=s)return null;let o=this.createPage(t.size,t.pages.length);return t.pages.push(o),o}static generate(t,e){return g(this,null,function*(){let i=this.getWorker();if(i&&typeof OffscreenCanvas!="undefined")try{return(yield H(i,"gen_sdf_glyphs",{chars:e,spec:t})).list.map(o=>({data:new Uint8Array(o.data),width:o.width,height:o.height,glyphWidth:o.glyphWidth,glyphHeight:o.glyphHeight,glyphLeft:o.glyphLeft,glyphTop:o.glyphTop,glyphAdvance:o.glyphAdvance}))}catch(s){console.warn("[SdfTextFactory] Worker \u751F\u6210\u5931\u8D25\uFF0C\u56DE\u9000\u4E3B\u7EBF\u7A0B",s),this.workerFailed=!0}return this.generateInMainThread(t,e)})}static getWorker(){if(this.workerFailed)return null;if(!this.worker)try{this.worker=ao()}catch(t){return this.workerFailed=!0,null}return this.worker}static generateInMainThread(t,e){return new Promise(i=>{let s=new Ve({fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight,radius:t.radius,cutoff:t.cutoff,buffer:t.buffer}),o=[],n=0,r=()=>{let h=Date.now();for(;n<e.length&&Date.now()-h<nc;)o.push(ac(s,e[n])),n++;if(n>=e.length){i(o);return}typeof window!="undefined"&&typeof window.requestIdleCallback=="function"?this.timer.requestIdleCallback(r):typeof window!="undefined"?this.timer.requestAnimationFrame(r):r()};r()})}static initDb(){return this.dbReady||(this.dbReady=Ye().then(()=>{}).catch(()=>{})),this.dbReady}static readFromDb(t,e){return g(this,null,function*(){try{yield this.initDb();let i=yield qe(ct.SDF_GLYPH,t+"|"+e);if(i&&i.data)return{data:new Uint8Array(i.data),width:i.width,height:i.height,glyphWidth:i.glyphWidth,glyphHeight:i.glyphHeight,glyphLeft:i.glyphLeft,glyphTop:i.glyphTop,glyphAdvance:i.glyphAdvance}}catch(i){}return null})}static writeToDb(t,e,i){this.initDb().then(()=>Ti(ct.SDF_GLYPH,t+"|"+e,{data:i.data.slice().buffer,width:i.width,height:i.height,glyphWidth:i.glyphWidth,glyphHeight:i.glyphHeight,glyphLeft:i.glyphLeft,glyphTop:i.glyphTop,glyphAdvance:i.glyphAdvance},void 0,!0)).catch(()=>{})}static dispose(){var t;this.atlases.forEach(e=>e.pages.forEach(i=>i.texture.dispose())),this.atlases.clear(),this.timer.dispose(),(t=this.worker)==null||t.terminate(),this.worker=null,this.workerFailed=!1,this.dbReady=null,this.warnedFull=!1}};X.atlases=new Map;X.timer=new K;X.worker=null;X.workerFailed=!1;X.dbReady=null;X.warnedFull=!1;X.maxTextureSize=null;import{Color as co,DoubleSide as Jn,ShaderMaterial as Qn}from"three";var hc=.25,cc=1-hc,lc=`
209
209
  float sx = length(modelMatrix[0].xyz);
210
210
  float sy = length(modelMatrix[1].xyz);
211
211
  vec4 mvPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);
@@ -272,8 +272,8 @@ void main() {
272
272
  if (alpha < 0.001) discard;
273
273
  gl_FragColor = vec4(uColor, alpha * uOpacity);
274
274
  }
275
- `;function er(a){let{color:t="#FFFFFF",opacity:e=.9,radius:i=4,size:s,depthTest:o=!1,billboard:n=!1}=a;return new Qn({uniforms:{uColor:{value:new co(t).convertLinearToSRGB()},uOpacity:{value:e},uSize:{value:[s.width,s.height]},uRadius:{value:i},uBillboard:{value:n?1:0}},vertexShader:dc,fragmentShader:mc,transparent:!0,depthTest:o,depthWrite:!1,side:Jn,extensions:{derivatives:!0}})}import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-collections.iterator.js";import{LinearFilter as ki,RGBAFormat as ir,Texture as fc,TextureLoader as gc}from"three";var ht=class{static ensureCanvas(){if(this.canvas||(this.canvas=document.createElement("canvas")),this.ctx||(this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0})),!this.ctx)throw new Error("ImgTextureFactory: 2d canvas is not available");return{canvas:this.canvas,ctx:this.ctx}}static getTextureByUrl(t){if(this.urlTextureMap.has(t))return Promise.resolve(this.urlTextureMap.get(t));let e=this.textureLoader.loadAsync(t);return e.then(i=>{i.format=ir,i.magFilter=ki,i.minFilter=ki,i.colorSpace="srgb",this.urlTextureMap.set(t,i)}),this.urlTextureMap.set(t,e),e}static getUrlTextureBorder(t,e,i){let s=t+"-"+i.width+"-"+i.color;if(this.borderUrlTextureMap.has(s))return Promise.resolve(this.borderUrlTextureMap.get(s));let o=this.textureLoader.loadAsync(t).then(n=>{let{ctx:r,canvas:h}=this.ensureCanvas(),c=e+i.width*2;h.width=c,h.height=c;let l=c/2;r.clearRect(0,0,c,c),r.beginPath(),r.arc(l,l,e/2+i.width,0,2*Math.PI),r.fillStyle=i.color,r.fill(),r.beginPath(),r.arc(l,l,e/2,0,2*Math.PI),r.closePath(),r.clip(),r.drawImage(n.image,i.width,i.width,e,e);let p=new fc(h);return p.format=ir,p.magFilter=ki,p.minFilter=ki,p.colorSpace="srgb",p.needsUpdate=!0,this.borderUrlTextureMap.set(s,p),p});return this.borderUrlTextureMap.set(s,o),o}static dispose(){this.urlTextureMap.forEach(t=>{t instanceof Promise?t.then(e=>e.dispose()):t.dispose()}),this.borderUrlTextureMap.forEach(t=>{t instanceof Promise?t.then(e=>e.dispose()):t.dispose()}),this.urlTextureMap.clear(),this.borderUrlTextureMap.clear(),this.canvas&&(this.canvas.width=0,this.canvas.height=0),this.canvas=null,this.ctx=null}};ht.textureLoader=new gc;ht.urlTextureMap=new Map;ht.borderUrlTextureMap=new Map;ht.canvas=null;ht.ctx=null;import"core-js/modules/web.dom-collections.iterator.js";import{GLTFLoader as Pc}from"three/examples/jsm/loaders/GLTFLoader.js";import{clone as Mc}from"three/examples/jsm/utils/SkeletonUtils.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.json.stringify.js";import"core-js/modules/es.error.cause.js";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.url.js";import"core-js/modules/web.url.to-json.js";import"core-js/modules/web.url-search-params.js";import"core-js/modules/web.url-search-params.delete.js";import"core-js/modules/web.url-search-params.has.js";import"core-js/modules/web.url-search-params.size.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.typed-array.int8-array.js";import"core-js/modules/es.typed-array.uint32-array.js";import"core-js/modules/es.typed-array.int16-array.js";import"core-js/modules/es.typed-array.int32-array.js";import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.typed-array.uint16-array.js";var sr=new URL("./icon/parkingSpace/half.svg",import.meta.url).href;var or=new URL("./icon/parkingSpace/power.svg",import.meta.url).href;var nr=new URL("./icon/parkingSpace/mechanical.svg",import.meta.url).href;var rr=new URL("./icon/parkingSpace/vip.svg",import.meta.url).href;var ar=new URL("./icon/parkingSpace/gsadv.svg",import.meta.url).href;var hr=new URL("./glb/locate.glb",import.meta.url).href;var cr=new URL("./icon/path/arrow.png",import.meta.url).href;var lo=new URL("./draco/draco_decoder.js",import.meta.url).href;var po=new URL("./draco/draco_decoder.wasm",import.meta.url).href;var uo=new URL("./draco/draco_wasm_wrapper.js",import.meta.url).href;var Ai={half:sr,power:or,mechanical:nr,vip:rr,gsadv:ar},lr=hr,Di=cr;import{BufferAttribute as pr,BufferGeometry as yc,Color as vc,FileLoader as dr,Loader as xc,LinearSRGBColorSpace as wc,SRGBColorSpace as ur}from"three";var mo=new WeakMap,Ri=class extends xc{setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,s){let o=new dr(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,n=>{this.parse(n,e,s)},i,s)}parse(t,e,i){i===void 0&&(i=()=>{}),this.decodeDracoFile(t,e,null,null,ur).catch(i)}decodeDracoFile(t,e,i,s,o,n){o===void 0&&(o=wc),n===void 0&&(n=()=>{});let r={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:o};return this.decodeGeometry(t,r).then(e).catch(n)}decodeGeometry(t,e){let i=JSON.stringify(e);if(mo.has(t)){let h=mo.get(t);if(h.key===i)return h.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s,o=this.workerNextTaskID++,n=t.byteLength,r=this._getWorker(o,n).then(h=>(s=h,new Promise((c,l)=>{s._callbacks[o]={resolve:c,reject:l},s.postMessage({type:"decode",id:o,taskConfig:e,buffer:t},[t])}))).then(h=>this._createGeometry(h.geometry));return r.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),mo.set(t,{key:i,promise:r}),r}_createGeometry(t){let e=new yc;t.index&&e.setIndex(new pr(t.index.array,1));for(let i=0;i<t.attributes.length;i++){let s=t.attributes[i],o=s.name,n=s.array,r=s.itemSize,h=new pr(n,r);o==="color"&&(this._assignVertexColorSpace(h,s.vertexColorSpace),h.normalized=!(n instanceof Float32Array)),e.setAttribute(o,h)}return e}_assignVertexColorSpace(t,e){if(e!==ur)return;let i=new vc;for(let s=0,o=t.count;s<o;s++)i.fromBufferAttribute(t,s).convertSRGBToLinear(),t.setXYZ(s,i.r,i.g,i.b)}_loadLibrary(t,e){let i=new dr(this.manager);return i.setPath(this.decoderPath),i.setResponseType(e),i.setWithCredentials(this.withCredentials),new Promise((s,o)=>{i.load(t,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary(lo,"text")):(e.push(this._loadLibrary(uo,"text")),e.push(this._loadLibrary(po,"arraybuffer"))),this.decoderPending=Promise.all(e).then(i=>{let s=i[0];t||(this.decoderConfig.wasmBinary=i[1]);let o=_c.toString(),n=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
276
- `);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){let n=o.data;switch(n.type){case"decode":s._callbacks[n.id].resolve(n);break;case"error":s._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}};function _c(){let a,t;onmessage=function(n){let r=n.data;switch(r.type){case"init":a=r.decoderConfig,t=new Promise(function(l){a.onModuleLoaded=function(p){l({draco:p})},DracoDecoderModule(a)});break;case"decode":let h=r.buffer,c=r.taskConfig;t.then(l=>{let p=l.draco,d=new p.Decoder;try{let u=e(p,d,new Int8Array(h),c),f=u.attributes.map(x=>x.array.buffer);u.index&&f.push(u.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:u},f)}catch(u){console.error(u),self.postMessage({type:"error",id:r.id,error:u.message})}finally{p.destroy(d)}});break}};function e(n,r,h,c){let l=c.attributeIDs,p=c.attributeTypes,d,u,f=r.GetEncodedGeometryType(h);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,u=r.DecodeArrayToMesh(h,h.byteLength,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,u=r.DecodeArrayToPointCloud(h,h.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());let x={index:null,attributes:[]};for(let m in l){let y=self[p[m]],_,P;if(c.useUniqueIDs)P=l[m],_=r.GetAttributeByUniqueId(d,P);else{if(P=r.GetAttributeId(d,n[l[m]]),P===-1)continue;_=r.GetAttribute(d,P)}let S=s(n,r,d,m,y,_);m==="color"&&(S.vertexColorSpace=c.vertexColorSpace),x.attributes.push(S)}return f===n.TRIANGULAR_MESH&&(x.index=i(n,r,d)),n.destroy(d),x}function i(n,r,h){let l=h.num_faces()*3,p=l*4,d=n._malloc(p);r.GetTrianglesUInt32Array(h,p,d);let u=new Uint32Array(n.HEAPF32.buffer,d,l).slice();return n._free(d),{array:u,itemSize:1}}function s(n,r,h,c,l,p){let d=p.num_components(),f=h.num_points()*d,x=f*l.BYTES_PER_ELEMENT,m=o(n,l),y=n._malloc(x);r.GetAttributeDataArrayForAllPoints(h,p,m,x,y);let _=new l(n.HEAPF32.buffer,y,f).slice();return n._free(y),{name:c,array:_,itemSize:d}}function o(n,r){switch(r){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var pt=class{static loadModel(t,e){return g(this,null,function*(){if(e===void 0&&(e=!0),e){if(this.modelMap.has(t)){let s=this.modelMap.get(t);return s instanceof Promise?s.then(o=>this.cloneGltf(o)):this.cloneGltf(s)}let i=new Promise((s,o)=>{this.loader.load(t,n=>{this.modelMap.set(t,n),s(n)},void 0,o)});return this.modelMap.set(t,i),i.then(s=>this.cloneGltf(s))}else return new Promise((i,s)=>{this.loader.load(t,i,void 0,s)})})}static cloneGltf(t){return w({},t,{scene:Mc(t.scene)})}static dispose(){this.modelMap.forEach(t=>{t instanceof Promise?t.then(e=>F(e.scene)):F(t.scene)}),this.modelMap.clear()}};pt.dracoLoader=new Ri;pt.loader=new Pc().setDRACOLoader(pt.dracoLoader);pt.modelMap=new Map;function fo(){return new Worker(new URL("./worker/merge-geometry.worker-RWM36Q2L.js",import.meta.url))}import{BufferGeometry as bc,BufferAttribute as mr}from"three";var kt=class{static GetMergeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new bc;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new mr(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new mr(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?w({},t[0],i):null})}static GetMergedGeometryLine(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?w({},t[0],i):null})}static dispose(){this.WorkerPool.dispose()}};kt.WorkerPool=new bi(10,fo);import{cloneDeep as Ac}from"lodash";var At={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9,center_x:0,center_y:0,center_coord_x:0,center_coord_y:0,dashed:!1},Y=class extends Ec{getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new Et,e=new Oi;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new Et(0,0,0);let t=new Oi,e=new Et;return t.setFromObject(this),t.getSize(e),e}getPosition(){let{center_coord_x:t,center_coord_y:e,geometry:i,height:s}=this.options,o=this.getCenter(),n=o.z+s/2;return!t||!e?o.setZ(n):i.type==="point"?new Et(t,e,n+s/2):new Et(t,e,n)}init(){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(){var t;if((t=this.options.doors)!=null&&t.length&&this.options.geometry.type==="polygon"){let e=this.options.geometry.coords[0];this.options.doors.forEach(i=>{let s=i.type==="single"?.5:1,o=.5,n=Vt(e,i.coord),r=new $t(...i.coord),h=new $t(...e[n]).sub(new $t(...i.coord)).normalize(),c=new $t().addVectors(r,h.clone().multiplyScalar(s)),l=new $t().addVectors(r,h.clone().multiplyScalar(-s)),p=new $t(-h.y,h.x),d=new $t().addVectors(c,p.clone().multiplyScalar(o));hn([d.x,d.y],e)||(p.multiplyScalar(-1),d=new $t().addVectors(c,p.clone().multiplyScalar(o)));let u=new $t().addVectors(l,p.clone().multiplyScalar(o)),f=[[c.x,c.y],[d.x,d.y],[u.x,u.y],[l.x,l.y]];e=this.options.geometry.coords[0]=[...e.slice(0,n+1),...f,...e.slice(n+1)]})}}initGeometry(){let t=ui(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new Sc(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=C.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.secondUrl&&ht.getTextureByUrl(this.options.secondUrl).then(i=>{i.wrapS=fr,i.wrapT=fr,i.needsUpdate=!0,t.map=i,t.side=kc}),this.options.height<=.1)return this.material=t,t;let e=C.createMeshBasicMaterial({color:Xt(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getLocalBox(){if(!this.geometry)return new Oi;this.geometry.boundingBox||this.geometry.computeBoundingBox();var t;return(t=this.geometry.boundingBox)!=null?t:new Oi}getGradualEndpoints(t,e){let i=e.clone().normalize(),s=new Et,o=new Et,n=1/0,r=-1/0;for(let h=0;h<8;h++){let c=new Et(h&1?t.max.x:t.min.x,h&2?t.max.y:t.min.y,h&4?t.max.z:t.min.z),l=c.dot(i);l<n&&(n=l,s.copy(c)),l>r&&(r=l,o.copy(c))}return{max:o,min:s}}initGradualMaterial(){let t=this.getLocalBox(),e=new Et(-1,.2,0).normalize(),i=new Et(-1,.2,1).normalize(),{max:s,min:o}=this.getGradualEndpoints(t,e),n=C.createShaderMaterial({gradualColor:this.options.gradualColor,opacity:this.options.fillOpacity,max:s,min:o});if(this.options.height<=.1)return this.material=n,n;let{max:r,min:h}=this.getGradualEndpoints(t,i),c=C.createShaderMaterial({gradualColor:[Xt(this.options.gradualColor[0],this.options.colorFactor),Xt(this.options.gradualColor[1],this.options.colorFactor)],opacity:this.options.fillOpacity,max:r,min:h});return this.material=[n,c],[n,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){if(this.options.dashed){let t=C.createLineDashedMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}else{let t=C.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Cc(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 s=0;s<i.length;s++){let o=i[s];for(let n=0;n<o.length;n++){let r=o[n],h=n+1===o.length?o[0]:o[n+1];t.push(new Et(r[0],r[1],e)),t.push(new Et(h[0],h[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new Tc().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new Lc(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.options.dashed&&t.computeLineDistances(),this.line=t,this.add(t),t}setOpacity(t,e){if(e===void 0&&(e=!1),e)this.options.fillOpacity=t,this.options.strokeOpacity=t;else{let{fillOpacity:i,strokeOpacity:s}=this.originOptions;this.options.fillOpacity=Math.min(i,t),this.options.strokeOpacity=Math.min(s,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:s}=e[0];return{position:i,distance:s}}return!1}dispose(){var t,e;(t=this.geometry)==null||t.dispose(),(e=this.line)==null||e.geometry.dispose(),this.clear()}constructor(t,e){if(super(),this.context=t,this.line=null,this.options=ye(Ac(w({},At,e)),this),this.originOptions={fillOpacity:this.options.fillOpacity,strokeOpacity:this.options.strokeOpacity},this.options.geometry.type==="point"){let[i,s]=this.options.geometry.coords;return this.position.set(i,s,this.options.height+this.options.airHeight),this}this.initDoor(),this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",i=>{let{value:s}=i;this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",i=>{let{value:s}=i;this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",i=>{let{value:s}=i;this.dispose(),this.init()}),this.addEventListener("change-strokeColor",i=>{let{value:s}=i;!this.options.stroke||!this.options.strokeOpacity||(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",i=>{let{value:s}=i;if(this.options.stroke)if(s)this.lineGeometry||this.initLineGeometry(),this.initLineMaterial(),this.createBorder();else{var o;this.line&&(this.remove(this.line),this.line=null),(o=this.lineGeometry)==null||o.dispose(),this.lineGeometry=void 0}}),this.addEventListener("change-airHeight",i=>{let{value:s}=i;this.position.z=s}),this.addEventListener("change-visible",i=>{let{value:s}=i;this.visible=s}),this.addEventListener("change-stroke",i=>{let{value:s}=i;if(s){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else if(this.line){var o;this.remove(this.line),(o=this.lineGeometry)==null||o.dispose()}}),this.addEventListener("change-dashed",()=>{!this.options.stroke||!this.options.strokeOpacity||(this.lineGeometry||this.initLineGeometry(),this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}};import{Object3D as Dc,PlaneGeometry as Rc,Mesh as Oc,ShadowMaterial as Fc,Color as Ic,DoubleSide as Gc}from"three";var Fi=class extends Dc{initLight(){let t=rn(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new Ic(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t,e){t===void 0&&(t=1e3),e===void 0&&(e=1e3);let i=new Rc(t,e),s=new Fc({transparent:!0,opacity:0,side:Gc}),o=new Oc(i,s);return o.receiveShadow=!0,o.position.z=-10,this.add(o),this.plane=o,o}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){F(this,!0)}constructor(){super(),this.basicOpacity=.07,this.directionalLight=this.initLight(),this.initPlane()}};import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as Wc,Vector3 as Uc}from"three";import{Box3 as gr,Vector3 as ot}from"three";import{debounce as Bc}from"lodash";var zc={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},Ee=class extends st{initObserver(){let t=new MutationObserver(Bc(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){var t,e;if(this.element instanceof Y&&this.element.options.geometry.type==="polygon"){let{max:n,min:r}=new gr().setFromObject(this.element),h=(n.x+r.x)/2,c=(n.y+r.y)/2;return{left:new ot(r.x,c,n.z),leftTop:new ot(r.x,n.y,n.z),top:new ot(h,n.y,n.z),rightTop:new ot(n.x,n.y,n.z),right:new ot(n.x,c,n.z),rightBottom:new ot(n.x,r.y,n.z),bottom:new ot(h,r.y,n.z),leftBottom:new ot(r.x,r.y,n.z),center:new ot(h,c,n.z)}}let{x:i,y:s,z:o}=((e=this.element)==null||(t=e.getPosition)==null?void 0:t.call(e))||this.position;return{left:new ot(i,s,o),leftTop:new ot(i,s,o),top:new ot(i,s,o),rightTop:new ot(i,s,o),right:new ot(i,s,o),rightBottom:new ot(i,s,o),bottom:new ot(i,s,o),leftBottom:new ot(i,s,o),center:new ot(i,s,o)}}getPlacementScreenPosition(){let{width:t,height:e}=this.context.clientSize,i=this.getPlacementPosition();return Object.keys(i).reduce((s,o)=>{let{x:n,y:r}=L(i[o],this.context.camera,t,e);return s[o]={x:n,y:r},s},{})}checkOverflow(t,e){let{width:i,height:s}=this.context.clientSize;return e.x>0&&t.x<i&&e.y<s&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:e}=this.div,i=this.getPlacementScreenPosition(),s=t/2,o=e/2,n=[{type:"center",getBox(r,h){return{max:{x:s+r,y:h-e},min:{x:r-s,y:h}}}},{type:"left",getBox(r,h){return{max:{x:r,y:h-o},min:{x:r-t,y:h+o}}}},{type:"leftTop",getBox(r,h){return{max:{x:r,y:h-e},min:{x:r-t,y:h}}}},{type:"top",getBox(r,h){return{max:{x:r+s,y:h-e},min:{x:r-s,y:h}}}},{type:"rightTop",getBox(r,h){return{max:{x:r+t,y:h-e},min:{x:r,y:h}}}},{type:"right",getBox(r,h){return{max:{x:r+t,y:h-o},min:{x:r,y:h+o}}}},{type:"rightBottom",getBox(r,h){return{max:{x:r+t,y:h},min:{x:r,y:h+e}}}},{type:"bottom",getBox(r,h){return{max:{x:r+s,y:h},min:{x:r-s,y:h+e}}}},{type:"leftBottom",getBox(r,h){return{max:{x:r,y:h},min:{x:r-t,y:h+o}}}}];for(let r=0;r<n.length;r++){let h=n[r],c=i[h.type],{max:l,min:p}=h.getBox(c.x,c.y);if(this.checkOverflow(l,p))return{type:h.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){e===void 0&&(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 gr().setFromObject(this.element).getCenter(new ot):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:s}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=s}_updatePosition(t,e){this.clientPos={x:t,y:e};let{width:i,height:s,x:o,y:n}=this.context.clientSize;if(this.div){if(this.options.appendToBody){this.div.style.left=""+o+"px",this.div.style.top=""+(n+s)+"px";return}this.options.autoUpdate?(this.div.style.left=""+t+"px",this.div.style.bottom=""+(s-e)+"px"):this.dispatchEvent({type:"update-position",x:t,y:e,width:i,height:s})}}updatePosition(t){t===void 0&&(t=!1);let e=this.getPosition(),{width:i,height:s}=this.context.clientSize,{x:o,y:n}=L(e,this.context.camera,i,s);this.clientPos.x===o&&this.clientPos.y===n&&!t||this._updatePosition(o,n)}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t,e;super.dispose(),this.unRegistryEvent(),this.unBindElement(),(t=this.observer)==null||t.disconnect(),(e=this.div)==null||e.remove(),this.div=null}constructor(t,e={}){super(),this.context=t,this.position=new ot,this.clientPos={x:0,y:0},this.visible=!0,this.placement="top",this.observer=null,this.onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()},this.options=w({},zc,e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}};var Hc={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},ce=class extends Wc{get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return g(this,null,function*(){if(yield ln(),!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[s,o]of Object.entries(e.styles))i.style[s]=o;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var t,e;let i=document.createElement("img");return i.setAttribute("src",this.options.icon),i.style.width=""+(((t=this.options.icon_size)==null?void 0:t[0])||32)+"px",i.style.height=""+(((e=this.options.icon_size)==null?void 0:e[1])||32)+"px",i.style.opacity=""+this.options.icon_opacity+"px",i.style.borderRadius="50%",this.options.icon_border.width&&(i.style.border=this.options.icon_border.width+"px solid "+this.options.icon_border.color),i.onload=()=>{this.resetSize()},this.img=i,i}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){t===void 0&&(t=this.context.config.poi.boxScale);let{width:e,height:i}=this.size,s=e*t,o=i*t,{x:n,y:r}=this.overlay.clientPos;return{left:n-s/2,right:n+s/2,top:this.options.icon?r-o:r-o/2,bottom:this.options.icon?r:r+o/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}constructor(t,e){var i,s,o;super(),this.context=t,this.visible=!0,this.size={width:0,height:0},this.position=new Uc,this.userData={},this.showTextStatus=!0,this.disposed=!1,this._changePosition=()=>{this.overlay.updatePosition(!0)},this.options=ye(w({},Hc,e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((s=e.position)==null?void 0:s.y)||0,((o=e.position)==null?void 0:o.z)||0),this.overlay=new Ee(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",n=>{let{x:r,y:h,height:c}=n;this.overlay.div.style.transform="translate3d(calc("+r+"px - 50%), calc("+(-c+h)+"px - "+(this.options.icon&&this.options.icon_position!=="center"?"100%":"50%")+"), 0)"}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",n=>{let{value:r}=n;r?this.img?this.img.setAttribute("src",r):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",n=>{let{value:r}=n,h=this.textDiv;if(h){let c=this.initText();this.div.replaceChild(c,h)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",n=>{let{value:r}=n;this.overlay.setOpacity(r)}),this.addEventListener("change-icon_size",n=>{let{value:r}=n;this.img&&(this.img.style.width=""+((r==null?void 0:r[0])||32)+"px",this.img.style.height=""+((r==null?void 0:r[1])||32)+"px",this.resetSize())}),this.addEventListener("change-icon_opacity",n=>{let{value:r}=n;this.img&&(this.img.style.opacity=""+r)}),this.addEventListener("change-icon_border",n=>{let{value:r}=n;this.img&&(this.img.style.border=r.width+"px solid "+r.color)}),this.addEventListener("change-background",n=>{let{value:r}=n;this.div.style.background=r})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import{Box3 as wo,Object3D as _o,Vector3 as Xi}from"three";import{Object3D as Nc,Vector3 as Zc}from"three";var Ii=class extends Nc{loadModel(){return g(this,null,function*(){let t=yield pt.loadModel(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t})}dispose(){F(this),this.model=null}constructor(t,e){super(),this.context=t,this.options=e,this.model=null,this.position.copy(e.position||new Zc(0,0,0)),this.loadModel()}};import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Vc,Vector3 as Kc}from"three";import{Object3D as jc}from"three";var q=class extends jc{setOpacity(t,e){e===void 0&&(e=!1),this.children.forEach(i=>{i.setOpacity==null||i.setOpacity.call(i,t,e)})}onAddToScene(t){this.active=!0,this.sceneType=t}onRemoveFromScene(){this.active=!1}dispose(){F(this),this.children.forEach(t=>t.dispose==null?void 0:t.dispose.call(t)),this.clear()}constructor(t){super(),this.context=t,this.active=!1,this.sceneType="scene"}};var Gi=class extends q{getCenter(){return new Vc().setFromObject(this).getCenter(new Kc)}createGraphic(t){let e=new Y(this.context,t);return e.userData.data=t,this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1/0,graphic:null,position:null},i=this.children.reduce((s,o)=>{if(o instanceof Y){let n=o.raycast(t);if(n){let{distance:r}=n;if(r<s.distance)return{distance:n.distance,position:n.position,graphic:o}}return s}else return s},e);return i===e?{graphics:[],position:null,distance:1/0}:{graphics:[i.graphic],position:i.position,distance:i.distance}}setGraphicOptions(t,e){let i,s=this.graphicMap.get(t);s&&(typeof e=="function"?i=e(s.options):i=w({},s.options,e),Object.keys(i).forEach(o=>{s.options[o]=i[o]}))}getGraphicPosition(t){let e=this.graphicMap.get(t);return e?[e.options.center_x,e.options.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1),this.graphicMap.forEach(i=>{i.setOpacity(t,e)})}constructor(t){super(t),this.graphicMap=new Map}};import"core-js/modules/es.array.unshift.js";import"core-js/modules/es.array.push.js";import{debounce as Xc}from"lodash";var Bi=class extends q{clear(t){return t===void 0&&(t=!1),this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new ce(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===0){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(s=>s instanceof ce&&s.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,s)=>{let{left:o,right:n,top:r,bottom:h}=i.getBox();if(s===0||!i.options.collision_enable){t.push({left:o,right:n,top:r,bottom:h}),i.parentSetVisible(!0);return}let c=t.some(l=>l.left<n&&l.right>o&&l.top<h&&l.bottom>r);i.parentSetVisible(!c),c||t.push({left:o,right:n,top:r,bottom:h})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}constructor(t){super(t),this.pois=[],this.timer=new K,this.onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})},this.registryEvent(),this.debounceCollisionDetection=Xc(this.collisionDetection,10)}};import"core-js/modules/es.array.push.js";import{Vector2 as ul}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import{Color as yr,DoubleSide as Yc,InstancedBufferAttribute as $e,InstancedBufferGeometry as qc,Mesh as $c,Object3D as Jc,PlaneGeometry as Qc,ShaderMaterial as tl}from"three";var el="#000000",il="#ffffff",sl=`
275
+ `;function er(a){let{color:t="#FFFFFF",opacity:e=.9,radius:i=4,size:s,depthTest:o=!1,billboard:n=!1}=a;return new Qn({uniforms:{uColor:{value:new co(t).convertLinearToSRGB()},uOpacity:{value:e},uSize:{value:[s.width,s.height]},uRadius:{value:i},uBillboard:{value:n?1:0}},vertexShader:dc,fragmentShader:mc,transparent:!0,depthTest:o,depthWrite:!1,side:Jn,extensions:{derivatives:!0}})}import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-collections.iterator.js";import{LinearFilter as ki,RGBAFormat as ir,Texture as fc,TextureLoader as gc}from"three";var ht=class{static ensureCanvas(){if(this.canvas||(this.canvas=document.createElement("canvas")),this.ctx||(this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0})),!this.ctx)throw new Error("ImgTextureFactory: 2d canvas is not available");return{canvas:this.canvas,ctx:this.ctx}}static getTextureByUrl(t){if(this.urlTextureMap.has(t))return Promise.resolve(this.urlTextureMap.get(t));let e=this.textureLoader.loadAsync(t);return e.then(i=>{i.format=ir,i.magFilter=ki,i.minFilter=ki,i.colorSpace="srgb",this.urlTextureMap.set(t,i)}),this.urlTextureMap.set(t,e),e}static getUrlTextureBorder(t,e,i){let s=t+"-"+i.width+"-"+i.color;if(this.borderUrlTextureMap.has(s))return Promise.resolve(this.borderUrlTextureMap.get(s));let o=this.textureLoader.loadAsync(t).then(n=>{let{ctx:r,canvas:h}=this.ensureCanvas(),c=e+i.width*2;h.width=c,h.height=c;let l=c/2;r.clearRect(0,0,c,c),r.beginPath(),r.arc(l,l,e/2+i.width,0,2*Math.PI),r.fillStyle=i.color,r.fill(),r.beginPath(),r.arc(l,l,e/2,0,2*Math.PI),r.closePath(),r.clip(),r.drawImage(n.image,i.width,i.width,e,e);let p=new fc(h);return p.format=ir,p.magFilter=ki,p.minFilter=ki,p.colorSpace="srgb",p.needsUpdate=!0,this.borderUrlTextureMap.set(s,p),p});return this.borderUrlTextureMap.set(s,o),o}static dispose(){this.urlTextureMap.forEach(t=>{t instanceof Promise?t.then(e=>e.dispose()):t.dispose()}),this.borderUrlTextureMap.forEach(t=>{t instanceof Promise?t.then(e=>e.dispose()):t.dispose()}),this.urlTextureMap.clear(),this.borderUrlTextureMap.clear(),this.canvas&&(this.canvas.width=0,this.canvas.height=0),this.canvas=null,this.ctx=null}};ht.textureLoader=new gc;ht.urlTextureMap=new Map;ht.borderUrlTextureMap=new Map;ht.canvas=null;ht.ctx=null;import"core-js/modules/web.dom-collections.iterator.js";import{GLTFLoader as Pc}from"three/examples/jsm/loaders/GLTFLoader.js";import{clone as bc}from"three/examples/jsm/utils/SkeletonUtils.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.json.stringify.js";import"core-js/modules/es.error.cause.js";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.url.js";import"core-js/modules/web.url.to-json.js";import"core-js/modules/web.url-search-params.js";import"core-js/modules/web.url-search-params.delete.js";import"core-js/modules/web.url-search-params.has.js";import"core-js/modules/web.url-search-params.size.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.typed-array.int8-array.js";import"core-js/modules/es.typed-array.uint32-array.js";import"core-js/modules/es.typed-array.int16-array.js";import"core-js/modules/es.typed-array.int32-array.js";import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.typed-array.uint16-array.js";var sr=new URL("./icon/parkingSpace/half.svg",import.meta.url).href;var or=new URL("./icon/parkingSpace/power.svg",import.meta.url).href;var nr=new URL("./icon/parkingSpace/mechanical.svg",import.meta.url).href;var rr=new URL("./icon/parkingSpace/vip.svg",import.meta.url).href;var ar=new URL("./icon/parkingSpace/gsadv.svg",import.meta.url).href;var hr=new URL("./glb/locate.glb",import.meta.url).href;var cr=new URL("./icon/path/arrow.png",import.meta.url).href;var lo=new URL("./draco/draco_decoder.js",import.meta.url).href;var po=new URL("./draco/draco_decoder.wasm",import.meta.url).href;var uo=new URL("./draco/draco_wasm_wrapper.js",import.meta.url).href;var Ai={half:sr,power:or,mechanical:nr,vip:rr,gsadv:ar},lr=hr,Di=cr;import{BufferAttribute as pr,BufferGeometry as yc,Color as vc,FileLoader as dr,Loader as xc,LinearSRGBColorSpace as wc,SRGBColorSpace as ur}from"three";var mo=new WeakMap,Ri=class extends xc{setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,s){let o=new dr(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,n=>{this.parse(n,e,s)},i,s)}parse(t,e,i){i===void 0&&(i=()=>{}),this.decodeDracoFile(t,e,null,null,ur).catch(i)}decodeDracoFile(t,e,i,s,o,n){o===void 0&&(o=wc),n===void 0&&(n=()=>{});let r={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:o};return this.decodeGeometry(t,r).then(e).catch(n)}decodeGeometry(t,e){let i=JSON.stringify(e);if(mo.has(t)){let h=mo.get(t);if(h.key===i)return h.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s,o=this.workerNextTaskID++,n=t.byteLength,r=this._getWorker(o,n).then(h=>(s=h,new Promise((c,l)=>{s._callbacks[o]={resolve:c,reject:l},s.postMessage({type:"decode",id:o,taskConfig:e,buffer:t},[t])}))).then(h=>this._createGeometry(h.geometry));return r.catch(()=>!0).then(()=>{s&&o&&this._releaseTask(s,o)}),mo.set(t,{key:i,promise:r}),r}_createGeometry(t){let e=new yc;t.index&&e.setIndex(new pr(t.index.array,1));for(let i=0;i<t.attributes.length;i++){let s=t.attributes[i],o=s.name,n=s.array,r=s.itemSize,h=new pr(n,r);o==="color"&&(this._assignVertexColorSpace(h,s.vertexColorSpace),h.normalized=!(n instanceof Float32Array)),e.setAttribute(o,h)}return e}_assignVertexColorSpace(t,e){if(e!==ur)return;let i=new vc;for(let s=0,o=t.count;s<o;s++)i.fromBufferAttribute(t,s).convertSRGBToLinear(),t.setXYZ(s,i.r,i.g,i.b)}_loadLibrary(t,e){let i=new dr(this.manager);return i.setPath(this.decoderPath),i.setResponseType(e),i.setWithCredentials(this.withCredentials),new Promise((s,o)=>{i.load(t,s,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary(lo,"text")):(e.push(this._loadLibrary(uo,"text")),e.push(this._loadLibrary(po,"arraybuffer"))),this.decoderPending=Promise.all(e).then(i=>{let s=i[0];t||(this.decoderConfig.wasmBinary=i[1]);let o=_c.toString(),n=["/* draco decoder */",s,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
276
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(o){let n=o.data;switch(n.type){case"decode":s._callbacks[n.id].resolve(n);break;case"error":s._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,o){return s._taskLoad>o._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}};function _c(){let a,t;onmessage=function(n){let r=n.data;switch(r.type){case"init":a=r.decoderConfig,t=new Promise(function(l){a.onModuleLoaded=function(p){l({draco:p})},DracoDecoderModule(a)});break;case"decode":let h=r.buffer,c=r.taskConfig;t.then(l=>{let p=l.draco,d=new p.Decoder;try{let u=e(p,d,new Int8Array(h),c),f=u.attributes.map(x=>x.array.buffer);u.index&&f.push(u.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:u},f)}catch(u){console.error(u),self.postMessage({type:"error",id:r.id,error:u.message})}finally{p.destroy(d)}});break}};function e(n,r,h,c){let l=c.attributeIDs,p=c.attributeTypes,d,u,f=r.GetEncodedGeometryType(h);if(f===n.TRIANGULAR_MESH)d=new n.Mesh,u=r.DecodeArrayToMesh(h,h.byteLength,d);else if(f===n.POINT_CLOUD)d=new n.PointCloud,u=r.DecodeArrayToPointCloud(h,h.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());let x={index:null,attributes:[]};for(let m in l){let y=self[p[m]],_,P;if(c.useUniqueIDs)P=l[m],_=r.GetAttributeByUniqueId(d,P);else{if(P=r.GetAttributeId(d,n[l[m]]),P===-1)continue;_=r.GetAttribute(d,P)}let S=s(n,r,d,m,y,_);m==="color"&&(S.vertexColorSpace=c.vertexColorSpace),x.attributes.push(S)}return f===n.TRIANGULAR_MESH&&(x.index=i(n,r,d)),n.destroy(d),x}function i(n,r,h){let l=h.num_faces()*3,p=l*4,d=n._malloc(p);r.GetTrianglesUInt32Array(h,p,d);let u=new Uint32Array(n.HEAPF32.buffer,d,l).slice();return n._free(d),{array:u,itemSize:1}}function s(n,r,h,c,l,p){let d=p.num_components(),f=h.num_points()*d,x=f*l.BYTES_PER_ELEMENT,m=o(n,l),y=n._malloc(x);r.GetAttributeDataArrayForAllPoints(h,p,m,x,y);let _=new l(n.HEAPF32.buffer,y,f).slice();return n._free(y),{name:c,array:_,itemSize:d}}function o(n,r){switch(r){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var pt=class{static loadModel(t,e){return g(this,null,function*(){if(e===void 0&&(e=!0),e){if(this.modelMap.has(t)){let s=this.modelMap.get(t);return s instanceof Promise?s.then(o=>this.cloneGltf(o)):this.cloneGltf(s)}let i=new Promise((s,o)=>{this.loader.load(t,n=>{this.modelMap.set(t,n),s(n)},void 0,o)});return this.modelMap.set(t,i),i.then(s=>this.cloneGltf(s))}else return new Promise((i,s)=>{this.loader.load(t,i,void 0,s)})})}static cloneGltf(t){return w({},t,{scene:bc(t.scene)})}static dispose(){this.modelMap.forEach(t=>{t instanceof Promise?t.then(e=>F(e.scene)):F(t.scene)}),this.modelMap.clear()}};pt.dracoLoader=new Ri;pt.loader=new Pc().setDRACOLoader(pt.dracoLoader);pt.modelMap=new Map;function fo(){return new Worker(new URL("./worker/merge-geometry.worker-RWM36Q2L.js",import.meta.url))}import{BufferGeometry as Mc,BufferAttribute as mr}from"three";var kt=class{static GetMergeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Mc;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new mr(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new mr(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?w({},t[0],i):null})}static GetMergedGeometryLine(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield H(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?w({},t[0],i):null})}static dispose(){this.WorkerPool.dispose()}};kt.WorkerPool=new Mi(10,fo);import{cloneDeep as Ac}from"lodash";var At={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9,center_x:0,center_y:0,center_coord_x:0,center_coord_y:0,dashed:!1},Y=class extends Ec{getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new Et,e=new Oi;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new Et(0,0,0);let t=new Oi,e=new Et;return t.setFromObject(this),t.getSize(e),e}getPosition(){let{center_coord_x:t,center_coord_y:e,geometry:i,height:s}=this.options,o=this.getCenter(),n=o.z+s/2;return!t||!e?o.setZ(n):i.type==="point"?new Et(t,e,n+s/2):new Et(t,e,n)}init(){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(){var t;if((t=this.options.doors)!=null&&t.length&&this.options.geometry.type==="polygon"){let e=this.options.geometry.coords[0];this.options.doors.forEach(i=>{let s=i.type==="single"?.5:1,o=.5,n=Vt(e,i.coord),r=new $t(...i.coord),h=new $t(...e[n]).sub(new $t(...i.coord)).normalize(),c=new $t().addVectors(r,h.clone().multiplyScalar(s)),l=new $t().addVectors(r,h.clone().multiplyScalar(-s)),p=new $t(-h.y,h.x),d=new $t().addVectors(c,p.clone().multiplyScalar(o));hn([d.x,d.y],e)||(p.multiplyScalar(-1),d=new $t().addVectors(c,p.clone().multiplyScalar(o)));let u=new $t().addVectors(l,p.clone().multiplyScalar(o)),f=[[c.x,c.y],[d.x,d.y],[u.x,u.y],[l.x,l.y]];e=this.options.geometry.coords[0]=[...e.slice(0,n+1),...f,...e.slice(n+1)]})}}initGeometry(){let t=ui(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new Sc(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=C.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.secondUrl&&ht.getTextureByUrl(this.options.secondUrl).then(i=>{i.wrapS=fr,i.wrapT=fr,i.needsUpdate=!0,t.map=i,t.side=kc}),this.options.height<=.1)return this.material=t,t;let e=C.createMeshBasicMaterial({color:Xt(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getLocalBox(){if(!this.geometry)return new Oi;this.geometry.boundingBox||this.geometry.computeBoundingBox();var t;return(t=this.geometry.boundingBox)!=null?t:new Oi}getGradualEndpoints(t,e){let i=e.clone().normalize(),s=new Et,o=new Et,n=1/0,r=-1/0;for(let h=0;h<8;h++){let c=new Et(h&1?t.max.x:t.min.x,h&2?t.max.y:t.min.y,h&4?t.max.z:t.min.z),l=c.dot(i);l<n&&(n=l,s.copy(c)),l>r&&(r=l,o.copy(c))}return{max:o,min:s}}initGradualMaterial(){let t=this.getLocalBox(),e=new Et(-1,.2,0).normalize(),i=new Et(-1,.2,1).normalize(),{max:s,min:o}=this.getGradualEndpoints(t,e),n=C.createShaderMaterial({gradualColor:this.options.gradualColor,opacity:this.options.fillOpacity,max:s,min:o});if(this.options.height<=.1)return this.material=n,n;let{max:r,min:h}=this.getGradualEndpoints(t,i),c=C.createShaderMaterial({gradualColor:[Xt(this.options.gradualColor[0],this.options.colorFactor),Xt(this.options.gradualColor[1],this.options.colorFactor)],opacity:this.options.fillOpacity,max:r,min:h});return this.material=[n,c],[n,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){if(this.options.dashed){let t=C.createLineDashedMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}else{let t=C.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Cc(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 s=0;s<i.length;s++){let o=i[s];for(let n=0;n<o.length;n++){let r=o[n],h=n+1===o.length?o[0]:o[n+1];t.push(new Et(r[0],r[1],e)),t.push(new Et(h[0],h[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new Tc().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new Lc(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.options.dashed&&t.computeLineDistances(),this.line=t,this.add(t),t}setOpacity(t,e){if(e===void 0&&(e=!1),e)this.options.fillOpacity=t,this.options.strokeOpacity=t;else{let{fillOpacity:i,strokeOpacity:s}=this.originOptions;this.options.fillOpacity=Math.min(i,t),this.options.strokeOpacity=Math.min(s,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:s}=e[0];return{position:i,distance:s}}return!1}dispose(){var t,e;(t=this.geometry)==null||t.dispose(),(e=this.line)==null||e.geometry.dispose(),this.clear()}constructor(t,e){if(super(),this.context=t,this.line=null,this.options=ye(Ac(w({},At,e)),this),this.originOptions={fillOpacity:this.options.fillOpacity,strokeOpacity:this.options.strokeOpacity},this.options.geometry.type==="point"){let[i,s]=this.options.geometry.coords;return this.position.set(i,s,this.options.height+this.options.airHeight),this}this.initDoor(),this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",i=>{let{value:s}=i;this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",i=>{let{value:s}=i;this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",i=>{let{value:s}=i;this.dispose(),this.init()}),this.addEventListener("change-strokeColor",i=>{let{value:s}=i;!this.options.stroke||!this.options.strokeOpacity||(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",i=>{let{value:s}=i;if(this.options.stroke)if(s)this.lineGeometry||this.initLineGeometry(),this.initLineMaterial(),this.createBorder();else{var o;this.line&&(this.remove(this.line),this.line=null),(o=this.lineGeometry)==null||o.dispose(),this.lineGeometry=void 0}}),this.addEventListener("change-airHeight",i=>{let{value:s}=i;this.position.z=s}),this.addEventListener("change-visible",i=>{let{value:s}=i;this.visible=s}),this.addEventListener("change-stroke",i=>{let{value:s}=i;if(s){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else if(this.line){var o;this.remove(this.line),(o=this.lineGeometry)==null||o.dispose()}}),this.addEventListener("change-dashed",()=>{!this.options.stroke||!this.options.strokeOpacity||(this.lineGeometry||this.initLineGeometry(),this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}};import{Object3D as Dc,PlaneGeometry as Rc,Mesh as Oc,ShadowMaterial as Fc,Color as Ic,DoubleSide as Gc}from"three";var Fi=class extends Dc{initLight(){let t=rn(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new Ic(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t,e){t===void 0&&(t=1e3),e===void 0&&(e=1e3);let i=new Rc(t,e),s=new Fc({transparent:!0,opacity:0,side:Gc}),o=new Oc(i,s);return o.receiveShadow=!0,o.position.z=-10,this.add(o),this.plane=o,o}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){F(this,!0)}constructor(){super(),this.basicOpacity=.07,this.directionalLight=this.initLight(),this.initPlane()}};import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as Wc,Vector3 as Uc}from"three";import{Box3 as gr,Vector3 as ot}from"three";import{debounce as Bc}from"lodash";var zc={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},Ee=class extends st{initObserver(){let t=new MutationObserver(Bc(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){var t,e;if(this.element instanceof Y&&this.element.options.geometry.type==="polygon"){let{max:n,min:r}=new gr().setFromObject(this.element),h=(n.x+r.x)/2,c=(n.y+r.y)/2;return{left:new ot(r.x,c,n.z),leftTop:new ot(r.x,n.y,n.z),top:new ot(h,n.y,n.z),rightTop:new ot(n.x,n.y,n.z),right:new ot(n.x,c,n.z),rightBottom:new ot(n.x,r.y,n.z),bottom:new ot(h,r.y,n.z),leftBottom:new ot(r.x,r.y,n.z),center:new ot(h,c,n.z)}}let{x:i,y:s,z:o}=((e=this.element)==null||(t=e.getPosition)==null?void 0:t.call(e))||this.position;return{left:new ot(i,s,o),leftTop:new ot(i,s,o),top:new ot(i,s,o),rightTop:new ot(i,s,o),right:new ot(i,s,o),rightBottom:new ot(i,s,o),bottom:new ot(i,s,o),leftBottom:new ot(i,s,o),center:new ot(i,s,o)}}getPlacementScreenPosition(){let{width:t,height:e}=this.context.clientSize,i=this.getPlacementPosition();return Object.keys(i).reduce((s,o)=>{let{x:n,y:r}=L(i[o],this.context.camera,t,e);return s[o]={x:n,y:r},s},{})}checkOverflow(t,e){let{width:i,height:s}=this.context.clientSize;return e.x>0&&t.x<i&&e.y<s&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:e}=this.div,i=this.getPlacementScreenPosition(),s=t/2,o=e/2,n=[{type:"center",getBox(r,h){return{max:{x:s+r,y:h-e},min:{x:r-s,y:h}}}},{type:"left",getBox(r,h){return{max:{x:r,y:h-o},min:{x:r-t,y:h+o}}}},{type:"leftTop",getBox(r,h){return{max:{x:r,y:h-e},min:{x:r-t,y:h}}}},{type:"top",getBox(r,h){return{max:{x:r+s,y:h-e},min:{x:r-s,y:h}}}},{type:"rightTop",getBox(r,h){return{max:{x:r+t,y:h-e},min:{x:r,y:h}}}},{type:"right",getBox(r,h){return{max:{x:r+t,y:h-o},min:{x:r,y:h+o}}}},{type:"rightBottom",getBox(r,h){return{max:{x:r+t,y:h},min:{x:r,y:h+e}}}},{type:"bottom",getBox(r,h){return{max:{x:r+s,y:h},min:{x:r-s,y:h+e}}}},{type:"leftBottom",getBox(r,h){return{max:{x:r,y:h},min:{x:r-t,y:h+o}}}}];for(let r=0;r<n.length;r++){let h=n[r],c=i[h.type],{max:l,min:p}=h.getBox(c.x,c.y);if(this.checkOverflow(l,p))return{type:h.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){e===void 0&&(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 gr().setFromObject(this.element).getCenter(new ot):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:s}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=s}_updatePosition(t,e){this.clientPos={x:t,y:e};let{width:i,height:s,x:o,y:n}=this.context.clientSize;if(this.div){if(this.options.appendToBody){this.div.style.left=""+o+"px",this.div.style.top=""+(n+s)+"px";return}this.options.autoUpdate?(this.div.style.left=""+t+"px",this.div.style.bottom=""+(s-e)+"px"):this.dispatchEvent({type:"update-position",x:t,y:e,width:i,height:s})}}updatePosition(t){t===void 0&&(t=!1);let e=this.getPosition(),{width:i,height:s}=this.context.clientSize,{x:o,y:n}=L(e,this.context.camera,i,s);this.clientPos.x===o&&this.clientPos.y===n&&!t||this._updatePosition(o,n)}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t,e;super.dispose(),this.unRegistryEvent(),this.unBindElement(),(t=this.observer)==null||t.disconnect(),(e=this.div)==null||e.remove(),this.div=null}constructor(t,e={}){super(),this.context=t,this.position=new ot,this.clientPos={x:0,y:0},this.visible=!0,this.placement="top",this.observer=null,this.onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()},this.options=w({},zc,e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}};var Hc={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},ce=class extends Wc{get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return g(this,null,function*(){if(yield ln(),!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[s,o]of Object.entries(e.styles))i.style[s]=o;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var t,e;let i=document.createElement("img");return i.setAttribute("src",this.options.icon),i.style.width=""+(((t=this.options.icon_size)==null?void 0:t[0])||32)+"px",i.style.height=""+(((e=this.options.icon_size)==null?void 0:e[1])||32)+"px",i.style.opacity=""+this.options.icon_opacity+"px",i.style.borderRadius="50%",this.options.icon_border.width&&(i.style.border=this.options.icon_border.width+"px solid "+this.options.icon_border.color),i.onload=()=>{this.resetSize()},this.img=i,i}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){t===void 0&&(t=this.context.config.poi.boxScale);let{width:e,height:i}=this.size,s=e*t,o=i*t,{x:n,y:r}=this.overlay.clientPos;return{left:n-s/2,right:n+s/2,top:this.options.icon?r-o:r-o/2,bottom:this.options.icon?r:r+o/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}constructor(t,e){var i,s,o;super(),this.context=t,this.visible=!0,this.size={width:0,height:0},this.position=new Uc,this.userData={},this.showTextStatus=!0,this.disposed=!1,this._changePosition=()=>{this.overlay.updatePosition(!0)},this.options=ye(w({},Hc,e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((s=e.position)==null?void 0:s.y)||0,((o=e.position)==null?void 0:o.z)||0),this.overlay=new Ee(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",n=>{let{x:r,y:h,height:c}=n;this.overlay.div.style.transform="translate3d(calc("+r+"px - 50%), calc("+(-c+h)+"px - "+(this.options.icon&&this.options.icon_position!=="center"?"100%":"50%")+"), 0)"}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",n=>{let{value:r}=n;r?this.img?this.img.setAttribute("src",r):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",n=>{let{value:r}=n,h=this.textDiv;if(h){let c=this.initText();this.div.replaceChild(c,h)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",n=>{let{value:r}=n;this.overlay.setOpacity(r)}),this.addEventListener("change-icon_size",n=>{let{value:r}=n;this.img&&(this.img.style.width=""+((r==null?void 0:r[0])||32)+"px",this.img.style.height=""+((r==null?void 0:r[1])||32)+"px",this.resetSize())}),this.addEventListener("change-icon_opacity",n=>{let{value:r}=n;this.img&&(this.img.style.opacity=""+r)}),this.addEventListener("change-icon_border",n=>{let{value:r}=n;this.img&&(this.img.style.border=r.width+"px solid "+r.color)}),this.addEventListener("change-background",n=>{let{value:r}=n;this.div.style.background=r})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import{Box3 as wo,Object3D as _o,Vector3 as Xi}from"three";import{Object3D as Nc,Vector3 as Zc}from"three";var Ii=class extends Nc{loadModel(){return g(this,null,function*(){let t=yield pt.loadModel(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t})}dispose(){F(this),this.model=null}constructor(t,e){super(),this.context=t,this.options=e,this.model=null,this.position.copy(e.position||new Zc(0,0,0)),this.loadModel()}};import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Vc,Vector3 as Kc}from"three";import{Object3D as jc}from"three";var q=class extends jc{setOpacity(t,e){e===void 0&&(e=!1),this.children.forEach(i=>{i.setOpacity==null||i.setOpacity.call(i,t,e)})}onAddToScene(t){this.active=!0,this.sceneType=t}onRemoveFromScene(){this.active=!1}dispose(){F(this),this.children.forEach(t=>t.dispose==null?void 0:t.dispose.call(t)),this.clear()}constructor(t){super(),this.context=t,this.active=!1,this.sceneType="scene"}};var Gi=class extends q{getCenter(){return new Vc().setFromObject(this).getCenter(new Kc)}createGraphic(t){let e=new Y(this.context,t);return e.userData.data=t,this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1/0,graphic:null,position:null},i=this.children.reduce((s,o)=>{if(o instanceof Y){let n=o.raycast(t);if(n){let{distance:r}=n;if(r<s.distance)return{distance:n.distance,position:n.position,graphic:o}}return s}else return s},e);return i===e?{graphics:[],position:null,distance:1/0}:{graphics:[i.graphic],position:i.position,distance:i.distance}}setGraphicOptions(t,e){let i,s=this.graphicMap.get(t);s&&(typeof e=="function"?i=e(s.options):i=w({},s.options,e),Object.keys(i).forEach(o=>{s.options[o]=i[o]}))}getGraphicPosition(t){let e=this.graphicMap.get(t);return e?[e.options.center_x,e.options.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1),this.graphicMap.forEach(i=>{i.setOpacity(t,e)})}constructor(t){super(t),this.graphicMap=new Map}};import"core-js/modules/es.array.unshift.js";import"core-js/modules/es.array.push.js";import{debounce as Xc}from"lodash";var Bi=class extends q{clear(t){return t===void 0&&(t=!1),this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new ce(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===0){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(s=>s instanceof ce&&s.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,s)=>{let{left:o,right:n,top:r,bottom:h}=i.getBox();if(s===0||!i.options.collision_enable){t.push({left:o,right:n,top:r,bottom:h}),i.parentSetVisible(!0);return}let c=t.some(l=>l.left<n&&l.right>o&&l.top<h&&l.bottom>r);i.parentSetVisible(!c),c||t.push({left:o,right:n,top:r,bottom:h})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}constructor(t){super(t),this.pois=[],this.timer=new K,this.onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})},this.registryEvent(),this.debounceCollisionDetection=Xc(this.collisionDetection,10)}};import"core-js/modules/es.array.push.js";import{Vector2 as ul}from"three";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import{Color as yr,DoubleSide as Yc,InstancedBufferAttribute as $e,InstancedBufferGeometry as qc,Mesh as $c,Object3D as Jc,PlaneGeometry as Qc,ShaderMaterial as tl}from"three";var el="#000000",il="#ffffff",sl=`
277
277
  uniform float uZoom;
278
278
  attribute vec3 aCenter;
279
279
  attribute vec4 aRect;
@@ -314,7 +314,7 @@ void main() {
314
314
  if (alpha < 0.001) discard;
315
315
  gl_FragColor = vec4(color, alpha * vOpacity);
316
316
  }
317
- `,zi=class extends Jc{addPoi(t,e){if(!(!e||!e.glyphs.length||e.height<=0)){var i,s,o;this.items.set(t,{poi:t,layout:e,textHeight:t.textHeight,opacity:(i=t.options.text_opacity)!=null?i:1,visible:!!t.visible&&((s=t.shouldShow)!=null?s:!0),depthTest:!!t.options.depth_test,outlineWidth:((o=t.options.text_outline_width)!=null?o:1)*this.pixelRatio,slots:[]}),this.scheduleRebuild()}}removePoi(t){this.items.delete(t)&&this.scheduleRebuild()}refresh(t,e){let i=this.items.get(t);if(!(!i||!e||!e.glyphs.length)){i.layout=e,i.textHeight=t.textHeight,i.depthTest=!!t.options.depth_test;var s;i.outlineWidth=((s=t.options.text_outline_width)!=null?s:1)*this.pixelRatio,this.scheduleRebuild()}}setVisible(t,e){let i=this.items.get(t);!i||i.visible===e||(i.visible=e,this.writeOpacity(i))}setOpacity(t,e){let i=this.items.get(t);i&&(i.opacity=e,this.writeOpacity(i))}setDepthTest(t,e){let i=this.items.get(t);!i||i.depthTest===e||(i.depthTest=e,this.scheduleRebuild())}setOutlineWidth(t,e){let i=this.items.get(t);i&&(i.outlineWidth=(e!=null?e:1)*this.pixelRatio,this.scheduleRebuild())}dispose(){this.context.removeEventListener("control-zoom-change",this.onZoomChange),this.rebuildRaf!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.rebuildRaf),this.rebuildRaf=null,this.rebuildScheduled=!1,this.items.clear(),this.clearBuckets(),this.materials.forEach(t=>t.dispose()),this.materials.clear()}get pixelRatio(){return typeof window!="undefined"&&window.devicePixelRatio||1}writeOpacity(t){let e=t.visible?t.opacity:0;t.slots.forEach(i=>{let{key:s,start:o}=i,n=this.buckets.get(s);n&&(n.opacity.array[o]=e,n.opacity.needsUpdate=!0)})}scheduleRebuild(){if(this.rebuildScheduled)return;this.rebuildScheduled=!0;let t=()=>{this.rebuildScheduled=!1,this.rebuildRaf=null,this.rebuild()};typeof requestAnimationFrame=="function"?this.rebuildRaf=requestAnimationFrame(t):setTimeout(t,0)}clearBuckets(){this.children.slice().forEach(t=>{var e;this.remove(t),(e=t.geometry)==null||e.dispose()}),this.buckets.clear()}rebuild(){if(!this.items.size){this.clearBuckets();return}this.clearBuckets();let t=new Map;this.items.forEach(e=>{e.slots=[];let i=e.poi,s=e.layout,o=1/s.height,n=s.width*o,r=i.textPivotY,h=i.position.x,c=i.position.y,l=i.position.z+.51,p=e.textHeight;if(!p)return;let d=X.getAtlas(i.sdfFontSpec);s.glyphs.forEach(u=>{let f=u.record;var x;let m=(x=f.page)!=null?x:0,y=d.key+"|"+m+"|"+e.outlineWidth+"|"+e.depthTest,_=t.get(y);_||(_={key:y,atlasKey:d.key,page:m,outlineWidth:e.outlineWidth,depthTest:e.depthTest,centers:[],rects:[],uvRects:[],heights:[],opacities:[]},t.set(y,_));let P=u.x*o-n*.5,S=(u.x+f.width)*o-n*.5,E=u.y*o-r,k=(u.y+f.height)*o-r,b=_.centers.length/3;_.centers.push(h,c,l),_.rects.push(P,E,S-P,k-E),_.uvRects.push(f.u0,f.v1,f.u1,f.v0),_.heights.push(p),_.opacities.push(e.visible?e.opacity:0),e.slots.push({key:y,start:b})})}),t.forEach(e=>{let i=e.centers.length/3;if(!i)return;let s=new Qc(1,1),o=new qc;o.index=s.index,o.setAttribute("position",s.attributes.position),o.setAttribute("uv",s.attributes.uv),o.instanceCount=i,o.setAttribute("aCenter",new $e(new Float32Array(e.centers),3)),o.setAttribute("aRect",new $e(new Float32Array(e.rects),4)),o.setAttribute("aUvRect",new $e(new Float32Array(e.uvRects),4)),o.setAttribute("aTextHeight",new $e(new Float32Array(e.heights),1));let n=new $e(new Float32Array(e.opacities),1);o.setAttribute("aOpacity",n);let r=this.getMaterial(e),h=new $c(o,r);h.frustumCulled=!1,h.renderOrder=100001,this.add(h),this.buckets.set(e.key,{key:e.key,count:i,geometry:o,mesh:h,opacity:n})})}getMaterial(t){let e=this.materials.get(t.key);if(e)return e;let i=X.getAtlasByKey(t.atlasKey),s=i==null?void 0:i.pages[t.page],o=s==null?void 0:s.texture,n=new tl({uniforms:{uAtlas:{value:o},uFillColor:{value:new yr(el).convertLinearToSRGB()},uOutlineColor:{value:new yr(il).convertLinearToSRGB()},uOutlineWidth:{value:t.outlineWidth},uEdge:{value:i?1-i.spec.cutoff:.75},uZoom:{value:this.context.camera.zoom}},vertexShader:sl,fragmentShader:ol,transparent:!0,depthTest:t.depthTest,depthWrite:!1,side:Yc,extensions:{derivatives:!0}});return this.materials.set(t.key,n),n}constructor(t){super(),this.context=t,this.items=new Map,this.buckets=new Map,this.materials=new Map,this.rebuildRaf=null,this.rebuildScheduled=!1,this.onZoomChange=e=>{let{zoom:i}=e,s=i!=null?i:this.context.camera.zoom;this.materials.forEach(o=>{o.uniforms.uZoom.value=s})},this.context.addEventListener("control-zoom-change",this.onZoomChange)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import{DoubleSide as nl,InstancedBufferAttribute as Je,InstancedBufferGeometry as rl,Mesh as al,Object3D as hl,PlaneGeometry as cl,ShaderMaterial as ll}from"three";var pl=`
317
+ `,zi=class extends Jc{addPoi(t,e){if(!(!e||!e.glyphs.length||e.height<=0)){var i,s,o;this.items.set(t,{poi:t,layout:e,textHeight:t.textHeight,opacity:(i=t.options.text_opacity)!=null?i:1,visible:!!t.visible&&((s=t.shouldShow)!=null?s:!0),depthTest:!!t.options.depth_test,outlineWidth:((o=t.options.text_outline_width)!=null?o:1)*this.pixelRatio,slots:[]}),this.scheduleRebuild()}}removePoi(t){this.items.delete(t)&&this.scheduleRebuild()}refresh(t,e){let i=this.items.get(t);if(!(!i||!e||!e.glyphs.length)){i.layout=e,i.textHeight=t.textHeight,i.depthTest=!!t.options.depth_test;var s;i.outlineWidth=((s=t.options.text_outline_width)!=null?s:1)*this.pixelRatio,this.scheduleRebuild()}}setVisible(t,e){let i=this.items.get(t);!i||i.visible===e||(i.visible=e,this.writeOpacity(i))}setOpacity(t,e){let i=this.items.get(t);i&&(i.opacity=e,this.writeOpacity(i))}setDepthTest(t,e){let i=this.items.get(t);!i||i.depthTest===e||(i.depthTest=e,this.scheduleRebuild())}setOutlineWidth(t,e){let i=this.items.get(t);i&&(i.outlineWidth=(e!=null?e:1)*this.pixelRatio,this.scheduleRebuild())}dispose(){this.context.removeEventListener("control-zoom-change",this.onZoomChange),this.rebuildRaf!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.rebuildRaf),this.rebuildRaf=null,this.rebuildScheduled=!1,this.items.clear(),this.clearBuckets(),this.materials.forEach(t=>t.dispose()),this.materials.clear()}get pixelRatio(){return typeof window!="undefined"&&window.devicePixelRatio||1}syncCenterZ(){let t=new Set;this.items.forEach(e=>{let i=e.poi.position.z+e.poi.deltaZ;e.slots.forEach(s=>{let{key:o,start:n}=s,r=this.buckets.get(o);r&&(r.centers.array[n*3+2]=i,t.add(r))})}),t.forEach(e=>{e.centers.needsUpdate=!0})}writeOpacity(t){let e=t.visible?t.opacity:0;t.slots.forEach(i=>{let{key:s,start:o}=i,n=this.buckets.get(s);n&&(n.opacity.array[o]=e,n.opacity.needsUpdate=!0)})}scheduleRebuild(){if(this.rebuildScheduled)return;this.rebuildScheduled=!0;let t=()=>{this.rebuildScheduled=!1,this.rebuildRaf=null,this.rebuild()};typeof requestAnimationFrame=="function"?this.rebuildRaf=requestAnimationFrame(t):setTimeout(t,0)}clearBuckets(){this.children.slice().forEach(t=>{var e;this.remove(t),(e=t.geometry)==null||e.dispose()}),this.buckets.clear()}rebuild(){if(!this.items.size){this.clearBuckets();return}this.clearBuckets();let t=new Map;this.items.forEach(e=>{e.slots=[];let i=e.poi,s=e.layout,o=1/s.height,n=s.width*o,r=i.textPivotY,h=i.position.x,c=i.position.y,l=i.position.z+i.deltaZ,p=e.textHeight;if(!p)return;let d=X.getAtlas(i.sdfFontSpec);s.glyphs.forEach(u=>{let f=u.record;var x;let m=(x=f.page)!=null?x:0,y=d.key+"|"+m+"|"+e.outlineWidth+"|"+e.depthTest,_=t.get(y);_||(_={key:y,atlasKey:d.key,page:m,outlineWidth:e.outlineWidth,depthTest:e.depthTest,centers:[],rects:[],uvRects:[],heights:[],opacities:[]},t.set(y,_));let P=u.x*o-n*.5,S=(u.x+f.width)*o-n*.5,E=u.y*o-r,k=(u.y+f.height)*o-r,M=_.centers.length/3;_.centers.push(h,c,l),_.rects.push(P,E,S-P,k-E),_.uvRects.push(f.u0,f.v1,f.u1,f.v0),_.heights.push(p),_.opacities.push(e.visible?e.opacity:0),e.slots.push({key:y,start:M})})}),t.forEach(e=>{let i=e.centers.length/3;if(!i)return;let s=new Qc(1,1),o=new qc;o.index=s.index,o.setAttribute("position",s.attributes.position),o.setAttribute("uv",s.attributes.uv),o.instanceCount=i;let n=new $e(new Float32Array(e.centers),3);o.setAttribute("aCenter",n),o.setAttribute("aRect",new $e(new Float32Array(e.rects),4)),o.setAttribute("aUvRect",new $e(new Float32Array(e.uvRects),4)),o.setAttribute("aTextHeight",new $e(new Float32Array(e.heights),1));let r=new $e(new Float32Array(e.opacities),1);o.setAttribute("aOpacity",r);let h=this.getMaterial(e),c=new $c(o,h);c.frustumCulled=!1,c.renderOrder=100001,this.add(c),this.buckets.set(e.key,{key:e.key,count:i,geometry:o,mesh:c,opacity:r,centers:n})})}getMaterial(t){let e=this.materials.get(t.key);if(e)return e;let i=X.getAtlasByKey(t.atlasKey),s=i==null?void 0:i.pages[t.page],o=s==null?void 0:s.texture,n=new tl({uniforms:{uAtlas:{value:o},uFillColor:{value:new yr(el).convertLinearToSRGB()},uOutlineColor:{value:new yr(il).convertLinearToSRGB()},uOutlineWidth:{value:t.outlineWidth},uEdge:{value:i?1-i.spec.cutoff:.75},uZoom:{value:this.context.camera.zoom}},vertexShader:sl,fragmentShader:ol,transparent:!0,depthTest:t.depthTest,depthWrite:!1,side:Yc,extensions:{derivatives:!0}});return this.materials.set(t.key,n),n}constructor(t){super(),this.context=t,this.items=new Map,this.buckets=new Map,this.materials=new Map,this.rebuildRaf=null,this.rebuildScheduled=!1,this.onZoomChange=e=>{let{zoom:i}=e,s=i!=null?i:this.context.camera.zoom;this.materials.forEach(o=>{o.uniforms.uZoom.value=s}),this.syncCenterZ()},this.context.addEventListener("control-zoom-change",this.onZoomChange)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import{DoubleSide as nl,InstancedBufferAttribute as Je,InstancedBufferGeometry as rl,Mesh as al,Object3D as hl,PlaneGeometry as cl,ShaderMaterial as ll}from"three";var pl=`
318
318
  uniform float uZoom;
319
319
  attribute vec3 aCenter;
320
320
  attribute vec2 aSize;
@@ -349,7 +349,7 @@ void main() {
349
349
  #include <tonemapping_fragment>
350
350
  #include <colorspace_fragment>
351
351
  }
352
- `,Wi=class extends hl{addPoi(t,e,i){var s;this.items.set(t,{poi:t,texture:e,size:i.size,offsetY:i.offsetY,rotation:i.rotation,opacity:i.opacity,visible:!!t.visible&&((s=t.shouldShow)!=null?s:!0),depthTest:i.depthTest,alphaTest:i.alphaTest,slots:[]}),this.scheduleRebuild()}removePoi(t){this.items.delete(t)&&this.scheduleRebuild()}setVisible(t,e){let i=this.items.get(t);!i||i.visible===e||(i.visible=e,this.writeOpacity(i))}setOpacity(t,e){let i=this.items.get(t);i&&(i.opacity=e,this.writeOpacity(i))}setRotation(t,e){let i=this.items.get(t);i&&(i.rotation=e/180*Math.PI,this.writeTransform(i))}setSize(t,e){let i=this.items.get(t);i&&(i.size=e,this.writeTransform(i))}setOffsetY(t,e){let i=this.items.get(t);i&&(i.offsetY=e,this.writeTransform(i))}setDepthTest(t,e){let i=this.items.get(t);!i||i.depthTest===e||(i.depthTest=e,this.scheduleRebuild())}dispose(){this.context.removeEventListener("control-zoom-change",this.onZoomChange),this.rebuildRaf!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.rebuildRaf),this.rebuildRaf=null,this.rebuildScheduled=!1,this.items.clear(),this.clearBuckets(),this.materials.forEach(t=>t.dispose()),this.materials.clear()}writeOpacity(t){let e=t.visible?t.opacity:0;t.slots.forEach(i=>{let{key:s,start:o}=i,n=this.buckets.get(s);n&&(n.opacity.array[o]=e,n.opacity.needsUpdate=!0)})}writeTransform(t){t.slots.forEach(e=>{let{key:i,start:s}=e,o=this.buckets.get(i);if(!o)return;let n=o.geometry,r=n.getAttribute("aSize");r.setXY(s,t.size[0],t.size[1]),r.needsUpdate=!0;let h=n.getAttribute("aOffsetY");h.setX(s,t.offsetY),h.needsUpdate=!0;let c=n.getAttribute("aRotation");c.setX(s,t.rotation),c.needsUpdate=!0})}scheduleRebuild(){if(this.rebuildScheduled)return;this.rebuildScheduled=!0;let t=()=>{this.rebuildScheduled=!1,this.rebuildRaf=null,this.rebuild()};typeof requestAnimationFrame=="function"?this.rebuildRaf=requestAnimationFrame(t):setTimeout(t,0)}clearBuckets(){this.children.slice().forEach(t=>{var e;this.remove(t),(e=t.geometry)==null||e.dispose()}),this.buckets.clear()}rebuild(){if(!this.items.size){this.clearBuckets();return}this.clearBuckets();let t=new Map;this.items.forEach(e=>{e.slots=[];let i=e.poi,s=e.texture.uuid+"|"+e.depthTest+"|"+e.alphaTest,o=t.get(s);o||(o={key:s,texture:e.texture,depthTest:e.depthTest,alphaTest:e.alphaTest,centers:[],sizes:[],offsets:[],rotations:[],opacities:[]},t.set(s,o));let n=o.centers.length/3;o.centers.push(i.position.x,i.position.y,i.position.z+.1),o.sizes.push(e.size[0],e.size[1]),o.offsets.push(e.offsetY),o.rotations.push(e.rotation),o.opacities.push(e.visible?e.opacity:0),e.slots.push({key:s,start:n})}),t.forEach(e=>{let i=e.centers.length/3;if(!i)return;let s=new cl(1,1),o=new rl;o.index=s.index,o.setAttribute("position",s.attributes.position),o.setAttribute("uv",s.attributes.uv),o.instanceCount=i,o.setAttribute("aCenter",new Je(new Float32Array(e.centers),3)),o.setAttribute("aSize",new Je(new Float32Array(e.sizes),2)),o.setAttribute("aOffsetY",new Je(new Float32Array(e.offsets),1)),o.setAttribute("aRotation",new Je(new Float32Array(e.rotations),1));let n=new Je(new Float32Array(e.opacities),1);o.setAttribute("aOpacity",n);let r=this.getMaterial(e),h=new al(o,r);h.frustumCulled=!1,h.renderOrder=1e5,this.add(h),this.buckets.set(e.key,{key:e.key,texture:e.texture,depthTest:e.depthTest,alphaTest:e.alphaTest,geometry:o,mesh:h,opacity:n})})}getMaterial(t){let e=this.materials.get(t.key);if(e)return e;let i=new ll({uniforms:{uMap:{value:t.texture},uAlphaTest:{value:t.alphaTest},uZoom:{value:this.context.camera.zoom}},vertexShader:pl,fragmentShader:dl,transparent:!0,depthTest:t.depthTest,depthWrite:!1,side:nl});return this.materials.set(t.key,i),i}constructor(t){super(),this.context=t,this.items=new Map,this.buckets=new Map,this.materials=new Map,this.rebuildRaf=null,this.rebuildScheduled=!1,this.onZoomChange=e=>{let{zoom:i}=e,s=i!=null?i:this.context.camera.zoom;this.materials.forEach(o=>{o.uniforms.uZoom.value=s})},this.context.addEventListener("control-zoom-change",this.onZoomChange)}};var Ui=class extends q{clear(){return this.context.collisionSystem.removeObjects(this.pois),this.pois.forEach(t=>{t.dispose()}),this.pois=[],this}createPoi(t){let e=new et(this.context,t);return this.pushPoi(e),e}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.remove(t),this.pois.splice(e,1),this.context.collisionSystem.removeObject(t),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){this.pois.includes(t)||(t.textBatch=this.textBatch,t.iconBatch=this.iconBatch,t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("text-texture-rect-inited",()=>{this.active&&this.context.forceUpdate()}),t.parentSetVisible(!1),this.add(t),this.pois.push(t),this.sceneType==="mulFloors"&&(t.options.depth_test=!0),this.active&&this.context.collisionSystem.addObject(t))}changePoiLevelOrCollisionEnable(t){this.active&&(this.context.collisionSystem.removeObject(t),this.context.collisionSystem.addObject(t))}getPoiByDeviceXy(t,e){let i=new ul(t,e);return this.pois.filter(o=>o instanceof et&&o.canSelect&&o.box.containsPoint(i))}setOpacity(t){this.pois.forEach(e=>{e.options.icon_opacity=t,e.options.text_opacity=t})}onAddToScene(t){super.onAddToScene(t);let e=t==="mulFloors";this.pois.forEach(i=>{i.options.depth_test=e,this.context.collisionSystem.addObject(i)})}onRemoveFromScene(){super.onRemoveFromScene(),this.context.collisionSystem.removeObjects(this.pois)}dispose(){var t,e;this.timer.dispose(),this.clear(),(t=this.textBatch)==null||t.dispose(),this.textBatch=null,(e=this.iconBatch)==null||e.dispose(),this.iconBatch=null,super.dispose()}constructor(t){super(t),this.pois=[],this.timer=new K,this.textBatch=null,this.iconBatch=null,t.config.poi.batchText&&(this.textBatch=new zi(t),this.add(this.textBatch)),t.config.poi.batchIcon&&(this.iconBatch=new Wi(t),this.add(this.iconBatch))}};import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.dom-collections.iterator.js";import{Vector2 as go}from"three";import{isNil as ml}from"lodash";var Hi=class extends q{createParkings(t,e,i){e===void 0&&(e=!0),this.parkingOptions=t,this.merged=e,e?(i?this.createMergedParkingByMergedElements(i):this.createMergedParking(t),t.map((s,o)=>{var n;(n=s.texts[0])==null||n.split(/[,,]/).map(r=>{this.parkingNoIndexMap.set(r,o)}),this.nodeIdIndexMap.set(s.id,o)})):this.createIndependentParking(t)}load(t,e){e===void 0&&(e=!0);var i;this.createParkings(t.elements,e,t.mergedElements),(i=t.mergedParkingTexture)!=null&&i.length?this.createMergedParkingTexture(t.mergedParkingTexture):this.createParkingTexture(t.elements)}createMergedParking(t){return g(this,null,function*(){let e=new Qe(this.context,t);this.mergedParkingSpace=e,this.add(e)})}createMergedParkingByMergedElements(t){let e=new Se(this.context,t);if(this.mergedParkingSpace=e,t.lineGeometry){let i=new de(this.context,t.lineGeometry);this.add(i)}this.add(e)}createIndependentParking(t){t.forEach(e=>{var i;let s=new Y(this.context,w({},e,{dashed:!1}));s.userData.data=e,this.add(s),(i=e.texts[0])==null||i.split(/[,,]/).map(o=>{this.parkingNoGraphicMap.set(o,s)}),this.graphicMap.set(s.options.id,s)})}createParkingTexture(t){let e=t.filter(i=>Ai[i.parkingType]).map(i=>{let s=new go(...i.geometry.coords[0][0]),o=new go(...i.geometry.coords[0][1]),n=new go(...i.geometry.coords[0][2]),r=Math.min(s.distanceTo(o),o.distanceTo(n)),h=0;return r===s.distanceTo(o)?h=o.sub(s).angle()-Math.PI/2:h=n.sub(o).angle()-Math.PI/2,{uuid:i.id,iconUrl:Ai[i.parkingType],name:i.texts[0],deltaHeight:(i.deltaHeight||0)+.001,airHeight:i.airHeight,height:i.height,geometry:i.geometry,opacity:i.fillOpacity,visible:!0,secondWidth:r-1,secondHeight:r-1,secondRotate:h,centerCoords:[i.center_coord_x,i.center_coord_y]}});if(e.length){let i=new le(this.context,e);this.add(i)}}createMergedParkingTexture(t){t.map(e=>{e.iconUrl=Ai[e.iconUrl];let i=new pe(this.context,e);this.add(i)})}changeParkingColor(t){this.merged?Object.keys(t).map(e=>{let i=this.parkingNoIndexMap.get(e);if(!ml(i)){var s;(s=this.mergedParkingSpace)==null||s.setColorByIndex(i,t[e])}}):Object.keys(t).map(e=>{let i=this.parkingNoGraphicMap.get(e);i&&(i.options.fillColor=t[e])})}setOpacity(t,e){if(e===void 0&&(e=!1),this.parkingOptions.forEach(s=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let r=this.parkingOriginOptions.get(s.id);var o;s.fillOpacity=Math.min(t,(o=r==null?void 0:r.fillOpacity)!=null?o:1);var n;s.strokeOpacity=Math.min(t,(n=r==null?void 0:r.strokeOpacity)!=null?n:1)}}),this.merged)if(this.mergedParkingSpace instanceof Qe)this.mergedParkingSpace.setOpacity(t,e);else{var i;(i=this.mergedParkingSpace)==null||i.setOpacity(t,e)}else this.graphicMap.forEach(s=>{s.setOpacity(t,e)});this.children.filter(s=>s instanceof le||s instanceof pe).map(s=>s.setOpacity(t))}getParkingOptionsByParkingNo(t){return this.parkingOptions.find(i=>i.texts[0]===t)||null}getGraphicPosition(t){if(this.merged){let e=this.parkingOptions.find(i=>i.id===t);return e?[e.center_x,e.center_y]:null}}getParkingSpaceByRaycaster(t){let e={distance:1/0,graphic:null,position:null},i=this.children.filter(s=>s instanceof Y).reduce((s,o)=>{if(o instanceof Y){let n=o.raycast(t);if(n){let{distance:r}=n;if(r<s.distance)return{distance:n.distance,position:n.position,graphic:o}}return s}else return s},e);return i===e?{graphics:[],position:null,distance:1/0}:{graphics:[i.graphic],distance:i.distance,position:i.position}}dispose(){var t;(t=this.mergedParkingSpace)==null||t.dispose(),this.mergedParkingSpace=null,F(this),this.graphicMap.clear(),this.parkingNoGraphicMap.clear(),this.parkingNoIndexMap.clear(),this.nodeIdIndexMap.clear(),this.parkingOptions=[],super.dispose()}constructor(t){super(t),this.graphicMap=new Map,this.parkingNoGraphicMap=new Map,this.parkingOriginOptions=new Map,this.parkingOptions=[],this.merged=!1,this.parkingNoIndexMap=new Map,this.nodeIdIndexMap=new Map,this.mergedParkingSpace=null}};import"core-js/modules/es.array.push.js";var Ni=class extends q{addModels(t){let e=t.reduce((i,s)=>{let{url:o}=s;return i[o]?i[o].push(s):i[o]=[s],i},{});Object.values(e).forEach(i=>{let s=new Zi(this.context,i);this.add(s)})}constructor(t){super(t)}};import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Ml,Group as wr,Matrix4 as bl,Quaternion as El,Vector3 as vo}from"three";import{LineMaterial as fl}from"three/examples/jsm/lines/LineMaterial.js";import{Color as ti,LineBasicMaterial as gl,MeshStandardMaterial as yl,MeshBasicMaterial as vl,ShaderMaterial as Ce,DoubleSide as xl,LineDashedMaterial as wl}from"three";function vr(a){return`${a.x}-${a.y}-${a.z}`}var ut=class{static generateLineMaterialKey({color:t,opacity:e}){return`${t}-${e}`}static createLineMaterial({color:t,opacity:e,vertexColors:i}){let s=this.generateLineMaterialKey({color:t,opacity:e,vertexColors:i});if(this.lineMaterialMap.has(s))return this.lineMaterialMap.get(s);let o=new gl({color:new ti(t).convertLinearToSRGB(),transparent:!0,opacity:e,vertexColors:i!=null?i:!1});return this.lineMaterialMap.set(s,o),o}static createMeshStandardMaterial({color:t,opacity:e}){let i=`${t}-${e}`;if(this.meshStandardMaterialMap.has(i))return this.meshStandardMaterialMap.get(i);let s=new yl({color:new ti(t).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:e,depthWrite:!0});return this.meshStandardMaterialMap.set(i,s),s}static createMeshBasicMaterial({color:t,opacity:e,vertexColors:i}){let s=`${t}-${e}-${i}`;if(this.meshBasicMaterialMap.has(s))return this.meshBasicMaterialMap.get(s);let o=new vl({color:t,transparent:!0,opacity:e,depthWrite:!0,vertexColors:i!=null?i:!1});return this.meshBasicMaterialMap.set(s,o),o}static createShaderMaterial({gradualColor:t,opacity:e,max:i,min:s}){let o=`${t.toString()}-${e}-${vr(s)}-${vr(i)}`;if(this.shaderMaterialMap.has(o))return this.shaderMaterialMap.get(o);let n=`
352
+ `,Wi=class extends hl{addPoi(t,e,i){var s;this.items.set(t,{poi:t,texture:e,size:i.size,offsetY:i.offsetY,rotation:i.rotation,opacity:i.opacity,visible:!!t.visible&&((s=t.shouldShow)!=null?s:!0),depthTest:i.depthTest,alphaTest:i.alphaTest,slots:[]}),this.scheduleRebuild()}removePoi(t){this.items.delete(t)&&this.scheduleRebuild()}setVisible(t,e){let i=this.items.get(t);!i||i.visible===e||(i.visible=e,this.writeOpacity(i))}setOpacity(t,e){let i=this.items.get(t);i&&(i.opacity=e,this.writeOpacity(i))}setRotation(t,e){let i=this.items.get(t);i&&(i.rotation=e/180*Math.PI,this.writeTransform(i))}setSize(t,e){let i=this.items.get(t);i&&(i.size=e,this.writeTransform(i))}setOffsetY(t,e){let i=this.items.get(t);i&&(i.offsetY=e,this.writeTransform(i))}setDepthTest(t,e){let i=this.items.get(t);!i||i.depthTest===e||(i.depthTest=e,this.scheduleRebuild())}dispose(){this.context.removeEventListener("control-zoom-change",this.onZoomChange),this.rebuildRaf!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this.rebuildRaf),this.rebuildRaf=null,this.rebuildScheduled=!1,this.items.clear(),this.clearBuckets(),this.materials.forEach(t=>t.dispose()),this.materials.clear()}writeOpacity(t){let e=t.visible?t.opacity:0;t.slots.forEach(i=>{let{key:s,start:o}=i,n=this.buckets.get(s);n&&(n.opacity.array[o]=e,n.opacity.needsUpdate=!0)})}writeTransform(t){t.slots.forEach(e=>{let{key:i,start:s}=e,o=this.buckets.get(i);if(!o)return;let n=o.geometry,r=n.getAttribute("aSize");r.setXY(s,t.size[0],t.size[1]),r.needsUpdate=!0;let h=n.getAttribute("aOffsetY");h.setX(s,t.offsetY),h.needsUpdate=!0;let c=n.getAttribute("aRotation");c.setX(s,t.rotation),c.needsUpdate=!0})}scheduleRebuild(){if(this.rebuildScheduled)return;this.rebuildScheduled=!0;let t=()=>{this.rebuildScheduled=!1,this.rebuildRaf=null,this.rebuild()};typeof requestAnimationFrame=="function"?this.rebuildRaf=requestAnimationFrame(t):setTimeout(t,0)}clearBuckets(){this.children.slice().forEach(t=>{var e;this.remove(t),(e=t.geometry)==null||e.dispose()}),this.buckets.clear()}rebuild(){if(!this.items.size){this.clearBuckets();return}this.clearBuckets();let t=new Map;this.items.forEach(e=>{e.slots=[];let i=e.poi,s=e.texture.uuid+"|"+e.depthTest+"|"+e.alphaTest,o=t.get(s);o||(o={key:s,texture:e.texture,depthTest:e.depthTest,alphaTest:e.alphaTest,centers:[],sizes:[],offsets:[],rotations:[],opacities:[]},t.set(s,o));let n=o.centers.length/3;o.centers.push(i.position.x,i.position.y,i.position.z+i.deltaZ),o.sizes.push(e.size[0],e.size[1]),o.offsets.push(e.offsetY),o.rotations.push(e.rotation),o.opacities.push(e.visible?e.opacity:0),e.slots.push({key:s,start:n})}),t.forEach(e=>{let i=e.centers.length/3;if(!i)return;let s=new cl(1,1),o=new rl;o.index=s.index,o.setAttribute("position",s.attributes.position),o.setAttribute("uv",s.attributes.uv),o.instanceCount=i,o.setAttribute("aCenter",new Je(new Float32Array(e.centers),3)),o.setAttribute("aSize",new Je(new Float32Array(e.sizes),2)),o.setAttribute("aOffsetY",new Je(new Float32Array(e.offsets),1)),o.setAttribute("aRotation",new Je(new Float32Array(e.rotations),1));let n=new Je(new Float32Array(e.opacities),1);o.setAttribute("aOpacity",n);let r=this.getMaterial(e),h=new al(o,r);h.frustumCulled=!1,h.renderOrder=1e5,this.add(h),this.buckets.set(e.key,{key:e.key,texture:e.texture,depthTest:e.depthTest,alphaTest:e.alphaTest,geometry:o,mesh:h,opacity:n})})}getMaterial(t){let e=this.materials.get(t.key);if(e)return e;let i=new ll({uniforms:{uMap:{value:t.texture},uAlphaTest:{value:t.alphaTest},uZoom:{value:this.context.camera.zoom}},vertexShader:pl,fragmentShader:dl,transparent:!0,depthTest:t.depthTest,depthWrite:!1,side:nl});return this.materials.set(t.key,i),i}constructor(t){super(),this.context=t,this.items=new Map,this.buckets=new Map,this.materials=new Map,this.rebuildRaf=null,this.rebuildScheduled=!1,this.onZoomChange=e=>{let{zoom:i}=e,s=i!=null?i:this.context.camera.zoom;this.materials.forEach(o=>{o.uniforms.uZoom.value=s})},this.context.addEventListener("control-zoom-change",this.onZoomChange)}};var Ui=class extends q{clear(){return this.context.collisionSystem.removeObjects(this.pois),this.pois.forEach(t=>{t.dispose()}),this.pois=[],this}createPoi(t){let e=new et(this.context,t);return this.pushPoi(e),e}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.remove(t),this.pois.splice(e,1),this.context.collisionSystem.removeObject(t),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){this.pois.includes(t)||(t.textBatch=this.textBatch,t.iconBatch=this.iconBatch,t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("text-texture-rect-inited",()=>{this.active&&this.context.forceUpdate()}),t.parentSetVisible(!1),this.add(t),this.pois.push(t),this.sceneType==="mulFloors"&&(t.options.depth_test=!0),this.active&&this.context.collisionSystem.addObject(t))}changePoiLevelOrCollisionEnable(t){this.active&&(this.context.collisionSystem.removeObject(t),this.context.collisionSystem.addObject(t))}getPoiByDeviceXy(t,e){let i=new ul(t,e);return this.pois.filter(o=>o instanceof et&&o.canSelect&&o.box.containsPoint(i))}setOpacity(t){this.pois.forEach(e=>{e.options.icon_opacity=t,e.options.text_opacity=t})}onAddToScene(t){super.onAddToScene(t);let e=t==="mulFloors";this.pois.forEach(i=>{i.options.depth_test=e,this.context.collisionSystem.addObject(i)})}onRemoveFromScene(){super.onRemoveFromScene(),this.context.collisionSystem.removeObjects(this.pois)}dispose(){var t,e;this.timer.dispose(),this.clear(),(t=this.textBatch)==null||t.dispose(),this.textBatch=null,(e=this.iconBatch)==null||e.dispose(),this.iconBatch=null,super.dispose()}constructor(t){super(t),this.pois=[],this.timer=new K,this.textBatch=null,this.iconBatch=null,t.config.poi.batchText&&(this.textBatch=new zi(t),this.add(this.textBatch)),t.config.poi.batchIcon&&(this.iconBatch=new Wi(t),this.add(this.iconBatch))}};import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.dom-collections.iterator.js";import{Vector2 as go}from"three";import{isNil as ml}from"lodash";var Hi=class extends q{createParkings(t,e,i){e===void 0&&(e=!0),this.parkingOptions=t,this.merged=e,e?(i?this.createMergedParkingByMergedElements(i):this.createMergedParking(t),t.map((s,o)=>{var n;(n=s.texts[0])==null||n.split(/[,,]/).map(r=>{this.parkingNoIndexMap.set(r,o)}),this.nodeIdIndexMap.set(s.id,o)})):this.createIndependentParking(t)}load(t,e){e===void 0&&(e=!0);var i;this.createParkings(t.elements,e,t.mergedElements),(i=t.mergedParkingTexture)!=null&&i.length?this.createMergedParkingTexture(t.mergedParkingTexture):this.createParkingTexture(t.elements)}createMergedParking(t){return g(this,null,function*(){let e=new Qe(this.context,t);this.mergedParkingSpace=e,this.add(e)})}createMergedParkingByMergedElements(t){let e=new Se(this.context,t);if(this.mergedParkingSpace=e,t.lineGeometry){let i=new de(this.context,t.lineGeometry);this.add(i)}this.add(e)}createIndependentParking(t){t.forEach(e=>{var i;let s=new Y(this.context,w({},e,{dashed:!1}));s.userData.data=e,this.add(s),(i=e.texts[0])==null||i.split(/[,,]/).map(o=>{this.parkingNoGraphicMap.set(o,s)}),this.graphicMap.set(s.options.id,s)})}createParkingTexture(t){let e=t.filter(i=>Ai[i.parkingType]).map(i=>{let s=new go(...i.geometry.coords[0][0]),o=new go(...i.geometry.coords[0][1]),n=new go(...i.geometry.coords[0][2]),r=Math.min(s.distanceTo(o),o.distanceTo(n)),h=0;return r===s.distanceTo(o)?h=o.sub(s).angle()-Math.PI/2:h=n.sub(o).angle()-Math.PI/2,{uuid:i.id,iconUrl:Ai[i.parkingType],name:i.texts[0],deltaHeight:(i.deltaHeight||0)+.001,airHeight:i.airHeight,height:i.height,geometry:i.geometry,opacity:i.fillOpacity,visible:!0,secondWidth:r-1,secondHeight:r-1,secondRotate:h,centerCoords:[i.center_coord_x,i.center_coord_y]}});if(e.length){let i=new le(this.context,e);this.add(i)}}createMergedParkingTexture(t){t.map(e=>{e.iconUrl=Ai[e.iconUrl];let i=new pe(this.context,e);this.add(i)})}changeParkingColor(t){this.merged?Object.keys(t).map(e=>{let i=this.parkingNoIndexMap.get(e);if(!ml(i)){var s;(s=this.mergedParkingSpace)==null||s.setColorByIndex(i,t[e])}}):Object.keys(t).map(e=>{let i=this.parkingNoGraphicMap.get(e);i&&(i.options.fillColor=t[e])})}setOpacity(t,e){if(e===void 0&&(e=!1),this.parkingOptions.forEach(s=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let r=this.parkingOriginOptions.get(s.id);var o;s.fillOpacity=Math.min(t,(o=r==null?void 0:r.fillOpacity)!=null?o:1);var n;s.strokeOpacity=Math.min(t,(n=r==null?void 0:r.strokeOpacity)!=null?n:1)}}),this.merged)if(this.mergedParkingSpace instanceof Qe)this.mergedParkingSpace.setOpacity(t,e);else{var i;(i=this.mergedParkingSpace)==null||i.setOpacity(t,e)}else this.graphicMap.forEach(s=>{s.setOpacity(t,e)});this.children.filter(s=>s instanceof le||s instanceof pe).map(s=>s.setOpacity(t))}getParkingOptionsByParkingNo(t){return this.parkingOptions.find(i=>i.texts[0]===t)||null}getGraphicPosition(t){if(this.merged){let e=this.parkingOptions.find(i=>i.id===t);return e?[e.center_x,e.center_y]:null}}getParkingSpaceByRaycaster(t){let e={distance:1/0,graphic:null,position:null},i=this.children.filter(s=>s instanceof Y).reduce((s,o)=>{if(o instanceof Y){let n=o.raycast(t);if(n){let{distance:r}=n;if(r<s.distance)return{distance:n.distance,position:n.position,graphic:o}}return s}else return s},e);return i===e?{graphics:[],position:null,distance:1/0}:{graphics:[i.graphic],distance:i.distance,position:i.position}}dispose(){var t;(t=this.mergedParkingSpace)==null||t.dispose(),this.mergedParkingSpace=null,F(this),this.graphicMap.clear(),this.parkingNoGraphicMap.clear(),this.parkingNoIndexMap.clear(),this.nodeIdIndexMap.clear(),this.parkingOptions=[],super.dispose()}constructor(t){super(t),this.graphicMap=new Map,this.parkingNoGraphicMap=new Map,this.parkingOriginOptions=new Map,this.parkingOptions=[],this.merged=!1,this.parkingNoIndexMap=new Map,this.nodeIdIndexMap=new Map,this.mergedParkingSpace=null}};import"core-js/modules/es.array.push.js";var Ni=class extends q{addModels(t){let e=t.reduce((i,s)=>{let{url:o}=s;return i[o]?i[o].push(s):i[o]=[s],i},{});Object.values(e).forEach(i=>{let s=new Zi(this.context,i);this.add(s)})}constructor(t){super(t)}};import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as bl,Group as wr,Matrix4 as Ml,Quaternion as El,Vector3 as vo}from"three";import{LineMaterial as fl}from"three/examples/jsm/lines/LineMaterial.js";import{Color as ti,LineBasicMaterial as gl,MeshStandardMaterial as yl,MeshBasicMaterial as vl,ShaderMaterial as Ce,DoubleSide as xl,LineDashedMaterial as wl}from"three";function vr(a){return`${a.x}-${a.y}-${a.z}`}var ut=class{static generateLineMaterialKey({color:t,opacity:e}){return`${t}-${e}`}static createLineMaterial({color:t,opacity:e,vertexColors:i}){let s=this.generateLineMaterialKey({color:t,opacity:e,vertexColors:i});if(this.lineMaterialMap.has(s))return this.lineMaterialMap.get(s);let o=new gl({color:new ti(t).convertLinearToSRGB(),transparent:!0,opacity:e,vertexColors:i!=null?i:!1});return this.lineMaterialMap.set(s,o),o}static createMeshStandardMaterial({color:t,opacity:e}){let i=`${t}-${e}`;if(this.meshStandardMaterialMap.has(i))return this.meshStandardMaterialMap.get(i);let s=new yl({color:new ti(t).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:e,depthWrite:!0});return this.meshStandardMaterialMap.set(i,s),s}static createMeshBasicMaterial({color:t,opacity:e,vertexColors:i}){let s=`${t}-${e}-${i}`;if(this.meshBasicMaterialMap.has(s))return this.meshBasicMaterialMap.get(s);let o=new vl({color:t,transparent:!0,opacity:e,depthWrite:!0,vertexColors:i!=null?i:!1});return this.meshBasicMaterialMap.set(s,o),o}static createShaderMaterial({gradualColor:t,opacity:e,max:i,min:s}){let o=`${t.toString()}-${e}-${vr(s)}-${vr(i)}`;if(this.shaderMaterialMap.has(o))return this.shaderMaterialMap.get(o);let n=`
353
353
  uniform vec3 uColor;
354
354
  uniform vec3 uGradualColor;
355
355
  uniform vec3 uMax;
@@ -556,7 +556,7 @@ void main() {
556
556
  gl_FragColor = vec4(newColor, vOpacity);
557
557
  }
558
558
  }
559
- `;return this.instancedWallMaterial=new Ce({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};it(ut,"lineMaterialMap",new Map),it(ut,"meshStandardMaterialMap",new Map),it(ut,"meshBasicMaterialMap",new Map),it(ut,"shaderMaterialMap",new Map),it(ut,"line2MaterialMap",new Map),it(ut,"mergeAttributeGraphicMaterial",null),it(ut,"mergeAttributeWallMaterial",null),it(ut,"mergeAttributeGraphicLineMaterial",null),it(ut,"instancedGraphicMaterial",null),it(ut,"instancedWallMaterial",null),it(ut,"lineDashedMaterialMap",new Map);var Te=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static registerKey(t){this.keySet.add(t)}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};it(Te,"keySet",new Set);function Le(a,t,e){return new Promise((i,s)=>{let o=Te.genUniqueKey(),n=({data:r})=>{r.type===`${t}_result`&&r.key===o&&(Te.removeKey(o),self.removeEventListener("message",n),r.error?s(r.error):i(r.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}import{EventDispatcher as _l}from"three";var ji=class extends _l{constructor(e=10,i){super();it(this,"max",10);it(this,"workerConstructor");it(this,"pool",[]);this.max=e,this.workerConstructor=i}getWorker(){return new Promise(e=>{let i=this.pool.find(o=>o.state==="leisure");if(i){i.state="used",e(i.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let o=this.workerConstructor();this.pool.push({worker:o,state:"used"}),e(o);return}let s=()=>{let o=this.pool.find(n=>n.state==="leisure");o&&(this.removeEventListener("release",s),o.state="used",e(o.worker))};this.addEventListener("release",s)})}releaseWorker(e){let i=this.pool.find(s=>s.worker===e);i&&(i.state="leisure",this.dispatchEvent({type:"release",worker:e}))}dispose(){this._listeners={},this.pool.forEach(e=>{e.worker.terminate()}),this.pool=[]}};function yo(){return new Worker(new URL("./worker/merge-geometry.worker-SQEWCBXS.js",import.meta.url))}import{BufferGeometry as Pl,BufferAttribute as xr}from"three";var ke=class{static GetMergeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Pl;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new xr(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new xr(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static GetMergedGeometryLine(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};it(ke,"WorkerPool",new ji(10,yo));var Vi=class extends q{getCenter(){return new Ml().setFromObject(this).getCenter(new vo)}addInstancedGraphic(t){this.instancedGraphicConfig?(this.instancedGraphicConfig.size+=t.size,this.instancedGraphicConfig.colors=[...this.instancedGraphicConfig.colors,...t.colors],this.instancedGraphicConfig.matrixes=[...this.instancedGraphicConfig.matrixes,...t.matrixes],this.instancedGraphicConfig.opacities=[...this.instancedGraphicConfig.opacities,...t.opacities],this.instancedGraphicConfig.maxZs=[...this.instancedGraphicConfig.maxZs,...t.maxZs],this.instancedGraphicConfig.ids=[...this.instancedGraphicConfig.ids,...t.ids]):this.instancedGraphicConfig=t,this.refeshInstancedGraphic()}refeshInstancedGraphic(){this.instancedGraphic&&(this.remove(this.instancedGraphic),F(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new Se(this.context,this.instancedGraphicConfig),this.add(this.instancedGraphic))}addGraphics(t,e){t.map(i=>{this.graphicDataMap.set(i.id,i),this.graphicOriginOptionMap.set(i.id,{fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity})}),e?e.map(i=>{if(i.instancedGeometry&&this.addInstancedGraphic(i.instancedGeometry),i.mergedGeometry){let s=new ei(this.context,w({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new de(this.context,i.lineGeometry);this.mergedLineGroup.add(s)}i.mergedGeometry=null,i.lineGeometry=null}):(this.refreshMergeGraphic(),this.refreshLine())}createGraphic(t){return g(this,null,function*(){let e=yield ke.GetMergedGeometry(t);if(F(this.mergedGraphicGroup),this.mergedGraphicGroup.clear(),e){let i=new ei(this.context,e);this.mergedGraphicGroup.add(i)}})}createLine(t){return g(this,null,function*(){let e=yield ke.GetMergedGeometryLine(t);if(F(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new de(this.context,e.lineGeometry);this.mergedLineGroup.add(i)}})}refreshMergeGraphic(){let t=Array.from(this.graphicDataMap.values());this.instancedGraphicConfig&&(t=t.filter(e=>{var i;return!((i=this.instancedGraphicConfig)!=null&&i.ids.includes(e.id))})),this.createGraphic(t)}refreshLine(){let t=Array.from(this.graphicDataMap.values());this.createLine(t)}removeGraphicById(t){var e;if(this.graphicDataMap.delete(t),(e=this.instancedGraphicConfig)!=null&&e.ids.includes(t)){let i=this.instancedGraphicConfig.ids.findIndex(s=>s===t);this.instancedGraphicConfig.size--,this.instancedGraphicConfig.colors.splice(i*3,3),this.instancedGraphicConfig.matrixes.splice(i*16,16),this.instancedGraphicConfig.opacities.splice(i,1),this.instancedGraphicConfig.maxZs.splice(i,1),this.instancedGraphicConfig.ids.splice(i,1),this.refeshInstancedGraphic()}else this.refreshMergeGraphic();this.refreshLine()}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){var i;let s,o=this.graphicDataMap.get(t);if(o){if(typeof e=="function"?s=e(o):s=w({},o,e),this.graphicDataMap.set(t,s),(i=this.instancedGraphicConfig)!=null&&i.ids.includes(t)&&this.instancedGraphic){this.instancedGraphic.setColorById(t,s.fillColor),this.instancedGraphic.setOpacityById(t,s.fillOpacity),this.instancedGraphic.setMaxZById(t,s.deltaHeight+s.airHeight+s.height);let n=this.instancedGraphicConfig.ids.findIndex(d=>d===t),r=this.instancedGraphicConfig.matrixes.slice(n*16,(n+1)*16),h=new bl().fromArray(r),c=new vo,l=new El,p=new vo;h.decompose(c,l,p),p.z=s.height,c.z=s.deltaHeight+s.airHeight+s.height/2,h.compose(c,l,p),this.instancedGraphic.setMatrixById(t,h)}else this.refreshMergeGraphic();this.refreshLine()}}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1);var i;this.graphicDataMap.forEach((s,o)=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let h=this.graphicOriginOptionMap.get(o);var n;s.fillOpacity=Math.min(t,(n=h==null?void 0:h.fillOpacity)!=null?n:1);var r;s.strokeOpacity=Math.min(t,(r=h==null?void 0:h.strokeOpacity)!=null?r:1)}}),(i=this.instancedGraphic)==null||i.setOpacity(t,e),this.refeshInstancedGraphic(),this.refreshLine()}dispose(){this.mergedGraphicGroup.children.slice().forEach(t=>{t.dispose==null||t.dispose.call(t)}),this.mergedGraphicGroup.clear(),this.mergedLineGroup.children.slice().forEach(t=>{t.dispose==null||t.dispose.call(t)}),this.mergedLineGroup.clear(),this.instancedGraphic&&(this.remove(this.instancedGraphic),this.instancedGraphic.dispose(),this.instancedGraphic=null),this.instancedGraphicConfig=null,this.graphicMap.clear(),this.graphicDataMap.clear(),this.graphicOriginOptionMap.clear(),super.dispose()}constructor(t){super(t),this.graphicMap=new Map,this.mergedGraphicGroup=new wr,this.mergedLineGroup=new wr,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Group as Tl,Mesh as Ll,MeshBasicMaterial as kl,PlaneGeometry as Al,Vector2 as Dl,Vector3 as xo,Raycaster as Rl,Plane as Ol}from"three";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-collections.iterator.js";import{SRGBColorSpace as Sl,TextureLoader as Cl}from"three";var Ki=class{setBaseUrl(t){this.baseUrl=t.replace(/\/$/,"")}setConfig(t){this.config=t}loadConfig(){return g(this,null,function*(){if(this.config)return this.config;if(!this.baseUrl)throw new Error("Base URL is not set");try{let t=yield fetch(""+this.baseUrl+"/config.json");return this.config=yield t.json(),this.config}catch(t){return console.error("Failed to load tile config:",t),this.config={extent:[12276734621488994e-9,2.1183542845726013e6,12279646804065457e-9,2121524247761597e-9],maxZoom:21,minZoom:11},this.config}})}buildTileUrl(t,e,i){if(!this.baseUrl)throw new Error("Base URL is not set");return this.baseUrl+"/"+i+"/"+t+"/"+e+".png"}loadTileTexture(t,e,i){return g(this,null,function*(){if(!this.baseUrl)throw new Error("Base URL is not set");let s=this.buildTileUrl(t,e,i);if(this.textureCache.has(s)){let n=this.textureCache.get(s);return n instanceof Promise?n:Promise.resolve(n)}let o=this.textureLoader.loadAsync(s).then(n=>(n.flipY=!0,n.colorSpace=Sl,this.textureCache.set(s,n),n)).catch(n=>null);return this.textureCache.set(s,o),o})}clearCache(){this.textureCache.forEach(t=>{t instanceof Promise?t.then(e=>e==null?void 0:e.dispose()):t.dispose()}),this.textureCache.clear()}dispose(){this.clearCache()}constructor(t){this.baseUrl="",this.config=null,this.textureCache=new Map,this.textureLoader=new Cl,t&&this.setBaseUrl(t)}};import{debounce as Fl}from"lodash";var _r={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},ue=class a extends q{loadTileConfig(){return g(this,null,function*(){return this.tileLoader.loadConfig()})}initEvents(){this.context.addEventListener("control-change",this.onUpdate),this.context.bmap.addEventListener("center-change",this.onCenterChange)}removeEvents(){this.context.removeEventListener("control-change",this.onUpdate),this.context.bmap.removeEventListener("center-change",this.onCenterChange)}getViewBounds(){let t=this.context.camera,e=new Rl,i=new Dl,s=[],[o,n]=this.context.center||[0,0],r=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}];for(let d of r){i.set(d.x,d.y),e.setFromCamera(i,t);let u=new xo(0,0,1),f=new xo(0,0,0),x=new Ol().setFromNormalAndCoplanarPoint(u,f),m=new xo;e.ray.intersectPlane(x,m)?s.push(m):(e.ray.direction.negate(),e.ray.intersectPlane(x,m)&&s.push(m))}if(s.length<4)return null;let h=1/0,c=1/0,l=-1/0,p=-1/0;return s.forEach(d=>{h=Math.min(h,d.x+o),c=Math.min(c,d.y+n),l=Math.max(l,d.x+o),p=Math.max(p,d.y+n)}),{minX:h,minY:c,maxX:l,maxY:p}}getTileZoomLevel(t,e){let{minZoom:i,maxZoom:s}=e,o=this.context.camera,n=(o.right-o.left)/o.zoom,r=this.context.clientSize.width,h=n/r,c=a.WORLD_WIDTH,l=Math.log2(c/(h*this.tileSize));return Math.min(s,Math.max(i,Math.round(l)))}getTilesInView(t,e,i){let[s,o,n,r]=i.extent,h=Math.max(t.minX,s),c=Math.max(t.minY,o),l=Math.min(t.maxX,n),p=Math.min(t.maxY,r);if(h>=l||c>=p)return[];let d=Math.pow(2,e),u=a.WORLD_WIDTH/d,f=a.WORLD_WIDTH_HALF,x=Math.max(0,Math.floor((h+f)/u)),m=Math.floor((l+f)/u),y=Math.max(0,Math.floor((f-p)/u)),_=Math.floor((f-c)/u),P=[];for(let S=x;S<=m;S++)for(let E=y;E<=_;E++)P.push({x:S,y:E,z:e});return P}renderTiles(t,e){return g(this,null,function*(){let i=t,s=[];if(this.currentLevel!==e)s=[...this.tileGroup.children];else{let r=this.tileGroup.children,h=r.map(l=>l.userData.key),c=t.map(l=>l.z+"/"+l.x+"/"+l.y);i=t.filter(l=>!h.includes(l.z+"/"+l.x+"/"+l.y)),s=r.filter(l=>!c.includes(l.userData.key))}let o=Math.pow(2,e),n=a.WORLD_WIDTH/o;yield Promise.all(i.map(r=>g(this,null,function*(){let h=r.z+"/"+r.x+"/"+r.y,c=yield this.tileLoader.loadTileTexture(r.x,r.y,r.z);if(c){let l=new kl({map:c,transparent:!0}),p=new Ll(this.baseGeometry,l);p.scale.setX(n).setY(n),p.position.set((r.x-o/2)*n+n/2,-((r.y-o/2)*n)-n/2,0),p.userData.key=h,this.tileGroup.add(p)}}))),this.tileGroup.children.forEach(r=>{s.includes(r)&&(r.material.dispose(),this.tileGroup.remove(r))})})}setVisibility(t){this.visible=t,t&&this.onUpdate()}setOpacity(t){super.setOpacity(t)}clearTiles(){this.tileGroup.children.forEach(t=>{t.material.dispose()}),this.tileGroup.clear()}dispose(){this.removeEvents(),this.clearTiles(),this.baseGeometry.dispose(),this.tileLoader.dispose(),super.dispose()}constructor(t,e){super(t),this.loadedTiles=new Map,this.currentLevel=0,this.tileSize=256,this.baseGeometry=new Al(1,1),this.options=_r,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=Fl(()=>g(this,null,function*(){if(!this.visible)return;let s=yield this.loadTileConfig(),o=this.context.camera,n=this.getViewBounds();if(!n)return;let r=this.getTileZoomLevel(o.zoom,s),h=this.getTilesInView(n,r,s);this.renderTiles(h,r)}),100),this.options=w({},_r,e),this.tileGroup=new Tl;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Ki(this.options.base_url),this.initEvents(),this.updateTiles()}};ue.WORLD_WIDTH=4007501668e-2;ue.WORLD_WIDTH_HALF=ue.WORLD_WIDTH/2;import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.string.trim.js";import{Box2 as Pr,Mesh as Mr,Object3D as Il,PlaneGeometry as br,Sprite as Gl,SpriteMaterial as Bl,Vector3 as zl}from"three";import{mergeGeometries as Wl}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ul=600,Hl="#000000",Nl="#ffffff",Zl=1,jl=400,Vl="sans-serif",Er=6,Sr=3,Kl=4,Xl={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,text_font_weight:jl,text_font_family:Vl,text_outline_width:Zl,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1,icon_alpha_test:.2,text_alpha_test:.2},et=class extends Il{scheduleScaleSync(){if(typeof requestAnimationFrame!="function")return;this.scaleSyncRaf&&cancelAnimationFrame(this.scaleSyncRaf);let t=this.textRevision;this.scaleSyncRaf=requestAnimationFrame(()=>{this.scaleSyncRaf=0,!(t!==this.textRevision||!this.meshText)&&this._initScale({zoom:this.context.camera.zoom})})}get shouldShow(){return this._shouldShow}get sdfFontSpec(){return X.getSpec({fontWeight:this.options.text_font_weight,fontFamily:this.options.text_font_family})}get textTexture(){if(!this.options.text)return null;var t;return(t=X.getTexture(this.sdfFontSpec))!=null?t:null}get textObject(){return this.meshText}get textPivotY(){return this.textCenterY}get isMovingBatchPoi(){return!!this.options.id&&this.options.id.startsWith("navigation_")}get textMaterials(){var t;let e=(t=this.meshText)==null?void 0:t.material;return e?Array.isArray(e)?e:[e]:[]}mergeTextParts(t){if(!t.length)return null;if(t.length===1)return t[0].geometry;let e=Wl(t.map(i=>i.geometry),!0);return t.forEach(i=>i.geometry.dispose()),e}get textTextureRect(){let t=this.options.text;var e;return t&&(e=this.textTextureRectMap[t])!=null?e:null}get textureLines(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.lines)!=null?i:1}get textAspect(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.aspect)!=null?i:1}get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){if(!this.hasText)return 0;let t=this.textLayoutMap[this.textTextureKey];return t?t.height*(this.options.text_font_size/this.sdfFontSpec.fontSize):this.options.text_font_size*this.textureLines}get initedTextRect(){return!this.options.text||this.options.text&&this.textTextureRect}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&this._shouldShow}disposeTextMesh(t){this.textObjects.delete(t),this.remove(t),t.geometry.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>i.dispose())}clearTextObjects(){this.meshText&&this.textObjects.add(this.meshText),this.meshBackground&&this.textObjects.add(this.meshBackground);let t=Array.from(this.textObjects);this.textObjects.clear(),this.meshText=void 0,this.meshBackground=void 0,t.forEach(e=>this.disposeTextMesh(e))}clearIconObjects(){this.spriteIcon&&this.iconSprites.add(this.spriteIcon);let t=Array.from(this.iconSprites);this.iconSprites.clear(),this.spriteIcon=void 0,t.forEach(e=>{this.remove(e),e.material.dispose()})}show(){return g(this,null,function*(){if(this._shouldShow)return;this._shouldShow=!0;let t=++this.visibilityRevision,e=[];if(!this.spriteIcon&&!this.batchIconReady&&this.options.icon&&e.push(this.initIcon()),!this.textObject&&!this.batchTextReady&&this.hasText&&e.push(this.initText()),yield Promise.all(e),t===this.visibilityRevision){if(!this._shouldShow){this.hide();return}if(this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.spriteIcon&&(this.spriteIcon.visible=!0),this.batchIconReady){var i;(i=this.iconBatch)==null||i.setVisible(this,this.visible)}if(this.meshText&&(this.meshText.visible=!0),this.meshBackground&&(this.meshBackground.visible=!0),this.batchTextReady){var s;(s=this.textBatch)==null||s.setVisible(this,this.visible)}this.scheduleScaleSync()}})}hide(){if(this._shouldShow=!1,this.visibilityRevision++,this.textRevision++,this.iconRevision++,this.scaleSyncRaf&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.scaleSyncRaf),this.scaleSyncRaf=0),this.batchIconReady){var t;(t=this.iconBatch)==null||t.setVisible(this,!1)}if(this.clearIconObjects(),this.batchTextReady){var e;(e=this.textBatch)==null||e.setVisible(this,!1)}this.clearTextObjects()}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchIcon(),this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate())})),this.addEventListener("change-text_background",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate())})),this.addEventListener("change-text_font_size",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchText(),this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate()})),this.addEventListener("change-text_font_weight",t=>g(this,null,function*(){let{value:e}=t;this.clearTextTextureCache(),this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate())})),this.addEventListener("change-text_font_family",t=>g(this,null,function*(){let{value:e}=t;this.clearTextTextureCache(),this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate())})),this.addEventListener("change-text_outline_width",t=>{let{value:e}=t;if(this.batchTextReady){var i;(i=this.textBatch)==null||i.setOutlineWidth(this,e)}else{let s=typeof window!="undefined"&&window.devicePixelRatio||1;this.textMaterials.forEach(o=>{o.uniforms.uOutlineWidth.value=e*s})}}),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setRotation(this,e)}else this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setSize(this,[this.options.icon_size[0],this.options.icon_size[1]])}this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.options.icon&&this.context.forceUpdate()}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setDepthTest(this,e)}else this.spriteIcon&&(this.spriteIcon.material.depthTest=e);if(this.batchTextReady){var s;(s=this.textBatch)==null||s.setDepthTest(this,e)}else this.textMaterials.forEach(o=>{o.depthTest=e});this.meshBackground&&(this.meshBackground.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setOpacity(this,e)}else this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;if(this.batchTextReady){var i;(i=this.textBatch)==null||i.setOpacity(this,e)}else this.textMaterials.forEach(s=>{s.uniforms.uOpacity.value=e})})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return g(this,null,function*(){if(this.options.icon){let t=++this.iconRevision;return new Promise(e=>g(this,null,function*(){let i;if(this.options.icon_border){let{icon:o,icon_size:n,icon_border:r}=this.options;i=yield ht.getUrlTextureBorder(o,n[0]-r.width*2,r)}else i=yield ht.getTextureByUrl(this.options.icon);if(i.needsUpdate=!0,t!==this.iconRevision){e(null);return}if(this.iconBatch&&!this.isMovingBatchPoi){let o=this.hasText?0:.5;this.iconBatch.addPoi(this,i,{size:[this.options.icon_size[0],this.options.icon_size[1]],offsetY:(.5-o)*this.options.icon_size[1],rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity,depthTest:this.options.depth_test,alphaTest:this.options.icon_alpha_test}),this.batchIconReady=!0,this.iconBatch.setVisible(this,this._shouldShow),e(null);return}let s=new Gl(new Bl({map:i,transparent:!0,alphaTest:this.options.icon_alpha_test,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));s.visible=!1,s.renderOrder=1e5+this.options.level,i.needsUpdate=!0,this.clearIconObjects(),this.iconSprites.add(s),this.add(s),this.spriteIcon=s,e(s)}))}})}get textTextureKey(){let t=this.options.text_background||{enable:!1,color:"",opacity:0};return this.options.text+"-"+t.enable+"-"+t.color+"-"+t.opacity+"-"+this.options.text_font_weight+"-"+this.options.text_font_family}prepareTextLayout(){return g(this,null,function*(){let t=this.textTextureKey;return yield this.initTextTexture(),t!==this.textTextureKey?!1:(this.initTextTextureRect(),!0)})}layoutText(t,e,i){return g(this,null,function*(){i===void 0&&(i=this.sdfFontSpec);let s=this.textLayoutMap[e];if(s)return s;let o=yield X.ensureText(t,i);if(t!==this.options.text||e!==this.textTextureKey)return null;let n=wi(t,o.charMap,o.spec,Ul);return this.textLayoutMap[e]=n,n})}initText(){return g(this,null,function*(){var t,e;if(!this.hasText)return;let i=++this.textRevision,s=this.options.text,o=this.textTextureKey,n=this.sdfFontSpec;if(this.textLayoutMap[o]||(yield this.initTextTexture()),i!==this.textRevision||o!==this.textTextureKey||s!==this.options.text)return;let r=this.textLayoutMap[o];if(!r)return;if(this.initSize(),this.textBatch&&!this.isMovingBatchPoi&&!((t=this.options.text_background)!=null&&t.enable)){if(i!==this.textRevision)return;this.clearTextObjects(),this.textBatch.addPoi(this,r),this.batchTextReady=!0,this.textBatch.setVisible(this,this._shouldShow);return}let h=X.getAtlas(n),c=Ue(r,{pivotY:this.textCenterY});if(!c.length)return;let p=r.height*(this.options.text_font_size/n.fontSize)/this.context.camera.zoom,d=typeof window!="undefined"&&window.devicePixelRatio||1,u=c.map(y=>Li({atlas:h.pages[y.page].texture,fillColor:Hl,outlineColor:Nl,outlineWidth:this.options.text_outline_width*d,opacity:this.options.text_opacity,depthTest:this.options.depth_test,edge:1-h.spec.cutoff,billboard:!0})),f=this.mergeTextParts(c);if(!f)return;let x=new Mr(f,u.length===1?u[0]:u);if(x.visible=!1,x.renderOrder=100001+this.options.level,x.scale.set(p,p,1),i!==this.textRevision||o!==this.textTextureKey){this.disposeTextMesh(x);return}if(this.clearTextObjects(),this.textObjects.add(x),this.meshText=x,this.add(x),(e=this.options.text_background)!=null&&e.enable){var m;this.initBackgroundMesh(r,h.spec),(m=this.meshBackground)==null||m.scale.set(p,p,1)}this._initScale({zoom:this.context.camera.zoom})})}initBackgroundMesh(t,e){let i=this.options.text_background,s=e.fontSize/xi,o=Er*s/t.height,n=Sr*s/t.height,r=t.aspect+o*2,h=1+n*2,c=Kl*s/t.height,l=new br(r,h);l.translate(0,.5-this.textCenterY,0);let p=er({color:i.color,opacity:i.opacity,radius:c,size:{width:r,height:h},depthTest:this.options.depth_test,billboard:!0}),d=new Mr(l,p);d.visible=!1,d.renderOrder=1e5+this.options.level,this.meshBackground&&this.meshBackground!==d&&this.disposeTextMesh(this.meshBackground),this.meshBackground=d,this.textObjects.add(d),this.add(d)}initSize(){var t;let e=0,i=0,{icon:s}=this.options;s?this.hasText?(e=0,i=e*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(e=.5,i=0):this.hasText?(i=.5,e=0):(e=0,i=0);let o=this.textCenterY!==i;if(this.textCenterY=i,(t=this.spriteIcon)==null||t.center.set(.5,e),this.batchIconReady){var n;(n=this.iconBatch)==null||n.setOffsetY(this,(.5-e)*this.options.icon_size[1])}o&&this.meshText&&this.rebuildTextMeshes()}rebuildTextMeshes(){var t;let e=this.textLayoutMap[this.textTextureKey];if(!e||!this.meshText)return;let i=this.mergeTextParts(Ue(e,{pivotY:this.textCenterY}));i&&(this.meshText.geometry.dispose(),this.meshText.geometry=i,this.meshBackground&&((t=this.options.text_background)!=null&&t.enable)&&(this.meshBackground.geometry.dispose(),this.meshBackground.geometry=this.buildBackgroundGeometry(e)))}buildBackgroundGeometry(t){let i=X.getAtlas(this.sdfFontSpec).spec.fontSize/xi,s=Er*i/t.height,o=Sr*i/t.height,n=t.aspect+s*2,r=1+o*2,h=new br(n,r);return h.translate(0,.5-this.textCenterY,0),h}init(){return g(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.scheduleScaleSync()})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.meshText&&(this.meshText.position.z=t),this.meshBackground&&(this.meshBackground.position.z=t-.001)}getLabelOriginWorldPosition(t){t===void 0&&(t=new zl);let e=this.meshText||this.meshBackground||this.spriteIcon;return e?e.getWorldPosition(t):(this.updateWorldMatrix(!0,!1),t.set(0,0,this.deltaZ).applyMatrix4(this.matrixWorld))}getBox(t){if(!this.initedTextRect)return this.initTextTextureRect(),null;let{clientSize:{width:e,height:i}}=this.context,s=e*(t.x+1)/2,o=i*(-t.y+1)/2,n=new Pr;if(this.options.icon&&this.hasText){let r=Math.max(this.iconWidth,this.textWidth)/2;n.min.set(s-r,o-this.iconHeight-this.durIconAndText-this.textHeight),n.max.set(s+r,o)}else if(this.options.icon){let r=this.iconWidth/2;n.min.set(s-r,o-this.iconHeight/2),n.max.set(s+r,o+this.iconHeight/2)}else if(this.hasText){let r=this.textWidth/2;n.min.set(s-r,o-this.textHeight/2),n.max.set(s+r,o+this.textHeight/2)}else n.min.set(s-2,o-2),n.max.set(s+2,o+2);return this.box=n,this.box}renderBoxHelper(){if(!this.context.debugCollisionBox){var t;(t=this.boxHelper)==null||t.remove(),this.boxHelper=void 0;return}if(!this.boxHelper){let o=document.createElement("div");o.style.position="absolute",o.style.zIndex="99999",o.style.pointerEvents="none",o.style.boxSizing="border-box",this.boxHelper=o,this.context.container.appendChild(o)}let{min:e,max:i}=this.box;this.boxHelper.style.left=e.x+"px",this.boxHelper.style.top=e.y+"px",this.boxHelper.style.width=Math.max(0,i.x-e.x)+"px",this.boxHelper.style.height=Math.max(0,i.y-e.y)+"px";let s=this._shouldShow;this.boxHelper.style.border="1px solid "+(s?"#22c55e":"#ef4444"),this.boxHelper.style.background=s?"rgba(34, 197, 94, 0.08)":"rgba(239, 68, 68, 0.08)"}setVisible(t){if(this.visible=t,this.batchIconReady){var e;(e=this.iconBatch)==null||e.setVisible(this,t&&this._shouldShow)}if(this.batchTextReady){var i;(i=this.textBatch)==null||i.setVisible(this,t&&this._shouldShow)}this.context.forceUpdate()}parentSetVisible(t){t?this.show():this.hide()}clearTextTextureCache(){this.textLayoutMap={},this.textTextureRectMap={}}resetBatchText(){if(this.batchTextReady){var t;(t=this.textBatch)==null||t.removePoi(this)}this.batchTextReady=!1}resetBatchIcon(){if(this.batchIconReady){var t;(t=this.iconBatch)==null||t.removePoi(this)}this.batchIconReady=!1}dispose(){var t;if(this.hide(),this.batchTextReady){var e;(e=this.textBatch)==null||e.removePoi(this)}if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.removePoi(this)}this.batchTextReady=!1,this.batchIconReady=!1,this.textBatch=null,this.iconBatch=null,(t=this.boxHelper)==null||t.remove(),this.boxHelper=void 0,this.clearTextTextureCache(),this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.textCenterY=.5,this.box=new Pr,this._shouldShow=!1,this.textRevision=0,this.visibilityRevision=0,this.iconRevision=0,this.scaleSyncRaf=0,this.textObjects=new Set,this.iconSprites=new Set,this.textLayoutMap={},this.textBatch=null,this.batchTextReady=!1,this.iconBatch=null,this.batchIconReady=!1,this.textTextureRectMap={},this._initTextTexture=()=>g(this,null,function*(){let c=this.options.text,l=this.textTextureKey,p=this.sdfFontSpec;if(!c||this.textLayoutMap[l])return;let d=yield this.layoutText(c,l,p);d&&(c!==this.options.text||l!==this.textTextureKey||(this.textLayoutMap[l]=d,this.textTextureRectMap[c]={width:d.width,height:d.height,lines:d.linesCount,aspect:d.aspect},this.dispatchEvent({type:"text-texture-inited"})))}),this.initTextTexture=this._initTextTexture,this._initTextTextureRect=()=>g(this,null,function*(){let c=this.options.text,l=this.textTextureKey,p=this.sdfFontSpec;if(!c||this.textTextureRectMap[c])return;let d=yield this.layoutText(c,l,p);d&&(c!==this.options.text||l!==this.textTextureKey||(this.textTextureRectMap[c]={width:d.width,height:d.height,lines:d.linesCount,aspect:d.aspect},this.dispatchEvent({type:"text-texture-rect-inited"})))}),this.initTextTextureRect=this._initTextTextureRect,this._initScale=c=>{let{zoom:l}=c;if(this.meshText){let d=this.textHeight/l;this.meshText.scale.set(d,d,1),this.meshBackground&&this.meshBackground.scale.set(d,d,1)}if(this.spriteIcon){var p;(p=this.spriteIcon)==null||p.scale.set(this.options.icon_size[0]/l,this.options.icon_size[1]/l,.1)}this.resetZ()};let s=this.context.config.poiTextBackground,o=e.text_background?w({},s,e.text_background):s;var n;let r=(n=e.text_font_family)!=null?n:this.context.config.poiTextFontFamily;var h;this.options=ye(w({},Xl,e,{text:(h=(i=e.text)==null?void 0:i.trim())!=null?h:"",text_font_family:r,text_background:o}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent()}};var zt=class extends _o{getPosition(){return this.box.getCenter(new Xi)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new Y(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(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+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new wo().setFromObject(this).getCenter(new Xi)}addModel(t){let e=new Ii(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new wo().setFromObject(this.groundUpper),e=t.getCenter(new Xi),i=t.getSize(new Xi);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new et(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}getParkingOptionsByParkingNo(t){return this.parkingSpaceLayer.getParkingOptionsByParkingNo(t)}updateBox(){this.box.setFromObject(this.groundLayer)}getGraphics(){return this.graphicLayer.children.filter(t=>t instanceof Y)}setOpacity(t,e){e===void 0&&(e=!1),this.groundLayer.setOpacity(t,e),this.graphicLayer.setOpacity(t,e),this.mergeGraphicLayer.setOpacity(t,e),this.poiLayer2.setOpacity(t),this.parkingSpaceLayer.setOpacity(t,e),this.laneLayer.setOpacity(t,e),this.wallLayer.setOpacity(t,e),this.textureLayer.setOpacity(t),this.textTextureLayer.setOpacity(t),this.glbModelLayer.setOpacity(t,e),this.userData.opacity=t}dispose(){var t;console.log("floor dispose",this.name),(t=this.shadow)==null||t.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.dispose(),this.grounds.forEach(e=>{var i;return e==null||(i=e.dispose)==null?void 0:i.call(e)}),this.groundUpper.clear(),this.models.children.forEach(e=>{var i;return e==null||(i=e.dispose)==null?void 0:i.call(e)}),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Fi,this.groundUpper=new _o,this.models=new _o,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new wo,this.groundLayer=new q(this.context),this.graphicLayer=new Gi(this.context),this.poiLayer=new Bi(this.context),this.poiLayer2=new Ui(this.context),this.parkingSpaceLayer=new Hi(this.context),this.wallLayer=new q(this.context),this.textureLayer=new q(this.context),this.glbModelLayer=new Ni(this.context),this.laneLayer=new q(this.context),this.mergeGraphicLayer=new Vi(this.context),this.textTextureLayer=new q(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),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.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};import{MeshBasicMaterial as Yl,Object3D as ql,PlaneGeometry as $l,Texture as Jl,Mesh as Ql,Matrix3 as Cr,Vector2 as tp,FrontSide as ep}from"three";import{create as ip}from"@mars3d/heatmap.js";import{bbox as sp,center as op}from"@turf/turf";var Yi=class extends ql{clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){var e;this.clearHeatmap();let{width:i,height:s,leftTop:o,center:n,scale:r}=this.box,h=((e=this.context.config.heatMap)==null?void 0:e.radius)||1,c=w({width:i,height:s,container:this.div},this.context.config.heatMap,{radius:h});this.heatmap=ip(c);let l=this.transformData(t,o,r);t.maxValue!==void 0&&(l.max=t.maxValue),t.minValue!==void 0&&(l.min=t.minValue),this.heatmap.setData(l),this.initPlane(i/r,s/r);let p=this.context.center;this.position.set(n[0]-p[0],n[1]-p[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new $l(t,e),s=new Jl(this.div.firstChild);s.needsUpdate=!0;let o=new Yl({transparent:!0,side:ep,map:s});o.needsUpdate=!0,this.plane=new Ql(i,o),this.plane.renderOrder=1e5,this.add(this.plane)}getTransMatrix(t){let{x:e,y:i}=t;return new Cr().makeScale(this.box.scale,-this.box.scale).multiply(new Cr().makeTranslation(-e,-i))}transformData(t,e,i){var s,o;let n=this.getTransMatrix(e);var r;let h=(r=(s=t.data[0])==null?void 0:s.value)!=null?r:0;var c;let l=(c=(o=t.data[0])==null?void 0:o.value)!=null?c:0;return{data:t.data.map(d=>{let u=new tp(d.x,d.y).applyMatrix3(n);return d.value>h&&(h=d.value),d.value<l&&(l=d.value),{x:Math.ceil(u.x),y:Math.ceil(u.y),value:d.value}}),max:h,min:l}}getBox(){let t=this.context.range,e=sp(t),i=Math.ceil(e[2]-e[0]),s=Math.ceil(e[3]-e[1]),o=4e3,n=4e3,r=o/i,h=n/s,c=Math.min(r,h);this.scaleRatio=c;let l=i*c,p=s*c,d={x:Math.ceil(e[0]),y:Math.ceil(e[3])},u=op(t).geometry.coordinates;return{width:l,height:p,leftTop:d,center:u,scale:c}}dispose(){this.clearHeatmap(),this.div.remove(),this.div=null,this.plane&&(this.remove(this.plane),F(this.plane))}constructor(t){super(),this.context=t,this.scaleRatio=1,this.div=document.createElement("div"),this.box=this.getBox()}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as np,Vector3 as Po}from"three";var dt=class extends np{_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:s,offsetY:o}=t,{clientWidth:n,clientHeight:r}=i.domElement,h=s/n*2-1,c=1-o/r*2;return new Po(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return L(t,e,i.clientWidth,i.clientHeight)}getWorldToDeviceDistance(t){let{camera:e,container:i}=this.context,s=i.clientWidth/2,o=i.clientHeight/2,n=new Po(-1,0,0).unproject(e),r=new Po(1,0,0).unproject(e),h=L(n,e,i.clientWidth,i.clientHeight),c=L(r,e,i.clientWidth,i.clientHeight),l=Math.abs(c.x-h.x)/2;return t*l}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.enable=!0,this._onResize=e=>{let{width:i,height:s}=e;this.svg&&(this.svg.setAttribute("width",""+i),this.svg.setAttribute("height",""+s))},this.svg=cn(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var qi=class extends dt{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:s}]=this.points;return Math.sqrt((i-t)**2+(s-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.points=[],this.onUpdate=()=>{if(this.points[0]){let s=this.getSvgCoordinate(this.points[0]);yt(this.circles[0],s.x,s.y),rt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);yt(this.circles[1],s.x,s.y),rt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",rt(this.line,void 0,{x:s.offsetX,y:s.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=s=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(s);if(o){let{offsetX:n,offsetY:r}=s,h=this.circles[this.points.length];yt(h,n,r),this.points.length||rt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Gt(e.radius,e.fill),Gt(e.radius,e.fill)],this.line=Kt(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};import"core-js/modules/es.array.push.js";var $i=class extends dt{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],s=+i.getAttribute("cx"),o=+i.getAttribute("cy");return Math.sqrt((t-s)**2+(e-o)**2)<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(s=>[s.x,s.y]),e=0,i=t.length;for(let s=0;s<i;s++){let o=(s+1)%i;e+=t[s][0]*t[o][1]-t[o][0]*t[s][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.points=[],this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,i)=>{let s=this.getSvgCoordinate(e);this.circles[i]&&yt(this.circles[i],s.x,s.y),i!==0&&rt(this.lines[i-1],void 0,s),this.lines[i]&&rt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",rt(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let i=this.getIntersectByPointerEvent(e);if(i){let{offsetX:s,offsetY:o}=e;this.checkAdsorb(s,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(i);let{circle:{fill:n,radius:r},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let c=Gt(r,n);yt(c,s,o),this.addCircle(c)}if(this.lines.length&&rt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=Kt(h);rt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};import{Box3 as rp}from"three";var Tr=class extends dt{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let i=new rp().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=L(r,s,o,n),l=L(h,s,o,n);j(this.rect,c.x,l.y,Math.abs(l.x-c.x),Math.abs(l.y-c.y));let{x:p,y:d}=c,{x:u,y:f}=l,x=5,m=[{x:p-x,y:f-x},{x:u-x,y:f-x},{x:p-x,y:d-x},{x:u-x,y:d-x}];for(let E=0;E<m.length;E++)j(this.cornerRect[E],m[E].x,m[E].y,x*2,x*2);let y=4,_=(p+u)/2,P=(d+f)/2,S=[{x:_-y,y:f-y},{x:p-y,y:P-y},{x:u-y,y:P-y},{x:_-y,y:d-y}];for(let E=0;E<S.length;E++)j(this.centerRect[E],S[E].x,S[E].y,y*2,y*2)}else{j(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)j(this.cornerRect[i],0,0,0,0),j(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=gt(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=gt(e.stroke,"#ffffff"),this.centerRect[i]=gt(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}};import"core-js/modules/es.array.push.js";import{BufferGeometry as ap,Color as Mo,LineSegments as hp,Mesh as cp,Object3D as lp,ShaderMaterial as pp,Vector3 as Lr}from"three";import{mergeGeometries as dp}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ji=class extends lp{initGeometry(){return g(this,null,function*(){let t=yield kt.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
559
+ `;return this.instancedWallMaterial=new Ce({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};it(ut,"lineMaterialMap",new Map),it(ut,"meshStandardMaterialMap",new Map),it(ut,"meshBasicMaterialMap",new Map),it(ut,"shaderMaterialMap",new Map),it(ut,"line2MaterialMap",new Map),it(ut,"mergeAttributeGraphicMaterial",null),it(ut,"mergeAttributeWallMaterial",null),it(ut,"mergeAttributeGraphicLineMaterial",null),it(ut,"instancedGraphicMaterial",null),it(ut,"instancedWallMaterial",null),it(ut,"lineDashedMaterialMap",new Map);var Te=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static registerKey(t){this.keySet.add(t)}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};it(Te,"keySet",new Set);function Le(a,t,e){return new Promise((i,s)=>{let o=Te.genUniqueKey(),n=({data:r})=>{r.type===`${t}_result`&&r.key===o&&(Te.removeKey(o),self.removeEventListener("message",n),r.error?s(r.error):i(r.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}import{EventDispatcher as _l}from"three";var ji=class extends _l{constructor(e=10,i){super();it(this,"max",10);it(this,"workerConstructor");it(this,"pool",[]);this.max=e,this.workerConstructor=i}getWorker(){return new Promise(e=>{let i=this.pool.find(o=>o.state==="leisure");if(i){i.state="used",e(i.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let o=this.workerConstructor();this.pool.push({worker:o,state:"used"}),e(o);return}let s=()=>{let o=this.pool.find(n=>n.state==="leisure");o&&(this.removeEventListener("release",s),o.state="used",e(o.worker))};this.addEventListener("release",s)})}releaseWorker(e){let i=this.pool.find(s=>s.worker===e);i&&(i.state="leisure",this.dispatchEvent({type:"release",worker:e}))}dispose(){this._listeners={},this.pool.forEach(e=>{e.worker.terminate()}),this.pool=[]}};function yo(){return new Worker(new URL("./worker/merge-geometry.worker-SQEWCBXS.js",import.meta.url))}import{BufferGeometry as Pl,BufferAttribute as xr}from"three";var ke=class{static GetMergeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Pl;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new xr(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new xr(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static GetMergedGeometryLine(t){return g(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Le(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};it(ke,"WorkerPool",new ji(10,yo));var Vi=class extends q{getCenter(){return new bl().setFromObject(this).getCenter(new vo)}addInstancedGraphic(t){this.instancedGraphicConfig?(this.instancedGraphicConfig.size+=t.size,this.instancedGraphicConfig.colors=[...this.instancedGraphicConfig.colors,...t.colors],this.instancedGraphicConfig.matrixes=[...this.instancedGraphicConfig.matrixes,...t.matrixes],this.instancedGraphicConfig.opacities=[...this.instancedGraphicConfig.opacities,...t.opacities],this.instancedGraphicConfig.maxZs=[...this.instancedGraphicConfig.maxZs,...t.maxZs],this.instancedGraphicConfig.ids=[...this.instancedGraphicConfig.ids,...t.ids]):this.instancedGraphicConfig=t,this.refeshInstancedGraphic()}refeshInstancedGraphic(){this.instancedGraphic&&(this.remove(this.instancedGraphic),F(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new Se(this.context,this.instancedGraphicConfig),this.add(this.instancedGraphic))}addGraphics(t,e){t.map(i=>{this.graphicDataMap.set(i.id,i),this.graphicOriginOptionMap.set(i.id,{fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity})}),e?e.map(i=>{if(i.instancedGeometry&&this.addInstancedGraphic(i.instancedGeometry),i.mergedGeometry){let s=new ei(this.context,w({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new de(this.context,i.lineGeometry);this.mergedLineGroup.add(s)}i.mergedGeometry=null,i.lineGeometry=null}):(this.refreshMergeGraphic(),this.refreshLine())}createGraphic(t){return g(this,null,function*(){let e=yield ke.GetMergedGeometry(t);if(F(this.mergedGraphicGroup),this.mergedGraphicGroup.clear(),e){let i=new ei(this.context,e);this.mergedGraphicGroup.add(i)}})}createLine(t){return g(this,null,function*(){let e=yield ke.GetMergedGeometryLine(t);if(F(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new de(this.context,e.lineGeometry);this.mergedLineGroup.add(i)}})}refreshMergeGraphic(){let t=Array.from(this.graphicDataMap.values());this.instancedGraphicConfig&&(t=t.filter(e=>{var i;return!((i=this.instancedGraphicConfig)!=null&&i.ids.includes(e.id))})),this.createGraphic(t)}refreshLine(){let t=Array.from(this.graphicDataMap.values());this.createLine(t)}removeGraphicById(t){var e;if(this.graphicDataMap.delete(t),(e=this.instancedGraphicConfig)!=null&&e.ids.includes(t)){let i=this.instancedGraphicConfig.ids.findIndex(s=>s===t);this.instancedGraphicConfig.size--,this.instancedGraphicConfig.colors.splice(i*3,3),this.instancedGraphicConfig.matrixes.splice(i*16,16),this.instancedGraphicConfig.opacities.splice(i,1),this.instancedGraphicConfig.maxZs.splice(i,1),this.instancedGraphicConfig.ids.splice(i,1),this.refeshInstancedGraphic()}else this.refreshMergeGraphic();this.refreshLine()}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){var i;let s,o=this.graphicDataMap.get(t);if(o){if(typeof e=="function"?s=e(o):s=w({},o,e),this.graphicDataMap.set(t,s),(i=this.instancedGraphicConfig)!=null&&i.ids.includes(t)&&this.instancedGraphic){this.instancedGraphic.setColorById(t,s.fillColor),this.instancedGraphic.setOpacityById(t,s.fillOpacity),this.instancedGraphic.setMaxZById(t,s.deltaHeight+s.airHeight+s.height);let n=this.instancedGraphicConfig.ids.findIndex(d=>d===t),r=this.instancedGraphicConfig.matrixes.slice(n*16,(n+1)*16),h=new Ml().fromArray(r),c=new vo,l=new El,p=new vo;h.decompose(c,l,p),p.z=s.height,c.z=s.deltaHeight+s.airHeight+s.height/2,h.compose(c,l,p),this.instancedGraphic.setMatrixById(t,h)}else this.refreshMergeGraphic();this.refreshLine()}}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1);var i;this.graphicDataMap.forEach((s,o)=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let h=this.graphicOriginOptionMap.get(o);var n;s.fillOpacity=Math.min(t,(n=h==null?void 0:h.fillOpacity)!=null?n:1);var r;s.strokeOpacity=Math.min(t,(r=h==null?void 0:h.strokeOpacity)!=null?r:1)}}),(i=this.instancedGraphic)==null||i.setOpacity(t,e),this.refeshInstancedGraphic(),this.refreshLine()}dispose(){this.mergedGraphicGroup.children.slice().forEach(t=>{t.dispose==null||t.dispose.call(t)}),this.mergedGraphicGroup.clear(),this.mergedLineGroup.children.slice().forEach(t=>{t.dispose==null||t.dispose.call(t)}),this.mergedLineGroup.clear(),this.instancedGraphic&&(this.remove(this.instancedGraphic),this.instancedGraphic.dispose(),this.instancedGraphic=null),this.instancedGraphicConfig=null,this.graphicMap.clear(),this.graphicDataMap.clear(),this.graphicOriginOptionMap.clear(),super.dispose()}constructor(t){super(t),this.graphicMap=new Map,this.mergedGraphicGroup=new wr,this.mergedLineGroup=new wr,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Group as Tl,Mesh as Ll,MeshBasicMaterial as kl,PlaneGeometry as Al,Vector2 as Dl,Vector3 as xo,Raycaster as Rl,Plane as Ol}from"three";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-collections.iterator.js";import{SRGBColorSpace as Sl,TextureLoader as Cl}from"three";var Ki=class{setBaseUrl(t){this.baseUrl=t.replace(/\/$/,"")}setConfig(t){this.config=t}loadConfig(){return g(this,null,function*(){if(this.config)return this.config;if(!this.baseUrl)throw new Error("Base URL is not set");try{let t=yield fetch(""+this.baseUrl+"/config.json");return this.config=yield t.json(),this.config}catch(t){return console.error("Failed to load tile config:",t),this.config={extent:[12276734621488994e-9,2.1183542845726013e6,12279646804065457e-9,2121524247761597e-9],maxZoom:21,minZoom:11},this.config}})}buildTileUrl(t,e,i){if(!this.baseUrl)throw new Error("Base URL is not set");return this.baseUrl+"/"+i+"/"+t+"/"+e+".png"}loadTileTexture(t,e,i){return g(this,null,function*(){if(!this.baseUrl)throw new Error("Base URL is not set");let s=this.buildTileUrl(t,e,i);if(this.textureCache.has(s)){let n=this.textureCache.get(s);return n instanceof Promise?n:Promise.resolve(n)}let o=this.textureLoader.loadAsync(s).then(n=>(n.flipY=!0,n.colorSpace=Sl,this.textureCache.set(s,n),n)).catch(n=>null);return this.textureCache.set(s,o),o})}clearCache(){this.textureCache.forEach(t=>{t instanceof Promise?t.then(e=>e==null?void 0:e.dispose()):t.dispose()}),this.textureCache.clear()}dispose(){this.clearCache()}constructor(t){this.baseUrl="",this.config=null,this.textureCache=new Map,this.textureLoader=new Cl,t&&this.setBaseUrl(t)}};import{debounce as Fl}from"lodash";var _r={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},ue=class a extends q{loadTileConfig(){return g(this,null,function*(){return this.tileLoader.loadConfig()})}initEvents(){this.context.addEventListener("control-change",this.onUpdate),this.context.bmap.addEventListener("center-change",this.onCenterChange)}removeEvents(){this.context.removeEventListener("control-change",this.onUpdate),this.context.bmap.removeEventListener("center-change",this.onCenterChange)}getViewBounds(){let t=this.context.camera,e=new Rl,i=new Dl,s=[],[o,n]=this.context.center||[0,0],r=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}];for(let d of r){i.set(d.x,d.y),e.setFromCamera(i,t);let u=new xo(0,0,1),f=new xo(0,0,0),x=new Ol().setFromNormalAndCoplanarPoint(u,f),m=new xo;e.ray.intersectPlane(x,m)?s.push(m):(e.ray.direction.negate(),e.ray.intersectPlane(x,m)&&s.push(m))}if(s.length<4)return null;let h=1/0,c=1/0,l=-1/0,p=-1/0;return s.forEach(d=>{h=Math.min(h,d.x+o),c=Math.min(c,d.y+n),l=Math.max(l,d.x+o),p=Math.max(p,d.y+n)}),{minX:h,minY:c,maxX:l,maxY:p}}getTileZoomLevel(t,e){let{minZoom:i,maxZoom:s}=e,o=this.context.camera,n=(o.right-o.left)/o.zoom,r=this.context.clientSize.width,h=n/r,c=a.WORLD_WIDTH,l=Math.log2(c/(h*this.tileSize));return Math.min(s,Math.max(i,Math.round(l)))}getTilesInView(t,e,i){let[s,o,n,r]=i.extent,h=Math.max(t.minX,s),c=Math.max(t.minY,o),l=Math.min(t.maxX,n),p=Math.min(t.maxY,r);if(h>=l||c>=p)return[];let d=Math.pow(2,e),u=a.WORLD_WIDTH/d,f=a.WORLD_WIDTH_HALF,x=Math.max(0,Math.floor((h+f)/u)),m=Math.floor((l+f)/u),y=Math.max(0,Math.floor((f-p)/u)),_=Math.floor((f-c)/u),P=[];for(let S=x;S<=m;S++)for(let E=y;E<=_;E++)P.push({x:S,y:E,z:e});return P}renderTiles(t,e){return g(this,null,function*(){let i=t,s=[];if(this.currentLevel!==e)s=[...this.tileGroup.children];else{let r=this.tileGroup.children,h=r.map(l=>l.userData.key),c=t.map(l=>l.z+"/"+l.x+"/"+l.y);i=t.filter(l=>!h.includes(l.z+"/"+l.x+"/"+l.y)),s=r.filter(l=>!c.includes(l.userData.key))}let o=Math.pow(2,e),n=a.WORLD_WIDTH/o;yield Promise.all(i.map(r=>g(this,null,function*(){let h=r.z+"/"+r.x+"/"+r.y,c=yield this.tileLoader.loadTileTexture(r.x,r.y,r.z);if(c){let l=new kl({map:c,transparent:!0}),p=new Ll(this.baseGeometry,l);p.scale.setX(n).setY(n),p.position.set((r.x-o/2)*n+n/2,-((r.y-o/2)*n)-n/2,0),p.userData.key=h,this.tileGroup.add(p)}}))),this.tileGroup.children.forEach(r=>{s.includes(r)&&(r.material.dispose(),this.tileGroup.remove(r))})})}setVisibility(t){this.visible=t,t&&this.onUpdate()}setOpacity(t){super.setOpacity(t)}clearTiles(){this.tileGroup.children.forEach(t=>{t.material.dispose()}),this.tileGroup.clear()}dispose(){this.removeEvents(),this.clearTiles(),this.baseGeometry.dispose(),this.tileLoader.dispose(),super.dispose()}constructor(t,e){super(t),this.loadedTiles=new Map,this.currentLevel=0,this.tileSize=256,this.baseGeometry=new Al(1,1),this.options=_r,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=Fl(()=>g(this,null,function*(){if(!this.visible)return;let s=yield this.loadTileConfig(),o=this.context.camera,n=this.getViewBounds();if(!n)return;let r=this.getTileZoomLevel(o.zoom,s),h=this.getTilesInView(n,r,s);this.renderTiles(h,r)}),100),this.options=w({},_r,e),this.tileGroup=new Tl;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Ki(this.options.base_url),this.initEvents(),this.updateTiles()}};ue.WORLD_WIDTH=4007501668e-2;ue.WORLD_WIDTH_HALF=ue.WORLD_WIDTH/2;import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.string.trim.js";import{Box2 as Pr,Mesh as br,Object3D as Il,PlaneGeometry as Mr,Sprite as Gl,SpriteMaterial as Bl,Vector3 as zl}from"three";import{mergeGeometries as Wl}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ul=600,Hl="#000000",Nl="#ffffff",Zl=1,jl=400,Vl="sans-serif",Er=6,Sr=3,Kl=4,Xl={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,text_font_weight:jl,text_font_family:Vl,text_outline_width:Zl,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1,icon_alpha_test:.2,text_alpha_test:.2},et=class extends Il{scheduleScaleSync(){if(typeof requestAnimationFrame!="function")return;this.scaleSyncRaf&&cancelAnimationFrame(this.scaleSyncRaf);let t=this.textRevision;this.scaleSyncRaf=requestAnimationFrame(()=>{this.scaleSyncRaf=0,!(t!==this.textRevision||!this.meshText)&&this._initScale({zoom:this.context.camera.zoom})})}get shouldShow(){return this._shouldShow}get sdfFontSpec(){return X.getSpec({fontWeight:this.options.text_font_weight,fontFamily:this.options.text_font_family})}get textTexture(){if(!this.options.text)return null;var t;return(t=X.getTexture(this.sdfFontSpec))!=null?t:null}get textObject(){return this.meshText}get textPivotY(){return this.textCenterY}get isMovingBatchPoi(){return!!this.options.id&&this.options.id.startsWith("navigation_")}get textMaterials(){var t;let e=(t=this.meshText)==null?void 0:t.material;return e?Array.isArray(e)?e:[e]:[]}mergeTextParts(t){if(!t.length)return null;if(t.length===1)return t[0].geometry;let e=Wl(t.map(i=>i.geometry),!0);return t.forEach(i=>i.geometry.dispose()),e}get textTextureRect(){let t=this.options.text;var e;return t&&(e=this.textTextureRectMap[t])!=null?e:null}get textureLines(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.lines)!=null?i:1}get textAspect(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.aspect)!=null?i:1}get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){if(!this.hasText)return 0;let t=this.textLayoutMap[this.textTextureKey];return t?t.height*(this.options.text_font_size/this.sdfFontSpec.fontSize):this.options.text_font_size*this.textureLines}get initedTextRect(){return!this.options.text||this.options.text&&this.textTextureRect}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&this._shouldShow}disposeTextMesh(t){this.textObjects.delete(t),this.remove(t),t.geometry.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>i.dispose())}clearTextObjects(){this.meshText&&this.textObjects.add(this.meshText),this.meshBackground&&this.textObjects.add(this.meshBackground);let t=Array.from(this.textObjects);this.textObjects.clear(),this.meshText=void 0,this.meshBackground=void 0,t.forEach(e=>this.disposeTextMesh(e))}clearIconObjects(){this.spriteIcon&&this.iconSprites.add(this.spriteIcon);let t=Array.from(this.iconSprites);this.iconSprites.clear(),this.spriteIcon=void 0,t.forEach(e=>{this.remove(e),e.material.dispose()})}show(){return g(this,null,function*(){if(this._shouldShow)return;this._shouldShow=!0;let t=++this.visibilityRevision,e=[];if(!this.spriteIcon&&!this.batchIconReady&&this.options.icon&&e.push(this.initIcon()),!this.textObject&&!this.batchTextReady&&this.hasText&&e.push(this.initText()),yield Promise.all(e),t===this.visibilityRevision){if(!this._shouldShow){this.hide();return}if(this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.spriteIcon&&(this.spriteIcon.visible=!0),this.batchIconReady){var i;(i=this.iconBatch)==null||i.setVisible(this,this.visible)}if(this.meshText&&(this.meshText.visible=!0),this.meshBackground&&(this.meshBackground.visible=!0),this.batchTextReady){var s;(s=this.textBatch)==null||s.setVisible(this,this.visible)}this.scheduleScaleSync()}})}hide(){if(this._shouldShow=!1,this.visibilityRevision++,this.textRevision++,this.iconRevision++,this.scaleSyncRaf&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.scaleSyncRaf),this.scaleSyncRaf=0),this.batchIconReady){var t;(t=this.iconBatch)==null||t.setVisible(this,!1)}if(this.clearIconObjects(),this.batchTextReady){var e;(e=this.textBatch)==null||e.setVisible(this,!1)}this.clearTextObjects()}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchIcon(),this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate())})),this.addEventListener("change-text_background",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate())})),this.addEventListener("change-text_font_size",t=>g(this,null,function*(){let{value:e}=t;this.resetBatchText(),this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate()})),this.addEventListener("change-text_font_weight",t=>g(this,null,function*(){let{value:e}=t;this.clearTextTextureCache(),this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate())})),this.addEventListener("change-text_font_family",t=>g(this,null,function*(){let{value:e}=t;this.clearTextTextureCache(),this.resetBatchText(),(yield this.prepareTextLayout())&&(this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate())})),this.addEventListener("change-text_outline_width",t=>{let{value:e}=t;if(this.batchTextReady){var i;(i=this.textBatch)==null||i.setOutlineWidth(this,e)}else{let s=typeof window!="undefined"&&window.devicePixelRatio||1;this.textMaterials.forEach(o=>{o.uniforms.uOutlineWidth.value=e*s})}}),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setRotation(this,e)}else this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setSize(this,[this.options.icon_size[0],this.options.icon_size[1]])}this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.options.icon&&this.context.forceUpdate()}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setDepthTest(this,e)}else this.spriteIcon&&(this.spriteIcon.material.depthTest=e);if(this.batchTextReady){var s;(s=this.textBatch)==null||s.setDepthTest(this,e)}else this.textMaterials.forEach(o=>{o.depthTest=e});this.meshBackground&&(this.meshBackground.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.setOpacity(this,e)}else this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;if(this.batchTextReady){var i;(i=this.textBatch)==null||i.setOpacity(this,e)}else this.textMaterials.forEach(s=>{s.uniforms.uOpacity.value=e})})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return g(this,null,function*(){if(this.options.icon){let t=++this.iconRevision;return new Promise(e=>g(this,null,function*(){let i;if(this.options.icon_border){let{icon:o,icon_size:n,icon_border:r}=this.options;i=yield ht.getUrlTextureBorder(o,n[0]-r.width*2,r)}else i=yield ht.getTextureByUrl(this.options.icon);if(i.needsUpdate=!0,t!==this.iconRevision){e(null);return}if(this.iconBatch&&!this.isMovingBatchPoi){let o=this.hasText?0:.5;this.iconBatch.addPoi(this,i,{size:[this.options.icon_size[0],this.options.icon_size[1]],offsetY:(.5-o)*this.options.icon_size[1],rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity,depthTest:this.options.depth_test,alphaTest:this.options.icon_alpha_test}),this.batchIconReady=!0,this.iconBatch.setVisible(this,this._shouldShow),e(null);return}let s=new Gl(new Bl({map:i,transparent:!0,alphaTest:this.options.icon_alpha_test,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));s.visible=!1,s.renderOrder=1e5+this.options.level,i.needsUpdate=!0,this.clearIconObjects(),this.iconSprites.add(s),this.add(s),this.spriteIcon=s,e(s)}))}})}get textTextureKey(){let t=this.options.text_background||{enable:!1,color:"",opacity:0};return this.options.text+"-"+t.enable+"-"+t.color+"-"+t.opacity+"-"+this.options.text_font_weight+"-"+this.options.text_font_family}prepareTextLayout(){return g(this,null,function*(){let t=this.textTextureKey;return yield this.initTextTexture(),t!==this.textTextureKey?!1:(this.initTextTextureRect(),!0)})}layoutText(t,e,i){return g(this,null,function*(){i===void 0&&(i=this.sdfFontSpec);let s=this.textLayoutMap[e];if(s)return s;let o=yield X.ensureText(t,i);if(t!==this.options.text||e!==this.textTextureKey)return null;let n=wi(t,o.charMap,o.spec,Ul);return this.textLayoutMap[e]=n,n})}initText(){return g(this,null,function*(){var t,e;if(!this.hasText)return;let i=++this.textRevision,s=this.options.text,o=this.textTextureKey,n=this.sdfFontSpec;if(this.textLayoutMap[o]||(yield this.initTextTexture()),i!==this.textRevision||o!==this.textTextureKey||s!==this.options.text)return;let r=this.textLayoutMap[o];if(!r)return;if(this.initSize(),this.textBatch&&!this.isMovingBatchPoi&&!((t=this.options.text_background)!=null&&t.enable)){if(i!==this.textRevision)return;this.clearTextObjects(),this.textBatch.addPoi(this,r),this.batchTextReady=!0,this.textBatch.setVisible(this,this._shouldShow);return}let h=X.getAtlas(n),c=Ue(r,{pivotY:this.textCenterY});if(!c.length)return;let p=r.height*(this.options.text_font_size/n.fontSize)/this.context.camera.zoom,d=typeof window!="undefined"&&window.devicePixelRatio||1,u=c.map(y=>Li({atlas:h.pages[y.page].texture,fillColor:Hl,outlineColor:Nl,outlineWidth:this.options.text_outline_width*d,opacity:this.options.text_opacity,depthTest:this.options.depth_test,edge:1-h.spec.cutoff,billboard:!0})),f=this.mergeTextParts(c);if(!f)return;let x=new br(f,u.length===1?u[0]:u);if(x.visible=!1,x.renderOrder=100001+this.options.level,x.scale.set(p,p,1),i!==this.textRevision||o!==this.textTextureKey){this.disposeTextMesh(x);return}if(this.clearTextObjects(),this.textObjects.add(x),this.meshText=x,this.add(x),(e=this.options.text_background)!=null&&e.enable){var m;this.initBackgroundMesh(r,h.spec),(m=this.meshBackground)==null||m.scale.set(p,p,1)}this._initScale({zoom:this.context.camera.zoom})})}initBackgroundMesh(t,e){let i=this.options.text_background,s=e.fontSize/xi,o=Er*s/t.height,n=Sr*s/t.height,r=t.aspect+o*2,h=1+n*2,c=Kl*s/t.height,l=new Mr(r,h);l.translate(0,.5-this.textCenterY,0);let p=er({color:i.color,opacity:i.opacity,radius:c,size:{width:r,height:h},depthTest:this.options.depth_test,billboard:!0}),d=new br(l,p);d.visible=!1,d.renderOrder=1e5+this.options.level,this.meshBackground&&this.meshBackground!==d&&this.disposeTextMesh(this.meshBackground),this.meshBackground=d,this.textObjects.add(d),this.add(d)}initSize(){var t;let e=0,i=0,{icon:s}=this.options;s?this.hasText?(e=0,i=e*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(e=.5,i=0):this.hasText?(i=.5,e=0):(e=0,i=0);let o=this.textCenterY!==i;if(this.textCenterY=i,(t=this.spriteIcon)==null||t.center.set(.5,e),this.batchIconReady){var n;(n=this.iconBatch)==null||n.setOffsetY(this,(.5-e)*this.options.icon_size[1])}o&&this.meshText&&this.rebuildTextMeshes()}rebuildTextMeshes(){var t;let e=this.textLayoutMap[this.textTextureKey];if(!e||!this.meshText)return;let i=this.mergeTextParts(Ue(e,{pivotY:this.textCenterY}));i&&(this.meshText.geometry.dispose(),this.meshText.geometry=i,this.meshBackground&&((t=this.options.text_background)!=null&&t.enable)&&(this.meshBackground.geometry.dispose(),this.meshBackground.geometry=this.buildBackgroundGeometry(e)))}buildBackgroundGeometry(t){let i=X.getAtlas(this.sdfFontSpec).spec.fontSize/xi,s=Er*i/t.height,o=Sr*i/t.height,n=t.aspect+s*2,r=1+o*2,h=new Mr(n,r);return h.translate(0,.5-this.textCenterY,0),h}init(){return g(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.scheduleScaleSync()})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.meshText&&(this.meshText.position.z=t),this.meshBackground&&(this.meshBackground.position.z=t-.001)}getLabelOriginWorldPosition(t){t===void 0&&(t=new zl);let e=this.meshText||this.meshBackground||this.spriteIcon;return e?e.getWorldPosition(t):(this.updateWorldMatrix(!0,!1),t.set(0,0,this.deltaZ).applyMatrix4(this.matrixWorld))}getBox(t){if(!this.initedTextRect)return this.initTextTextureRect(),null;let{clientSize:{width:e,height:i}}=this.context,s=e*(t.x+1)/2,o=i*(-t.y+1)/2,n=new Pr;if(this.options.icon&&this.hasText){let r=Math.max(this.iconWidth,this.textWidth)/2;n.min.set(s-r,o-this.iconHeight-this.durIconAndText-this.textHeight),n.max.set(s+r,o)}else if(this.options.icon){let r=this.iconWidth/2;n.min.set(s-r,o-this.iconHeight/2),n.max.set(s+r,o+this.iconHeight/2)}else if(this.hasText){let r=this.textWidth/2;n.min.set(s-r,o-this.textHeight/2),n.max.set(s+r,o+this.textHeight/2)}else n.min.set(s-2,o-2),n.max.set(s+2,o+2);return this.box=n,this.box}renderBoxHelper(){if(!this.context.debugCollisionBox){var t;(t=this.boxHelper)==null||t.remove(),this.boxHelper=void 0;return}if(!this.boxHelper){let o=document.createElement("div");o.style.position="absolute",o.style.zIndex="99999",o.style.pointerEvents="none",o.style.boxSizing="border-box",this.boxHelper=o,this.context.container.appendChild(o)}let{min:e,max:i}=this.box;this.boxHelper.style.left=e.x+"px",this.boxHelper.style.top=e.y+"px",this.boxHelper.style.width=Math.max(0,i.x-e.x)+"px",this.boxHelper.style.height=Math.max(0,i.y-e.y)+"px";let s=this._shouldShow;this.boxHelper.style.border="1px solid "+(s?"#22c55e":"#ef4444"),this.boxHelper.style.background=s?"rgba(34, 197, 94, 0.08)":"rgba(239, 68, 68, 0.08)"}setVisible(t){if(this.visible=t,this.batchIconReady){var e;(e=this.iconBatch)==null||e.setVisible(this,t&&this._shouldShow)}if(this.batchTextReady){var i;(i=this.textBatch)==null||i.setVisible(this,t&&this._shouldShow)}this.context.forceUpdate()}parentSetVisible(t){t?this.show():this.hide()}clearTextTextureCache(){this.textLayoutMap={},this.textTextureRectMap={}}resetBatchText(){if(this.batchTextReady){var t;(t=this.textBatch)==null||t.removePoi(this)}this.batchTextReady=!1}resetBatchIcon(){if(this.batchIconReady){var t;(t=this.iconBatch)==null||t.removePoi(this)}this.batchIconReady=!1}dispose(){var t;if(this.hide(),this.batchTextReady){var e;(e=this.textBatch)==null||e.removePoi(this)}if(this.batchIconReady){var i;(i=this.iconBatch)==null||i.removePoi(this)}this.batchTextReady=!1,this.batchIconReady=!1,this.textBatch=null,this.iconBatch=null,(t=this.boxHelper)==null||t.remove(),this.boxHelper=void 0,this.clearTextTextureCache(),this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.textCenterY=.5,this.box=new Pr,this._shouldShow=!1,this.textRevision=0,this.visibilityRevision=0,this.iconRevision=0,this.scaleSyncRaf=0,this.textObjects=new Set,this.iconSprites=new Set,this.textLayoutMap={},this.textBatch=null,this.batchTextReady=!1,this.iconBatch=null,this.batchIconReady=!1,this.textTextureRectMap={},this._initTextTexture=()=>g(this,null,function*(){let c=this.options.text,l=this.textTextureKey,p=this.sdfFontSpec;if(!c||this.textLayoutMap[l])return;let d=yield this.layoutText(c,l,p);d&&(c!==this.options.text||l!==this.textTextureKey||(this.textLayoutMap[l]=d,this.textTextureRectMap[c]={width:d.width,height:d.height,lines:d.linesCount,aspect:d.aspect},this.dispatchEvent({type:"text-texture-inited"})))}),this.initTextTexture=this._initTextTexture,this._initTextTextureRect=()=>g(this,null,function*(){let c=this.options.text,l=this.textTextureKey,p=this.sdfFontSpec;if(!c||this.textTextureRectMap[c])return;let d=yield this.layoutText(c,l,p);d&&(c!==this.options.text||l!==this.textTextureKey||(this.textTextureRectMap[c]={width:d.width,height:d.height,lines:d.linesCount,aspect:d.aspect},this.dispatchEvent({type:"text-texture-rect-inited"})))}),this.initTextTextureRect=this._initTextTextureRect,this._initScale=c=>{let{zoom:l}=c;if(this.meshText){let d=this.textHeight/l;this.meshText.scale.set(d,d,1),this.meshBackground&&this.meshBackground.scale.set(d,d,1)}if(this.spriteIcon){var p;(p=this.spriteIcon)==null||p.scale.set(this.options.icon_size[0]/l,this.options.icon_size[1]/l,.1)}this.resetZ()};let s=this.context.config.poiTextBackground,o=e.text_background?w({},s,e.text_background):s;var n;let r=(n=e.text_font_family)!=null?n:this.context.config.poiTextFontFamily;var h;this.options=ye(w({},Xl,e,{text:(h=(i=e.text)==null?void 0:i.trim())!=null?h:"",text_font_family:r,text_background:o}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent()}};var zt=class extends _o{getPosition(){return this.box.getCenter(new Xi)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new Y(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(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+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new wo().setFromObject(this).getCenter(new Xi)}addModel(t){let e=new Ii(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new wo().setFromObject(this.groundUpper),e=t.getCenter(new Xi),i=t.getSize(new Xi);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new et(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}getParkingOptionsByParkingNo(t){return this.parkingSpaceLayer.getParkingOptionsByParkingNo(t)}updateBox(){this.box.setFromObject(this.groundLayer)}getGraphics(){return this.graphicLayer.children.filter(t=>t instanceof Y)}setOpacity(t,e){e===void 0&&(e=!1),this.groundLayer.setOpacity(t,e),this.graphicLayer.setOpacity(t,e),this.mergeGraphicLayer.setOpacity(t,e),this.poiLayer2.setOpacity(t),this.parkingSpaceLayer.setOpacity(t,e),this.laneLayer.setOpacity(t,e),this.wallLayer.setOpacity(t,e),this.textureLayer.setOpacity(t),this.textTextureLayer.setOpacity(t),this.glbModelLayer.setOpacity(t,e),this.userData.opacity=t}dispose(){var t;console.log("floor dispose",this.name),(t=this.shadow)==null||t.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.dispose(),this.grounds.forEach(e=>{var i;return e==null||(i=e.dispose)==null?void 0:i.call(e)}),this.groundUpper.clear(),this.models.children.forEach(e=>{var i;return e==null||(i=e.dispose)==null?void 0:i.call(e)}),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Fi,this.groundUpper=new _o,this.models=new _o,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new wo,this.groundLayer=new q(this.context),this.graphicLayer=new Gi(this.context),this.poiLayer=new Bi(this.context),this.poiLayer2=new Ui(this.context),this.parkingSpaceLayer=new Hi(this.context),this.wallLayer=new q(this.context),this.textureLayer=new q(this.context),this.glbModelLayer=new Ni(this.context),this.laneLayer=new q(this.context),this.mergeGraphicLayer=new Vi(this.context),this.textTextureLayer=new q(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),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.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};import{MeshBasicMaterial as Yl,Object3D as ql,PlaneGeometry as $l,Texture as Jl,Mesh as Ql,Matrix3 as Cr,Vector2 as tp,FrontSide as ep}from"three";import{create as ip}from"@mars3d/heatmap.js";import{bbox as sp,center as op}from"@turf/turf";var Yi=class extends ql{clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){var e;this.clearHeatmap();let{width:i,height:s,leftTop:o,center:n,scale:r}=this.box,h=((e=this.context.config.heatMap)==null?void 0:e.radius)||1,c=w({width:i,height:s,container:this.div},this.context.config.heatMap,{radius:h});this.heatmap=ip(c);let l=this.transformData(t,o,r);t.maxValue!==void 0&&(l.max=t.maxValue),t.minValue!==void 0&&(l.min=t.minValue),this.heatmap.setData(l),this.initPlane(i/r,s/r);let p=this.context.center;this.position.set(n[0]-p[0],n[1]-p[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new $l(t,e),s=new Jl(this.div.firstChild);s.needsUpdate=!0;let o=new Yl({transparent:!0,side:ep,map:s});o.needsUpdate=!0,this.plane=new Ql(i,o),this.plane.renderOrder=1e5,this.add(this.plane)}getTransMatrix(t){let{x:e,y:i}=t;return new Cr().makeScale(this.box.scale,-this.box.scale).multiply(new Cr().makeTranslation(-e,-i))}transformData(t,e,i){var s,o;let n=this.getTransMatrix(e);var r;let h=(r=(s=t.data[0])==null?void 0:s.value)!=null?r:0;var c;let l=(c=(o=t.data[0])==null?void 0:o.value)!=null?c:0;return{data:t.data.map(d=>{let u=new tp(d.x,d.y).applyMatrix3(n);return d.value>h&&(h=d.value),d.value<l&&(l=d.value),{x:Math.ceil(u.x),y:Math.ceil(u.y),value:d.value}}),max:h,min:l}}getBox(){let t=this.context.range,e=sp(t),i=Math.ceil(e[2]-e[0]),s=Math.ceil(e[3]-e[1]),o=4e3,n=4e3,r=o/i,h=n/s,c=Math.min(r,h);this.scaleRatio=c;let l=i*c,p=s*c,d={x:Math.ceil(e[0]),y:Math.ceil(e[3])},u=op(t).geometry.coordinates;return{width:l,height:p,leftTop:d,center:u,scale:c}}dispose(){this.clearHeatmap(),this.div.remove(),this.div=null,this.plane&&(this.remove(this.plane),F(this.plane))}constructor(t){super(),this.context=t,this.scaleRatio=1,this.div=document.createElement("div"),this.box=this.getBox()}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as np,Vector3 as Po}from"three";var dt=class extends np{_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:s,offsetY:o}=t,{clientWidth:n,clientHeight:r}=i.domElement,h=s/n*2-1,c=1-o/r*2;return new Po(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return L(t,e,i.clientWidth,i.clientHeight)}getWorldToDeviceDistance(t){let{camera:e,container:i}=this.context,s=i.clientWidth/2,o=i.clientHeight/2,n=new Po(-1,0,0).unproject(e),r=new Po(1,0,0).unproject(e),h=L(n,e,i.clientWidth,i.clientHeight),c=L(r,e,i.clientWidth,i.clientHeight),l=Math.abs(c.x-h.x)/2;return t*l}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.enable=!0,this._onResize=e=>{let{width:i,height:s}=e;this.svg&&(this.svg.setAttribute("width",""+i),this.svg.setAttribute("height",""+s))},this.svg=cn(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var qi=class extends dt{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:s}]=this.points;return Math.sqrt((i-t)**2+(s-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.points=[],this.onUpdate=()=>{if(this.points[0]){let s=this.getSvgCoordinate(this.points[0]);yt(this.circles[0],s.x,s.y),rt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);yt(this.circles[1],s.x,s.y),rt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",rt(this.line,void 0,{x:s.offsetX,y:s.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=s=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(s);if(o){let{offsetX:n,offsetY:r}=s,h=this.circles[this.points.length];yt(h,n,r),this.points.length||rt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Gt(e.radius,e.fill),Gt(e.radius,e.fill)],this.line=Kt(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};import"core-js/modules/es.array.push.js";var $i=class extends dt{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],s=+i.getAttribute("cx"),o=+i.getAttribute("cy");return Math.sqrt((t-s)**2+(e-o)**2)<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(s=>[s.x,s.y]),e=0,i=t.length;for(let s=0;s<i;s++){let o=(s+1)%i;e+=t[s][0]*t[o][1]-t[o][0]*t[s][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.points=[],this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,i)=>{let s=this.getSvgCoordinate(e);this.circles[i]&&yt(this.circles[i],s.x,s.y),i!==0&&rt(this.lines[i-1],void 0,s),this.lines[i]&&rt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",rt(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let i=this.getIntersectByPointerEvent(e);if(i){let{offsetX:s,offsetY:o}=e;this.checkAdsorb(s,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(i);let{circle:{fill:n,radius:r},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let c=Gt(r,n);yt(c,s,o),this.addCircle(c)}if(this.lines.length&&rt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=Kt(h);rt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};import{Box3 as rp}from"three";var Tr=class extends dt{setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let i=new rp().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=L(r,s,o,n),l=L(h,s,o,n);j(this.rect,c.x,l.y,Math.abs(l.x-c.x),Math.abs(l.y-c.y));let{x:p,y:d}=c,{x:u,y:f}=l,x=5,m=[{x:p-x,y:f-x},{x:u-x,y:f-x},{x:p-x,y:d-x},{x:u-x,y:d-x}];for(let E=0;E<m.length;E++)j(this.cornerRect[E],m[E].x,m[E].y,x*2,x*2);let y=4,_=(p+u)/2,P=(d+f)/2,S=[{x:_-y,y:f-y},{x:p-y,y:P-y},{x:u-y,y:P-y},{x:_-y,y:d-y}];for(let E=0;E<S.length;E++)j(this.centerRect[E],S[E].x,S[E].y,y*2,y*2)}else{j(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)j(this.cornerRect[i],0,0,0,0),j(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=gt(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=gt(e.stroke,"#ffffff"),this.centerRect[i]=gt(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}};import"core-js/modules/es.array.push.js";import{BufferGeometry as ap,Color as bo,LineSegments as hp,Mesh as cp,Object3D as lp,ShaderMaterial as pp,Vector3 as Lr}from"three";import{mergeGeometries as dp}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ji=class extends lp{initGeometry(){return g(this,null,function*(){let t=yield kt.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
560
560
  varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
561
561
  uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
562
562
  uniform vec3 uColor;
@@ -595,7 +595,7 @@ void main() {
595
595
  gl_FragColor = vec4(vColor, uOpacity); // \u5176\u4ED6\u9762\u989C\u8272\uFF09
596
596
  }
597
597
  }
598
- `,i=-1/0,s=1/0,o=this.geometry.getAttribute("position");if(o)for(let r=0;r<o.count;r++){let h=o.getZ(r);h>i&&(i=h),h<s&&(s=h)}let n=new pp({uniforms:{maxZ:{value:i},uColor:{value:new Mo(this.options[0].fillColor)},uGradualColor1:{value:new Mo(Xt(this.options[0].fillColor,.99))},uGradualColor2:{value:new Mo(Xt(this.options[0].fillColor,.9))},uOpacity:{value:this.options[0].fillOpacity},minZ:{value:s}},vertexShader:t,fragmentShader:e,transparent:!0});this.material=n}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],i=C.createLineMaterial({color:t,opacity:e});return this.lineMaterial=i,i}getBorderPoints(t){let{height:e,deltaHeight:i,geometry:s}=t,o=[],n=e+(i||0),{coords:r}=s;for(let h=0;h<r.length;h++){let c=r[h];for(let l=0;l<c.length;l++){let p=c[l],d=l+1===c.length?c[0]:c[l+1];o.push(new Lr(p[0],p[1],n)),o.push(new Lr(d[0],d[1],n))}}return o}initLineGeometry(){let t=this.options.map(e=>{let i=this.getBorderPoints(e);return new ap().setFromPoints(i)});this.lineGeometry=dp(t)}createBorder(){let t=new hp(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}setOpacity(t,e){e===void 0&&(e=!1),e?this.material.uniforms.uOpacity.value=t:this.material.uniforms.uOpacity.value=Math.min(t,this.originFillOpacity),this.material.needsUpdate=!0}init(){return g(this,null,function*(){yield this.initGeometry(),this.initMaterial();let t=new cp(this.geometry,this.material);this.add(t),this.options[0].strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry())})}dispose(){var t,e,i;(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.lineGeometry)==null||i.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.originFillOpacity=1,e.length&&(this.originFillOpacity=e[0].fillOpacity,this.init())}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{Float32BufferAttribute as up,FrontSide as mp,InstancedMesh as fp,Matrix4 as gp,MeshBasicMaterial as yp,Object3D as vp,Quaternion as xp,Shape as wp,ShapeGeometry as _p,Vector2 as Qi,Vector3 as bo}from"three";var Eo={id:"",uuid:"",iconUrl:"",name:"",airHeight:0,deltaHeight:0,height:0,geometry:{cds:[],type:"polygon",coords:[],curveCpt:[],curveIndex:[]},opacity:1,visible:!0,centerCoords:[0,0],secondWidth:0,secondHeight:0,secondRotate:0},le=class extends vp{init(){return g(this,null,function*(){let t=this.options.reduce((s,o)=>{let{iconUrl:n}=o;return s.has(n)||s.set(n,[]),s.get(n).push(o),s},new Map),e=Array.from(t.values());(yield Promise.all(e.map(s=>g(this,null,function*(){let o=s[0].iconUrl,n=yield ht.getTextureByUrl(o);return new yp({map:n,transparent:!0,alphaTest:.2,side:mp})})))).forEach((s,o)=>{let n=new fp(this.geometry,s,e[o].length);e[o].forEach((r,h)=>{let c=new gp().compose(new bo(r.centerCoords[0],r.centerCoords[1],r.deltaHeight+r.airHeight+r.height),new xp().setFromAxisAngle(new bo(0,0,1),r.secondRotate),new bo(r.secondWidth,r.secondHeight,1));n.setMatrixAt(h,c)}),this.add(n)}),this.position.z+=.004})}setOpacity(t){this.children.forEach(e=>{e.material.opacity=t,e.material.needsUpdate=!0})}dispose(){F(this),this.clear()}constructor(t,e){super(),this.context=t,this.geometry=new _p(new wp([new Qi(-.5,-.5),new Qi(-.5,.5),new Qi(.5,.5),new Qi(.5,-.5)])),this.options=e.map(s=>w({},Eo,s));let i=new up([0,0,0,1,1,1,1,0],2);this.geometry.setAttribute("uv",i),this.init()}};import{Box3 as Pp,Mesh as Mp,Object3D as bp,Vector3 as Ep}from"three";var Sp={url:"",geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},id:"",width:0,rotate:1,airHeight:1,deltaHeight:0,center_x:0,center_y:0},kr=class extends bp{loadModel(){return g(this,null,function*(){let t=yield pt.loadModel(this.options.url);t.scene.updateMatrixWorld(),t.scene.rotation.set(Math.PI/2,0,0);let i=new Pp().setFromObject(t.scene).getSize(new Ep),s=Math.max(i.x,i.y),o=this.options.width/s;this.scale.set(o,o,o),this.meshSetMaterial(t.scene),this.add(t.scene),this.position.set(this.options.center_x,this.options.center_y,0),this.position.z+=this.options.airHeight+this.options.deltaHeight,this.model=t,this.rotateZ(this.options.rotate),this.dispatchEvent({type:"load-model-end",object:t})})}meshSetMaterial(t){t instanceof Mp&&(t.material.emissiveIntensity=.5,t.material.shininess=0,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map),t.children.forEach(i=>{this.meshSetMaterial(i)})}dispose(){F(this),this.model=null,this._listeners={}}constructor(t,e){super(),this.context=t,this.model=null,this.options=Object.assign({},Sp,e),this.loadModel()}};import"core-js/modules/es.array.push.js";import{BufferGeometry as Cp,Color as Tp,LineSegments as Lp,Mesh as kp,Object3D as Ap,Vector2 as Dp,Vector3 as Ar}from"three";import{mergeGeometries as Rp}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{LineSegments2 as Op}from"three/examples/jsm/lines/LineSegments2.js";import{LineSegmentsGeometry as Fp}from"three/examples/jsm/lines/LineSegmentsGeometry.js";var ts=class extends Ap{initGeometry(){return g(this,null,function*(){this.geometry=yield kt.GetMergedShapeGeometry(this.options)})}initMaterial(){let t=C.createMeshBasicMaterial({color:"#ffffff",opacity:1,vertexColors:!0});return this.material=t,t}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],i=C.createLineMaterial({color:t,opacity:e,vertexColors:!0});return this.lineMaterial=i,i}getBorderPoints(t){let{deltaHeight:e,geometry:i}=t,s=[],o=e||0,{coords:n}=i;for(let r=0;r<n.length;r++){let h=n[r];for(let c=0;c<h.length;c++){let l=h[c],p=c+1===h.length?h[0]:h[c+1];s.push(new Ar(l[0],l[1],o)),s.push(new Ar(p[0],p[1],o))}}return s}initDoubleLine(){let t=this.options.filter(e=>{var i,s;return e.double&&((s=e.geometry.otherCoords)==null||(i=s[1])==null?void 0:i.length)});t.length&&[!0,!1].forEach(e=>{let i=t.filter(c=>c.dashed===e);if(!i.length)return;let s=C.createLine2MaterialMap({color:"#ffffff",width:.2,dashed:e,resolution:new Dp(this.context.clientSize.width,this.context.clientSize.height),vertexColors:!0}),o=[],n=[];i.forEach(c=>{let l=c.geometry.otherCoords[1],p=c.airHeight+(c.deltaHeight||0)+.01,d=new Tp(c.secondColor);for(let u=0;u<l.length-1;u++){let f=l[u],x=l[u+1];o.push(f[0],f[1],p,x[0],x[1],p),n.push(d.r,d.g,d.b,d.r,d.g,d.b)}});let r=new Fp;r.setPositions(o),r.setColors(n);let h=new Op(r,s);h.computeLineDistances(),h.position.z+=.01,this.add(h),this.doubleLines.push(h)})}initLineGeometry(){let t=this.options.map(e=>{let i=this.getBorderPoints(e);return new Cp().setFromPoints(i)});this.lineGeometry=Rp(t)}createBorder(){let t=new Lp(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}init(){return g(this,null,function*(){yield this.initGeometry(),this.initMaterial();let t=new kp(this.geometry,this.material);this.add(t),this.initDoubleLine(),this.position.z+=.02+(this.options[0].deltaHeight||0)})}dispose(){var t,e;(t=this.geometry)==null||t.dispose(),(e=this.lineGeometry)==null||e.dispose(),this.doubleLines.map(i=>i.geometry.dispose()),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.doubleLines=[],e.length&&this.init()}};import"core-js/modules/es.array.push.js";import{Object3D as Ip,Mesh as Gp,Vector3 as Dr,BufferGeometry as Bp,LineSegments as zp,ShaderMaterial as Wp,Color as Rr,ObjectLoader as Up}from"three";var Or=class extends Ip{initMergedElement(){let t=new Up,e=t.parseGeometries([this.mergedElement.mergedGeometry]);if(this.geometry=e[this.mergedElement.mergedGeometry.uuid],this.initMaterial(),this.initMesh(),this.mesh.position.z=(this.mergedElement.deltaHeight||0)+this.mergedElement.airHeight,this.mergedElement.lineGeometry){let i=t.parseGeometries([this.mergedElement.lineGeometry]);this.lineGeometry=i[this.mergedElement.lineGeometry.uuid],this.initLineMaterial(),this.createBorder()}}init(){return g(this,null,function*(){this.geometry=yield this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options[0].deltaHeight+this.options[0].airHeight,this.options[0].strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())})}initGeometry(){return g(this,null,function*(){let t=yield kt.GetMergeGeometry(this.options);return this.dispatchEvent({type:"init-geometry",geometry:t}),t})}initMaterial(){let t=`
598
+ `,i=-1/0,s=1/0,o=this.geometry.getAttribute("position");if(o)for(let r=0;r<o.count;r++){let h=o.getZ(r);h>i&&(i=h),h<s&&(s=h)}let n=new pp({uniforms:{maxZ:{value:i},uColor:{value:new bo(this.options[0].fillColor)},uGradualColor1:{value:new bo(Xt(this.options[0].fillColor,.99))},uGradualColor2:{value:new bo(Xt(this.options[0].fillColor,.9))},uOpacity:{value:this.options[0].fillOpacity},minZ:{value:s}},vertexShader:t,fragmentShader:e,transparent:!0});this.material=n}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],i=C.createLineMaterial({color:t,opacity:e});return this.lineMaterial=i,i}getBorderPoints(t){let{height:e,deltaHeight:i,geometry:s}=t,o=[],n=e+(i||0),{coords:r}=s;for(let h=0;h<r.length;h++){let c=r[h];for(let l=0;l<c.length;l++){let p=c[l],d=l+1===c.length?c[0]:c[l+1];o.push(new Lr(p[0],p[1],n)),o.push(new Lr(d[0],d[1],n))}}return o}initLineGeometry(){let t=this.options.map(e=>{let i=this.getBorderPoints(e);return new ap().setFromPoints(i)});this.lineGeometry=dp(t)}createBorder(){let t=new hp(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}setOpacity(t,e){e===void 0&&(e=!1),e?this.material.uniforms.uOpacity.value=t:this.material.uniforms.uOpacity.value=Math.min(t,this.originFillOpacity),this.material.needsUpdate=!0}init(){return g(this,null,function*(){yield this.initGeometry(),this.initMaterial();let t=new cp(this.geometry,this.material);this.add(t),this.options[0].strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry())})}dispose(){var t,e,i;(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.lineGeometry)==null||i.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.originFillOpacity=1,e.length&&(this.originFillOpacity=e[0].fillOpacity,this.init())}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{Float32BufferAttribute as up,FrontSide as mp,InstancedMesh as fp,Matrix4 as gp,MeshBasicMaterial as yp,Object3D as vp,Quaternion as xp,Shape as wp,ShapeGeometry as _p,Vector2 as Qi,Vector3 as Mo}from"three";var Eo={id:"",uuid:"",iconUrl:"",name:"",airHeight:0,deltaHeight:0,height:0,geometry:{cds:[],type:"polygon",coords:[],curveCpt:[],curveIndex:[]},opacity:1,visible:!0,centerCoords:[0,0],secondWidth:0,secondHeight:0,secondRotate:0},le=class extends vp{init(){return g(this,null,function*(){let t=this.options.reduce((s,o)=>{let{iconUrl:n}=o;return s.has(n)||s.set(n,[]),s.get(n).push(o),s},new Map),e=Array.from(t.values());(yield Promise.all(e.map(s=>g(this,null,function*(){let o=s[0].iconUrl,n=yield ht.getTextureByUrl(o);return new yp({map:n,transparent:!0,alphaTest:.2,side:mp})})))).forEach((s,o)=>{let n=new fp(this.geometry,s,e[o].length);e[o].forEach((r,h)=>{let c=new gp().compose(new Mo(r.centerCoords[0],r.centerCoords[1],r.deltaHeight+r.airHeight+r.height),new xp().setFromAxisAngle(new Mo(0,0,1),r.secondRotate),new Mo(r.secondWidth,r.secondHeight,1));n.setMatrixAt(h,c)}),this.add(n)}),this.position.z+=.004})}setOpacity(t){this.children.forEach(e=>{e.material.opacity=t,e.material.needsUpdate=!0})}dispose(){F(this),this.clear()}constructor(t,e){super(),this.context=t,this.geometry=new _p(new wp([new Qi(-.5,-.5),new Qi(-.5,.5),new Qi(.5,.5),new Qi(.5,-.5)])),this.options=e.map(s=>w({},Eo,s));let i=new up([0,0,0,1,1,1,1,0],2);this.geometry.setAttribute("uv",i),this.init()}};import{Box3 as Pp,Mesh as bp,Object3D as Mp,Vector3 as Ep}from"three";var Sp={url:"",geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},id:"",width:0,rotate:1,airHeight:1,deltaHeight:0,center_x:0,center_y:0},kr=class extends Mp{loadModel(){return g(this,null,function*(){let t=yield pt.loadModel(this.options.url);t.scene.updateMatrixWorld(),t.scene.rotation.set(Math.PI/2,0,0);let i=new Pp().setFromObject(t.scene).getSize(new Ep),s=Math.max(i.x,i.y),o=this.options.width/s;this.scale.set(o,o,o),this.meshSetMaterial(t.scene),this.add(t.scene),this.position.set(this.options.center_x,this.options.center_y,0),this.position.z+=this.options.airHeight+this.options.deltaHeight,this.model=t,this.rotateZ(this.options.rotate),this.dispatchEvent({type:"load-model-end",object:t})})}meshSetMaterial(t){t instanceof bp&&(t.material.emissiveIntensity=.5,t.material.shininess=0,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map),t.children.forEach(i=>{this.meshSetMaterial(i)})}dispose(){F(this),this.model=null,this._listeners={}}constructor(t,e){super(),this.context=t,this.model=null,this.options=Object.assign({},Sp,e),this.loadModel()}};import"core-js/modules/es.array.push.js";import{BufferGeometry as Cp,Color as Tp,LineSegments as Lp,Mesh as kp,Object3D as Ap,Vector2 as Dp,Vector3 as Ar}from"three";import{mergeGeometries as Rp}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{LineSegments2 as Op}from"three/examples/jsm/lines/LineSegments2.js";import{LineSegmentsGeometry as Fp}from"three/examples/jsm/lines/LineSegmentsGeometry.js";var ts=class extends Ap{initGeometry(){return g(this,null,function*(){this.geometry=yield kt.GetMergedShapeGeometry(this.options)})}initMaterial(){let t=C.createMeshBasicMaterial({color:"#ffffff",opacity:1,vertexColors:!0});return this.material=t,t}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],i=C.createLineMaterial({color:t,opacity:e,vertexColors:!0});return this.lineMaterial=i,i}getBorderPoints(t){let{deltaHeight:e,geometry:i}=t,s=[],o=e||0,{coords:n}=i;for(let r=0;r<n.length;r++){let h=n[r];for(let c=0;c<h.length;c++){let l=h[c],p=c+1===h.length?h[0]:h[c+1];s.push(new Ar(l[0],l[1],o)),s.push(new Ar(p[0],p[1],o))}}return s}initDoubleLine(){let t=this.options.filter(e=>{var i,s;return e.double&&((s=e.geometry.otherCoords)==null||(i=s[1])==null?void 0:i.length)});t.length&&[!0,!1].forEach(e=>{let i=t.filter(c=>c.dashed===e);if(!i.length)return;let s=C.createLine2MaterialMap({color:"#ffffff",width:.2,dashed:e,resolution:new Dp(this.context.clientSize.width,this.context.clientSize.height),vertexColors:!0}),o=[],n=[];i.forEach(c=>{let l=c.geometry.otherCoords[1],p=c.airHeight+(c.deltaHeight||0)+.01,d=new Tp(c.secondColor);for(let u=0;u<l.length-1;u++){let f=l[u],x=l[u+1];o.push(f[0],f[1],p,x[0],x[1],p),n.push(d.r,d.g,d.b,d.r,d.g,d.b)}});let r=new Fp;r.setPositions(o),r.setColors(n);let h=new Op(r,s);h.computeLineDistances(),h.position.z+=.01,this.add(h),this.doubleLines.push(h)})}initLineGeometry(){let t=this.options.map(e=>{let i=this.getBorderPoints(e);return new Cp().setFromPoints(i)});this.lineGeometry=Rp(t)}createBorder(){let t=new Lp(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}init(){return g(this,null,function*(){yield this.initGeometry(),this.initMaterial();let t=new kp(this.geometry,this.material);this.add(t),this.initDoubleLine(),this.position.z+=.02+(this.options[0].deltaHeight||0)})}dispose(){var t,e;(t=this.geometry)==null||t.dispose(),(e=this.lineGeometry)==null||e.dispose(),this.doubleLines.map(i=>i.geometry.dispose()),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.doubleLines=[],e.length&&this.init()}};import"core-js/modules/es.array.push.js";import{Object3D as Ip,Mesh as Gp,Vector3 as Dr,BufferGeometry as Bp,LineSegments as zp,ShaderMaterial as Wp,Color as Rr,ObjectLoader as Up}from"three";var Or=class extends Ip{initMergedElement(){let t=new Up,e=t.parseGeometries([this.mergedElement.mergedGeometry]);if(this.geometry=e[this.mergedElement.mergedGeometry.uuid],this.initMaterial(),this.initMesh(),this.mesh.position.z=(this.mergedElement.deltaHeight||0)+this.mergedElement.airHeight,this.mergedElement.lineGeometry){let i=t.parseGeometries([this.mergedElement.lineGeometry]);this.lineGeometry=i[this.mergedElement.lineGeometry.uuid],this.initLineMaterial(),this.createBorder()}}init(){return g(this,null,function*(){this.geometry=yield this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options[0].deltaHeight+this.options[0].airHeight,this.options[0].strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())})}initGeometry(){return g(this,null,function*(){let t=yield kt.GetMergeGeometry(this.options);return this.dispatchEvent({type:"init-geometry",geometry:t}),t})}initMaterial(){let t=`
599
599
  varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
600
600
  uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
601
601
  uniform vec3 uColor;
@@ -621,14 +621,14 @@ void main() {
621
621
  gl_FragColor = vec4(uColor2, uOpacity); // \u5176\u4ED6\u9762\u989C\u8272\uFF09
622
622
  }
623
623
  }
624
- `,i=-1/0,s=this.geometry.getAttribute("position");if(s)for(let n=0;n<s.count;n++){let r=s.getZ(n);r>i&&(i=r)}let o=new Wp({uniforms:{maxZ:{value:i},uColor:{value:new Rr(this.options[0].fillColor).convertLinearToSRGB()},uColor2:{value:new Rr(Xt(this.options[0].fillColor)).convertLinearToSRGB()},uOpacity:{value:this.options[0].fillOpacity}},vertexShader:t,fragmentShader:e,transparent:!0});this.material=o}initLineMaterial(){let t=C.createLineMaterial({color:this.options[0].strokeColor,opacity:this.options[0].strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Gp(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options[0].height+this.options[0].deltaHeight;return this.options.map(i=>{let{coords:s}=i.geometry;for(let o=0;o<s.length;o++){let n=s[o];for(let r=0;r<n.length;r++){let h=n[r],c=r+1===n.length?n[0]:n[r+1];t.push(new Dr(h[0],h[1],e)),t.push(new Dr(c[0],c[1],e))}}}),t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new Bp().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new zp(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}dispose(){var t,e;this.geometry?(this.geometry.dispose(),this._listeners={}):this.addEventListener("init-geometry",()=>{var i;(i=this.geometry)==null||i.dispose(),this._listeners={}}),(t=this.material)==null||t.dispose(),(e=this.line)==null||e.geometry.dispose(),this.clear()}constructor(t,e,i){super(),this.context=t,this.mergedElement=i,this.options=[],i?(this.options=[i],this.initMergedElement()):(this.options=e.map(s=>w({},At,s)),this.init())}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.string.trim.js";import{Matrix4 as So,Mesh as Hp,Object3D as Np}from"three";import{mergeGeometries as Zp}from"three/examples/jsm/utils/BufferGeometryUtils.js";var jp={airHeight:0,deltaHeight:0,height:0,geometry:{cds:[],type:"polygon",coords:[],curveCpt:[],curveIndex:[]},texts:[],fillColor:"#ffffff",fillOpacity:0,strokeColor:"#ffffff",strokeOpacity:0,secondHeight:0,secondRotate:0,center_x:0,center_y:0},Vp={fontFamily:"sans-serif",fontWeight:"normal",fontSize:64},Kp=2048,Xp=1,es=class extends Np{init(){return g(this,null,function*(){let t=yield Promise.all(this.options.map(n=>g(this,null,function*(){let r=yield X.ensureText(n.texts[0],Vp);return{options:n,atlas:r,layout:wi(n.texts[0],r.charMap,r.spec,Kp)}}))),e=[],i=[];for(let n of t){let{options:r,layout:h,atlas:c}=n,l=Ue(h,{pivotX:.5,pivotY:.5,normalizeBottom:h.inkBottom,normalizeHeight:h.inkHeight});if(!l.length)continue;let p=new So().makeTranslation(r.center_x,r.center_y,r.airHeight+r.deltaHeight+r.height).multiply(new So().makeRotationZ(r.secondRotate)).multiply(new So().makeScale(r.secondHeight,r.secondHeight,1));for(let d of l)d.geometry.applyMatrix4(p),d.geometry.computeBoundingSphere(),e.push(d.geometry),i.push(this.createMaterial(n,c.pages[d.page].texture))}if(!e.length)return;let s=Zp(e,!0);e.forEach(n=>n.dispose());let o=new Hp(s,i);o.frustumCulled=!1,o.renderOrder=9e5,this.mesh=o,this.position.z+=.04,this.add(o)})}createMaterial(t,e){let{options:i,atlas:s}=t,o=typeof window!="undefined"&&window.devicePixelRatio||1;return Li({atlas:e,fillColor:i.fillColor,fillOpacity:i.fillOpacity,outlineColor:i.strokeColor,outlineOpacity:i.strokeOpacity,outlineWidth:Xp*o,edge:1-s.spec.cutoff,depthWrite:!1})}get materials(){var t;let e=(t=this.mesh)==null?void 0:t.material;return e?Array.isArray(e)?e:[e]:[]}setOpacity(t){this.materials.forEach(e=>{e.uniforms.uOpacity.value=t})}dispose(){var t;(t=this.mesh)==null||t.geometry.dispose(),this.materials.forEach(e=>e.dispose()),this.clear()}constructor(t,e){super(),this.context=t,this.options=e.map(i=>w({},jp,i)).filter(i=>i.texts[0].trim()),this.options.length&&this.init()}};import{Object3D as Yp}from"three";import{Line2 as qp}from"three/examples/jsm/lines/Line2.js";import{LineGeometry as $p}from"three/examples/jsm/lines/LineGeometry.js";import{LineMaterial as Jp}from"three/examples/jsm/lines/LineMaterial.js";var ii=class extends Yp{registryEvent(){this.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.context.removeEventListener("resize",this.onResize)}setPosition(t,e){this.lineGeometry.setPositions([t.x,t.y,t.z,e.x,e.y,e.z]),this.line||this.createLine()}createLine(){this.line=new qp(this.lineGeometry,this.lineMaterial),this.line.renderOrder=100003,this.add(this.line)}dispose(){var t;this.unRegistryEvent(),this.line&&F(this.line),this.lineGeometry=null,this.lineMaterial=null,this.clear(),(t=this.line)==null||t.clear(),this.line=null}constructor(t,e,i){super(),this.context=t,this.lineGeometry=new $p,this.lineMaterial=new Jp({color:0,transparent:!0,depthTest:!1,linewidth:2}),this.line=null,this.onResize=()=>{let{width:s,height:o}=this.context.clientSize;this.lineMaterial.resolution.set(s,o)},this.onResize(),this.registryEvent(),e&&i&&this.setPosition(e,i)}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Qp,InstancedMesh as td,Object3D as ed,Vector3 as id}from"three";import{Matrix4 as si}from"three";var Zi=class extends ed{loadModel(){return g(this,null,function*(){let t=yield pt.loadModel(this.options[0].url);t.scene.updateMatrixWorld(!0);let e=t.scene.matrixWorld.clone().invert();t.scene.traverse(h=>{if(h.isMesh){let c=e.clone().multiply(h.matrixWorld),l=h.material;this.subMeshes.push({geometry:h.geometry,material:h.material,initialMatrix:c}),Array.isArray(l)?l.forEach(p=>{p.transparent=!0,this.materialOriginParams.set(p,{opacity:p.opacity})}):(l.transparent=!0,this.materialOriginParams.set(l,{opacity:l.opacity}))}});let i=this.subMeshes.map(h=>{let{geometry:c,material:l}=h;return new td(c,l,this.options.length)});t.scene.rotation.set(Math.PI/2,0,0);let o=new Qp().setFromObject(t.scene).getSize(new id),n=Math.max(o.x,o.y);this.options.map(h=>{let c=new si,l=h.width/n;return c.multiply(new si().makeTranslation(h.center_x,h.center_y,h.airHeight+h.deltaHeight)).multiply(new si().makeScale(l,l,l)).multiply(new si().makeRotationZ(h.rotate)).multiply(new si().makeRotationX(Math.PI/2)),h.url==="https://robot-vr-public.cdn.bcebos.com/ai-map-resource/757/1865371442288267264/smzsdrc.glb"&&console.log(h,c),c}).forEach((h,c)=>{i.forEach((l,p)=>{let d=h.clone().multiply(this.subMeshes[p].initialMatrix);l.setMatrixAt(c,d)})}),i.forEach(h=>{h.instanceMatrix.needsUpdate=!0,this.meshSetMaterial(h),this.add(h)})})}meshSetMaterial(t){t.isMesh&&(t.frustumCulled=!1,t.castShadow=!0,Array.isArray(t.material)?t.material.map(e=>{e.emissiveIntensity*=.95}):(t.material.emissiveIntensity*=.95,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map))}setOpacity(t,e){e===void 0&&(e=!1),this.subMeshes.forEach(i=>{let{material:s}=i;if(Array.isArray(s))s.forEach(o=>{if(e)o.opacity=t;else{let n=this.materialOriginParams.get(o)||{opacity:1};t>n.opacity?o.opacity=n.opacity:o.opacity=t}o.needsUpdate=!0});else{let o=this.materialOriginParams.get(s)||{opacity:1};t>o.opacity?s.opacity=o.opacity:s.opacity=t,s.needsUpdate=!0}}),this.children.forEach(i=>{i.instanceMatrix.needsUpdate=!0})}dispose(){this.children.forEach(t=>t.dispose()),F(this),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.subMeshes=[],this.materialOriginParams=new Map,this.loadModel()}};import{Object3D as sd,Mesh as od,LineSegments as nd,ObjectLoader as rd}from"three";var ei=class extends sd{init(){return g(this,null,function*(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.deltaHeight+this.options.airHeight,this.options.lineGeometry&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder()),this.options.mergedGeometry=null,this.options.lineGeometry=null})}initGeometry(){return this.loader.parseGeometries([this.options.mergedGeometry])[this.options.mergedGeometry.uuid]}initMaterial(){this.material=C.GetMergeAttributeGraphicMaterial()}initLineMaterial(){return this.lineMaterial=C.GetMergeAttributeGraphicLineMaterial()}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new od(this.geometry,this.material),this.add(this.mesh)}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.loader.parseGeometries([this.options.lineGeometry]);this.lineGeometry=t[this.options.lineGeometry.uuid]}createBorder(){this.line&&this.remove(this.line);let t=new nd(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}dispose(){var t;this.geometry&&this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.loader=new rd,this.options=w({},At,e),this.init()}};import{Mesh as ad,Object3D as hd,ObjectLoader as cd}from"three";var is=class extends hd{initGeometry(){return g(this,null,function*(){let t=new cd().parseGeometries([this.options.mergedGeometry]);this.geometry=t[this.options.mergedGeometry.uuid]})}init(){return g(this,null,function*(){var t;yield this.initGeometry();let e=new ad(this.geometry,ut.GetMergeAttributeWallMaterial());this.add(e);let i=(t=this.geometry)==null?void 0:t.getAttribute("opacity");i&&(this.originOpacities=Array.from(i.array))})}setOpacity(t,e){e===void 0&&(e=!1);var i;let s=(i=this.geometry)==null?void 0:i.getAttribute("opacity");if(s){for(let n=0;n<s.count;n++)if(e)s.setX(n,t);else{var o;s.setX(n,Math.min(t,(o=this.originOpacities[n])!=null?o:1))}s.needsUpdate=!0}}dispose(){var t;(t=this.geometry)==null||t.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.originOpacities=[],this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import{Float32BufferAttribute as ld,FrontSide as pd,InstancedBufferAttribute as dd,InstancedMesh as ud,MeshBasicMaterial as md,Object3D as fd,Shape as gd,ShapeGeometry as yd,Vector2 as ss}from"three";var pe=class extends fd{init(){return g(this,null,function*(){let t=this.options.iconUrl,e=yield ht.getTextureByUrl(t),i=new md({map:e,transparent:!0,alphaTest:.2,side:pd}),s=new ud(this.geometry,i,this.options.mergedMatrixes.size);s.instanceMatrix=new dd(new Float32Array(this.options.mergedMatrixes.array),16),this.add(s),this.mesh=s,this.position.z+=.004})}setOpacity(t){this.mesh&&(this.mesh.material.opacity=t,this.mesh.material.needsUpdate=!0,this.mesh.instanceMatrix.needsUpdate=!0)}dispose(){var t;this.mesh&&F(this.mesh),(t=this.mesh)==null||t.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.geometry=new yd(new gd([new ss(-.5,-.5),new ss(-.5,.5),new ss(.5,.5),new ss(.5,-.5)])),this.options=w({},Eo,e);let i=new ld([0,0,0,1,1,1,1,0],2);this.geometry.setAttribute("uv",i),this.init()}};import"core-js/modules/es.array.push.js";import{Mesh as vd,Object3D as xd,ObjectLoader as wd,Vector2 as Fr}from"three";import{LineSegments2 as Ir}from"three/examples/jsm/lines/LineSegments2.js";import{LineSegmentsGeometry as Gr}from"three/examples/jsm/lines/LineSegmentsGeometry.js";var os=class extends xd{initGeometry(){return g(this,null,function*(){let t=this.loader.parseGeometries([this.options.mergedGeometry]);this.geometry=t[this.options.mergedGeometry.uuid]})}initMaterial(){let t=C.createMeshBasicMaterial({color:"#ffffff",opacity:1,vertexColors:!0});return this.material=t,t}initDoubleLine(){if(this.options.dashedLineGeometry){let t=C.createLine2MaterialMap({color:"#ffffff",width:.2,dashed:!0,resolution:new Fr(this.context.clientSize.width,this.context.clientSize.height),vertexColors:!0});t.transparent=!0,t.needsUpdate=!0;let e=new Gr;e.setPositions(this.options.dashedLineGeometry.positions),e.setColors(this.options.dashedLineGeometry.colors);let i=new Ir(e,t);i.computeLineDistances(),i.position.z+=.01,this.add(i),this.doubleLines.push(i)}if(this.options.lineGeometry){let t=C.createLine2MaterialMap({color:"#ffffff",width:.2,dashed:!1,resolution:new Fr(this.context.clientSize.width,this.context.clientSize.height),vertexColors:!0}),e=new Gr;e.setPositions(this.options.lineGeometry.positions),e.setColors(this.options.lineGeometry.colors);let i=new Ir(e,t);i.position.z+=.01,this.add(i),this.doubleLines.push(i)}}init(){return g(this,null,function*(){yield this.initGeometry(),this.initMaterial();let t=new vd(this.geometry,this.material);this.add(t),this.initDoubleLine(),this.position.z+=.02})}setOpacity(t){this.material.opacity=t,this.material.needsUpdate=!0,this.doubleLines.forEach(e=>{e.material.opacity=t,e.material.needsUpdate=!0})}dispose(){var t,e;(t=this.geometry)==null||t.dispose(),(e=this.lineGeometry)==null||e.dispose(),this.doubleLines.map(i=>i.geometry.dispose()),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.doubleLines=[],this.loader=new wd,this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/web.dom-collections.iterator.js";import{Object3D as _d,Vector3 as Co,BufferGeometry as Pd,LineSegments as Md,Color as Br,BoxGeometry as bd,InstancedMesh as Ed,Matrix4 as Sd,Quaternion as Cd,InstancedBufferAttribute as zr,BufferAttribute as Wr}from"three";var Qe=class extends _d{setColorByIndex(t,e){this.mesh&&(this.mesh.setColorAt(t,new Br(e).convertLinearToSRGB()),this.mesh.instanceColor.needsUpdate=!0)}init(){return g(this,null,function*(){this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options[0].deltaHeight+this.options[0].airHeight,this.options[0].strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())})}initMaterial(){this.material=C.GetInstancedGraphicMaterial()}initLineMaterial(){let t=C.GetMergeAttributeGraphicLineMaterial();this.lineMaterial=t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Ed(this.geometry,this.material,this.options.length);let t=new zr(new Float32Array(this.options.length),1),e=new zr(new Float32Array(this.options.length),1);this.options.forEach((i,s)=>{let o=i.geometry.coords[0],[n,r,h]=o.slice(0,3),c=Math.sqrt((r[0]-n[0])**2+(r[1]-n[1])**2),l=Math.sqrt((h[0]-r[0])**2+(h[1]-r[1])**2),p=[c,l],d=Math.max(...p),u=Math.min(...p),f;d===c?f=[r[0]-n[0],r[1]-n[1]]:f=[h[0]-r[0],h[1]-r[1]];let[x,m]=f,y=Math.atan2(m,x)-Math.PI/2,_=new Sd().compose(new Co(i.center_coord_x,i.center_coord_y,(i.deltaHeight||0)+i.airHeight+i.height/2),new Cd().setFromAxisAngle(new Co(0,0,1),y),new Co(u,d,i.height));this.mesh.setMatrixAt(s,_),this.mesh.setColorAt(s,new Br(i.fillColor).convertLinearToSRGB());var P;t.array[s]=(P=i.fillOpacity)!=null?P:1;var S;e.array[s]=((S=i.deltaHeight)!=null?S:0)+i.airHeight+i.height}),this.originOpacity=[...t.array],this.geometry.setAttribute("opacity",t),this.geometry.setAttribute("maxZ",e),this.add(this.mesh),this.mesh.instanceMatrix.needsUpdate=!0}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let{points:t,colors:e,opacities:i}=no(this.options),s=new Pd().setFromPoints(t);s.setAttribute("color",new Wr(new Float32Array(e),3)),s.setAttribute("opacity",new Wr(new Float32Array(i),1)),this.lineOriginOpacity=[...i],this.lineGeometry=s}createBorder(){this.line&&this.remove(this.line);let t=new Md(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}setOpacity(t,e){e===void 0&&(e=!1);let i=this.geometry.getAttribute("opacity");for(let n=0;n<i.count;n++)if(e)i.array[n]=t;else{var s;i.array[n]=Math.min(t,(s=this.originOpacity[n])!=null?s:1)}if(i.needsUpdate=!0,this.lineGeometry){let n=this.lineGeometry.getAttribute("opacity");for(let r=0;r<n.count;r++)if(e)n.array[r]=t;else{var o;n.array[r]=Math.min(t,(o=this.lineOriginOpacity[r])!=null?o:1)}n.needsUpdate=!0}}dispose(){var t,e;this.geometry.dispose(),(t=this.mesh)==null||t.dispose(),(e=this.line)==null||e.geometry.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.geometry=new bd(1,1,1),this.options=[],this.originOpacity=[],this.lineOriginOpacity=[],this.options=e.map(i=>w({},At,i)),this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/web.dom-collections.iterator.js";import{Object3D as Td,Color as Ld,BoxGeometry as kd,InstancedMesh as Ad,InstancedBufferAttribute as To}from"three";var Se=class extends Td{init(){return g(this,null,function*(){this.initMaterial(),this.initMesh()})}initMaterial(){this.material=C.GetInstancedGraphicMaterial()}initMesh(){if(this.mesh&&this.remove(this.mesh),!this.elements)return;this.mesh=new Ad(this.geometry,this.material,this.elements.size);let t=new To(new Float32Array(this.elements.opacities),1),e=new To(new Float32Array(this.elements.maxZs),1);this.originOpacities=[...t.array],this.geometry.setAttribute("opacity",t),this.geometry.setAttribute("maxZ",e),this.mesh.instanceMatrix.set(this.elements.matrixes),this.mesh.instanceColor=new To(new Float32Array(this.elements.colors),3),this.add(this.mesh),this.mesh.instanceMatrix.needsUpdate=!0}setColorByIndex(t,e){this.mesh&&(this.mesh.setColorAt(t,new Ld(e).convertLinearToSRGB()),this.mesh.instanceColor.needsUpdate=!0)}setOpacityByIndex(t,e){if(this.mesh){let i=this.geometry.getAttribute("opacity");i.setX(t,e),i.needsUpdate=!0}}setMatrixByIndex(t,e){this.mesh&&(this.mesh.setMatrixAt(t,e),this.mesh.instanceMatrix.needsUpdate=!0)}setMaxZByIndex(t,e){if(this.mesh){let i=this.geometry.getAttribute("maxZ");i.setX(t,e),i.needsUpdate=!0}}setColorById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setColorByIndex(i,e)}setOpacityById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setOpacityByIndex(i,e)}setMatrixById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setMatrixByIndex(i,e)}setMaxZById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setMaxZByIndex(i,e)}setOpacity(t,e){if(e===void 0&&(e=!1),!this.geometry)return;let i=this.geometry.getAttribute("opacity");for(let o=0;o<i.count;o++)if(e)i.array[o]=t;else{var s;i.array[o]=Math.min(t,(s=this.originOpacities[o])!=null?s:1)}i.needsUpdate=!0}pushElements(t){this.elements?(this.elements.size+=t.size,this.elements.colors=[...this.elements.colors,...t.colors],this.elements.matrixes=[...this.elements.matrixes,...t.matrixes],this.elements.opacities=[...this.elements.opacities,...t.opacities],this.elements.maxZs=[...this.elements.maxZs,...t.maxZs],this.elements.ids=[...this.elements.ids,...t.ids],this.originOpacities=[...this.originOpacities,...t.opacities]):this.elements=t,this.refesh()}removeInstanceById(t){if(this.elements){if(this.mesh){let e=this.elements.ids.indexOf(t);e!==-1&&(this.elements.size--,this.elements.colors.splice(e*3,3),this.elements.matrixes.splice(e*16,16),this.elements.opacities.splice(e,1),this.elements.maxZs.splice(e,1),this.elements.ids.splice(e,1),this.originOpacities.splice(e,1))}this.refesh()}}refesh(){this.mesh&&(this.mesh.dispose(),this.remove(this.mesh)),this.init()}dispose(){var t;this.material=null,this.originOpacities.length=0,this.geometry.dispose(),(t=this.mesh)==null||t.dispose(),this.clear()}constructor(t,e){super(),this.geometry=new kd(1,1,1),this.material=null,this.elements=null,this.originOpacities=[],this.elements=e,this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/web.dom-collections.iterator.js";import{Object3D as Dd,BoxGeometry as Rd,InstancedMesh as Od,InstancedBufferAttribute as ns}from"three";var rs=class extends Dd{init(){return g(this,null,function*(){this.initMaterial(),this.initMesh()})}initMaterial(){this.material=C.GetInstancedWallMaterial()}initMesh(){if(this.mesh&&this.remove(this.mesh),!this.elements)return;this.mesh=new Od(this.geometry,this.material,this.elements.size);let t=new ns(new Float32Array(this.elements.opacities),1),e=new ns(new Float32Array(this.elements.maxZs),1),i=new ns(new Float32Array(this.elements.minZs),1);this.originOpacities=[...t.array],this.geometry.setAttribute("opacity",t),this.geometry.setAttribute("maxZ",e),this.geometry.setAttribute("minZ",i),this.mesh.instanceMatrix.set(this.elements.matrixes),this.mesh.instanceColor=new ns(new Float32Array(this.elements.colors),3),this.add(this.mesh),this.mesh.instanceMatrix.needsUpdate=!0}setOpacityByIndex(t,e){if(this.mesh){let i=this.geometry.getAttribute("opacity");i.setX(t,e),i.needsUpdate=!0}}setOpacity(t,e){e===void 0&&(e=!1),this.elements&&this.elements.opacities.forEach((i,s)=>{let o=e?t:Math.min(t,this.originOpacities[s]);this.setOpacityByIndex(s,o)})}dispose(){this.mesh&&(this.mesh.dispose(),this.remove(this.mesh)),this.material=null,this.geometry&&this.geometry.dispose(),this.elements=null}constructor(t,e){super(),this.geometry=new Rd(1,1,1),this.material=null,this.elements=null,this.originOpacities=[],this.elements=e,this.init()}};import{Object3D as Fd,LineSegments as Id,ObjectLoader as Gd}from"three";var de=class extends Fd{init(){return g(this,null,function*(){this.initLineGeometry(),this.initLineMaterial(),this.createBorder(),this.options=null})}initLineMaterial(){return this.lineMaterial=C.GetMergeAttributeGraphicLineMaterial()}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.loader.parseGeometries([this.options]);this.lineGeometry=t[this.options.uuid]}createBorder(){this.line&&this.remove(this.line);let t=new Id(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}dispose(){var t;(t=this.lineGeometry)==null||t.dispose(),this.lineMaterial=null,this.clear()}constructor(t,e){super(),this.context=t,this.lineMaterial=null,this.loader=new Gd,this.options=w({},At,e),this.init()}};import{Frustum as Bd}from"three";var as=class extends dt{setEnable(t){super.setEnable(t),j(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=L(this.startPoint,e,i,s),n=L(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof Y&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=L(d,s,o,n);return te(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=L(h,s,o,n),p=L(c,s,o,n);return!(!te(l,e,i)||!te(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new Bd,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);j(this.rect,n.x,n.y,r,h)}else j(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=gt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var hs=class extends zd{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.context.config.enableBoxSelect||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}constructor(t){super(),this.context=t,this._list=new Set,this.downPoint=null,this.downTime=0,this.isMultipleSelect=!1,this.onPointerDown=e=>{Date.now()-this.downTime<200||(this.downPoint={x:e.offsetX,y:e.offsetY},this.downTime=Date.now())},this.onPointerUp=e=>{if(!this.downPoint)return;let{offsetX:i,offsetY:s}=e,{x:o,y:n}=this.downPoint;if(Math.sqrt((o-i)**2+(n-s)**2)>3)return;let{graphics:r}=this.context.getGraphicsByDeviceXy(i,s),h=new Set(r.map(l=>l.options.id));this.context.getPoisByDeviceXy(i,s).forEach(l=>{if(!h.has(l.options.id)){var p;let d=((p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id))||null;d&&d.options.geometry.type==="point"&&(r.push(d),h.add(l.options.id))}}),(re?e.metaKey:e.ctrlKey)||this._list.clear(),r.forEach(l=>this._list.add(l)),this.selectEnd(),this.downPoint=null},this.onPointerOut=e=>{this.disableBoxSelection()},this.onKeyDown=e=>{ve(e.key)&&this.enableBoxSelection()},this.onKeyUp=e=>{ve(e.key)&&this.disableBoxSelection()},this.onBoxSelected=e=>{let{list:i}=e;this._list.clear(),i.forEach(s=>{this._list.add(s)}),this.selectEnd()},this.boxSelection=new as(t),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as Wd,Vector2 as Ud}from"three";var cs=class extends Wd{handleHoverGraphicsChange(t){t===void 0&&(t=this.curGraphics),this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel),document.body.addEventListener("pointermove",this.onBodyPointerMove)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel),document.body.removeEventListener("pointermove",this.onBodyPointerMove)}dispose(){this.unRegistryEvent(),this.timer.dispose()}constructor(t){super(),this.context=t,this.curGraphics=new Set,this.timer=new K,this.graphicTimerMap=new Map,this.onPointerMove=e=>{let{graphics:i,pois:s,e:o}=e,n=s.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!i.length&&!n.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:r}=this.context.config.hover,h=new Set;if(n.length){let l,p=1e4;n.forEach(d=>{let u=s.find(f=>f.options.id===d.options.id);if(u instanceof ce){let{x:f,y:x}=u.clientPos,m=Math.sqrt((f-o.offsetX)**2+(x-o.offsetY)**2);m<p&&(p=m,l=d)}else if(u instanceof et){let{x:f,y:x}=u.box.getCenter(new Ud),m=Math.sqrt((f-o.offsetX)**2+(x-o.offsetY)**2);m<p&&(p=m,l=d)}}),h.add(l)}h.size||i.forEach(l=>h.add(l)),h.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},r);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{h.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let c=this.curGraphics.size;this.curGraphics.forEach(l=>{h.has(l)||this.curGraphics.delete(l)}),c!==this.curGraphics.size&&this.handleHoverGraphicsChange()},this.onPointerLevel=()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()},this.onBodyPointerMove=e=>{if(this.curGraphics.size){let i=this.context.container.getBoundingClientRect();(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom)&&this.onPointerLevel()}},this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Hd,Vector3 as Wt}from"three";import{polygon as Ur,intersect as Nd}from"@turf/turf";var ls=class{updateBox(){this.box.setFromObject(this.context.scene)}setEnable(t){this.enable=t,t?this.registryEvent():this.unRegistryEvent()}changePrevCamera(){this.prevCamera={position:this.context.camera.position.clone(),zoom:this.context.camera.zoom,target:this.context.control.target.clone()}}backToPrevCamera(){this.setEnable(!1),this.context.camera.position.copy(this.prevCamera.position),this.context.camera.zoom=this.prevCamera.zoom,this.context.control.target.copy(this.prevCamera.target),this.context.control.update(),this.setEnable(!0)}registryEvent(){this.context.addEventListener("control-change",this.onCameraChange)}unRegistryEvent(){this.context.removeEventListener("control-change",this.onCameraChange)}getCurFloorScreenPosition(){if(!this.context.scene.children.filter(f=>f instanceof zt).length)return null;let e=this.box,{camera:i,clientSize:{width:s,height:o}}=this.context,{min:n,max:r}=e,c=[new Wt(n.x,n.y,n.z),new Wt(r.x,n.y,n.z),new Wt(n.x,r.y,n.z),new Wt(r.x,r.y,n.z),new Wt(n.x,n.y,r.z),new Wt(r.x,n.y,r.z),new Wt(n.x,r.y,r.z),new Wt(r.x,r.y,r.z)].map(f=>L(f,i,s,o)),l=Math.min(...c.map(f=>f.x)),p=Math.max(...c.map(f=>f.x)),d=Math.min(...c.map(f=>f.y)),u=Math.max(...c.map(f=>f.y));return{left:l,right:p,top:d,bottom:u}}checkDistanceToScreenEdge(t){let{left:e,right:i,top:s,bottom:o}=t,{width:n,height:r}=this.context.clientSize,[h,c,l,p]=this.context.config.cameraBound.padding,d=Ur([[[e,s],[i,s],[i,o],[e,o],[e,s]]]),u=Ur([[[p,h],[n-c,h],[n-c,r-l],[p,r-l],[p,h]]]);try{return Nd(d,u)!==null}catch(f){return console.warn("\u8BA1\u7B97\u4EA4\u96C6\u51FA\u9519:",f),!1}}dispose(){this.unRegistryEvent()}constructor(t){this.context=t,this.prevCamera={position:new Wt,zoom:1,target:new Wt},this.enable=!0,this.box=new Hd,this.onCameraChange=()=>{let e=this.getCurFloorScreenPosition();if(e){let{left:i,right:s,top:o,bottom:n}=e;if([i,s,o,n].every(h=>!h))return;this.checkDistanceToScreenEdge({left:i,right:s,top:o,bottom:n})?this.changePrevCamera():this.backToPrevCamera()}},this.registryEvent(),this.changePrevCamera()}};import"core-js/modules/es.promise.finally.js";import{Vector3 as Zr}from"three";import{Tween as ms,Group as Yd}from"@tweenjs/tween.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{EventDispatcher as Zd,MOUSE as Ae,Quaternion as Hr,Spherical as ps,TOUCH as De,Vector2 as wt,Vector3 as St,Plane as jd,Ray as Vd,MathUtils as Kd}from"three";var ds=new Vd,Nr=new jd,Xd=Math.cos(70*Kd.DEG2RAD),us=class extends Zd{dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerUp),this.domElement.removeEventListener("wheel",this.onMouseWheel),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this.onKeyDown),this._domElementKeyEvents=null)}constructor(t,e){super(),this.rotateLineStart=new wt,this.rotateLineEnd=new wt,this.spherical=new ps,this.sphericalDelta=new ps,this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new St,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.screenSpacePanning=!1,this.mouseButtons={LEFT:Ae.PAN,MIDDLE:Ae.DOLLY,RIGHT:Ae.ROTATE},this.touches={ONE:De.PAN,TWO:De.DOLLY_ROTATE},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(v){v.addEventListener("keydown",this.onKeyDown),this._domElementKeyEvents=v},this.stopListenToKeyEvents=function(){var v;(v=this._domElementKeyEvents)==null||v.removeEventListener("keydown",this.onKeyDown),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent({type:"change"}),i.update(),o=s.NONE},this.update=function(){let v=new St,M=new Hr().setFromUnitVectors(t.up,new St(0,1,0)),U=M.clone().invert(),tt=new St,xt=new Hr,It=new St,Ct=2*Math.PI;return function(Ge){Ge===void 0&&(Ge=null);let Ht=i.object.position;v.copy(Ht).sub(i.target),v.applyQuaternion(M),r.setFromVector3(v),i.autoRotate&&o===s.NONE&&$(R(Ge)),i.enableDamping?(r.theta+=h.theta*i.dampingFactor,r.phi+=h.phi*i.dampingFactor):(r.theta+=h.theta,r.phi+=h.phi);let Nt=i.minAzimuthAngle,Zt=i.maxAzimuthAngle;isFinite(Nt)&&isFinite(Zt)&&(Nt<-Math.PI?Nt+=Ct:Nt>Math.PI&&(Nt-=Ct),Zt<-Math.PI?Zt+=Ct:Zt>Math.PI&&(Zt-=Ct),Nt<=Zt?r.theta=Math.max(Nt,Math.min(Zt,r.theta)):r.theta=r.theta>(Nt+Zt)/2?Math.max(Nt,r.theta):Math.min(Zt,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(l,i.dampingFactor):i.target.add(l),i.zoomToCursor&&k||i.object.isOrthographicCamera?r.radius=D(r.radius):r.radius=D(r.radius*c),v.setFromSpherical(r),v.applyQuaternion(U),Ht.copy(i.target).add(v),i.object.lookAt(i.target),i.enableDamping===!0?(h.theta*=1-i.dampingFactor,h.phi*=1-i.dampingFactor,l.multiplyScalar(1-i.dampingFactor)):(h.set(0,0,0),l.set(0,0,0));let pi=!1;if(i.zoomToCursor&&k){let Be=null;if(i.object.isPerspectiveCamera){let ze=v.length();Be=D(ze*c);let di=ze-Be;i.object.position.addScaledVector(S,di),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){let ze=new St(E.x,E.y,0);ze.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),pi=!0;let di=new St(E.x,E.y,0);di.unproject(i.object),i.object.position.sub(di).add(ze),i.object.updateMatrixWorld(),Be=v.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;Be!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(Be).add(i.object.position):(ds.origin.copy(i.object.position),ds.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(ds.direction))<Xd?t.lookAt(i.target):(Nr.setFromNormalAndCoplanarPoint(i.object.up,i.target),ds.intersectPlane(Nr,i.target))))}else i.object.isOrthographicCamera&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),pi=!0);return c=1,k=!1,pi||tt.distanceToSquared(i.object.position)>n||8*(1-xt.dot(i.object.quaternion))>n||It.distanceToSquared(i.target)>0?(i.dispatchEvent({type:"change"}),tt.copy(i.object.position),xt.copy(i.object.quaternion),It.copy(i.target),pi=!1,!0):!1}}();let i=this,s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},o=s.NONE,n=1e-6,r=new ps,h=new ps,c=1,l=new St,p=new wt,d=new wt,u=new wt,f=new wt,x=new wt,m=new wt,y=new wt,_=new wt,P=new wt,S=new St,E=new wt,k=!1,b=[],G={};function R(v){return v!==null?2*Math.PI/60*i.autoRotateSpeed*v:2*Math.PI/60/60*i.autoRotateSpeed}function O(){return Math.pow(.95,i.zoomSpeed)}function $(v){h.theta-=v}function nt(v){h.phi-=v}let W=function(){let v=new St;return function(U,tt){v.setFromMatrixColumn(tt,0),v.multiplyScalar(-U),l.add(v)}}(),J=function(){let v=new St;return function(U,tt){i.screenSpacePanning===!0?v.setFromMatrixColumn(tt,1):(v.setFromMatrixColumn(tt,0),v.crossVectors(i.object.up,v)),v.multiplyScalar(U),l.add(v)}}(),z=function(){let v=new St;return function(U,tt){let xt=i.domElement;if(i.object.isPerspectiveCamera){let It=i.object.position;v.copy(It).sub(i.target);let Ct=v.length();Ct*=Math.tan(i.object.fov/2*Math.PI/180),W(2*U*Ct/xt.clientHeight,i.object.matrix),J(2*tt*Ct/xt.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(W(U*(i.object.right-i.object.left)/i.object.zoom/xt.clientWidth,i.object.matrix),J(tt*(i.object.top-i.object.bottom)/i.object.zoom/xt.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function mt(v){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c/=v:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function Q(v){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c*=v:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function I(v){if(!i.zoomToCursor)return;k=!0;let M=i.domElement.getBoundingClientRect(),U=v.clientX-M.left,tt=v.clientY-M.top,xt=M.width,It=M.height;E.x=U/xt*2-1,E.y=-(tt/It)*2+1,S.set(E.x,E.y,1).unproject(i.object).sub(i.object.position).normalize()}function D(v){return Math.max(i.minDistance,Math.min(i.maxDistance,v))}function V(v){p.set(v.clientX,v.clientY)}function Z(v){I(v),y.set(v.clientX,v.clientY)}function Ot(v){f.set(v.clientX,v.clientY)}function Ft(v){d.set(v.clientX,v.clientY),u.subVectors(d,p).multiplyScalar(i.rotateSpeed);let M=i.domElement;$(2*Math.PI*u.x/M.clientHeight),nt(2*Math.PI*u.y/M.clientHeight),p.copy(d),i.update()}function Qt(v){_.set(v.clientX,v.clientY),P.subVectors(_,y),P.y>0?mt(O()):P.y<0&&Q(O()),y.copy(_),i.update()}function Ut(v){x.set(v.clientX,v.clientY),m.subVectors(x,f).multiplyScalar(i.panSpeed),z(m.x,m.y),f.copy(x),i.update()}function Ie(v){I(v),v.deltaY<0?Q(O()):v.deltaY>0&&mt(O()),i.update()}function Oa(v){let M=!1;switch(v.code){case i.keys.UP:v.ctrlKey||v.metaKey||v.shiftKey?nt(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(0,i.keyPanSpeed),M=!0;break;case i.keys.BOTTOM:v.ctrlKey||v.metaKey||v.shiftKey?nt(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(0,-i.keyPanSpeed),M=!0;break;case i.keys.LEFT:v.ctrlKey||v.metaKey||v.shiftKey?$(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(i.keyPanSpeed,0),M=!0;break;case i.keys.RIGHT:v.ctrlKey||v.metaKey||v.shiftKey?$(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(-i.keyPanSpeed,0),M=!0;break}M&&(v.preventDefault(),i.update())}function Xo(){if(b.length===1)p.set(b[0].pageX,b[0].pageY);else{let v=(b[0].pageX-b[0].pageY)/(b[1].pageX-b[1].pageY),M=b[0].pageY-v*b[0].pageX;i.rotateLineStart.set(v,M);let U=.5*(b[0].pageX+b[1].pageX),tt=.5*(b[0].pageY+b[1].pageY);p.set(U,tt)}}function Yo(){if(b.length===1)f.set(b[0].pageX,b[0].pageY);else{let v=.5*(b[0].pageX+b[1].pageX),M=.5*(b[0].pageY+b[1].pageY);f.set(v,M)}}function qo(){let v=b[0].pageX-b[1].pageX,M=b[0].pageY-b[1].pageY,U=Math.sqrt(v*v+M*M);y.set(0,U)}function Fa(){i.enableZoom&&qo(),i.enablePan&&Yo()}function Ia(){i.enableZoom&&qo(),i.enableRotate&&Xo()}function $o(v){if(b.length==1)d.set(v.pageX,v.pageY);else{let U=js(v),tt=.5*(v.pageX+U.x),xt=.5*(v.pageY+U.y);d.set(tt,xt);let It=(v.pageY-U.y)/(v.pageX-U.x),Ct=U.y-It*U.x;if(i.rotateLineEnd.set(It,Ct),Number.isFinite(i.rotateLineEnd.x)&&Number.isFinite(i.rotateLineStart.x)){let Vs=(i.rotateLineStart.y-i.rotateLineEnd.y)/(i.rotateLineEnd.x-i.rotateLineStart.x),Ge=It*Vs+Ct;if(Number.isFinite(Vs)&&Number.isFinite(Ge)){let Ht=Math.atan(i.rotateLineEnd.x)-Math.atan(i.rotateLineStart.x);Math.PI-Math.abs(Ht)<.5&&(Ht=-Math.sign(Ht)*(Math.PI-Math.abs(Ht))),Math.abs(Ht)<.1&&(h.theta+=Ht)}}i.rotateLineStart.copy(i.rotateLineEnd)}u.subVectors(d,p).multiplyScalar(i.rotateSpeed);let M=i.domElement;nt(2*Math.PI*u.y/M.clientHeight),p.copy(d)}function Jo(v){if(b.length===1)x.set(v.pageX,v.pageY);else{let M=js(v),U=.5*(v.pageX+M.x),tt=.5*(v.pageY+M.y);x.set(U,tt)}m.subVectors(x,f).multiplyScalar(i.panSpeed),z(m.x,m.y),f.copy(x)}function Qo(v){let M=js(v),U=v.pageX-M.x,tt=v.pageY-M.y,xt=Math.sqrt(U*U+tt*tt);_.set(0,xt),P.set(0,Math.pow(_.y/y.y,i.zoomSpeed)),mt(P.y),y.copy(_)}function Ga(v){i.enableZoom&&Qo(v),i.enablePan&&Jo(v)}function Ba(v){i.enableZoom&&Qo(v),i.enableRotate&&$o(v)}this.onPointerDown=function(M){i.enabled!==!1&&(b.length===0&&(i.domElement.setPointerCapture(M.pointerId),i.domElement.addEventListener("pointermove",i.onPointerMove),i.domElement.addEventListener("pointerup",i.onPointerUp)),Na(M),M.pointerType==="touch"?Ua(M):za(M))},this.onPointerMove=function(M){i.enabled!==!1&&(M.pointerType==="touch"?Ha(M):Wa(M))},this.onPointerUp=function(M){Za(M),b.length===0&&(i.domElement.releasePointerCapture(M.pointerId),i.domElement.removeEventListener("pointermove",i.onPointerMove),i.domElement.removeEventListener("pointerup",i.onPointerUp)),i.dispatchEvent({type:"end"}),o=s.NONE};function za(v){let M;switch(v.button){case 0:M=i.mouseButtons.LEFT;break;case 1:M=i.mouseButtons.MIDDLE;break;case 2:M=i.mouseButtons.RIGHT;break;default:M=-1}switch(M){case Ae.DOLLY:if(i.enableZoom===!1)return;Z(v),o=s.DOLLY;break;case Ae.ROTATE:if(v.ctrlKey||v.metaKey||v.shiftKey){if(i.enablePan===!1)return;Ot(v),o=s.PAN}else{if(i.enableRotate===!1)return;V(v),o=s.ROTATE}break;case Ae.PAN:if(v.ctrlKey||v.metaKey||v.shiftKey){if(i.enableRotate===!1)return;V(v),o=s.ROTATE}else{if(i.enablePan===!1)return;Ot(v),o=s.PAN}break;default:o=s.NONE}o!==s.NONE&&i.dispatchEvent({type:"start"})}function Wa(v){switch(o){case s.ROTATE:if(i.enableRotate===!1)return;Ft(v);break;case s.DOLLY:if(i.enableZoom===!1)return;Qt(v);break;case s.PAN:if(i.enablePan===!1)return;Ut(v);break}}this.onMouseWheel=function(M){i.enabled===!1||i.enableZoom===!1||o!==s.NONE||(M.preventDefault(),i.dispatchEvent({type:"start"}),Ie(M),i.dispatchEvent({type:"end"}))},this.onKeyDown=function(M){i.enabled===!1||i.enablePan===!1||Oa(M)};function Ua(v){switch(tn(v),b.length){case 1:switch(i.touches.ONE){case De.ROTATE:if(i.enableRotate===!1)return;Xo(),o=s.TOUCH_ROTATE;break;case De.PAN:if(i.enablePan===!1)return;Yo(),o=s.TOUCH_PAN;break;default:o=s.NONE}break;case 2:switch(i.touches.TWO){case De.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Fa(),o=s.TOUCH_DOLLY_PAN;break;case De.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ia(),o=s.TOUCH_DOLLY_ROTATE;break;default:o=s.NONE}break;default:o=s.NONE}o!==s.NONE&&i.dispatchEvent({type:"start"})}function Ha(v){switch(tn(v),o){case s.TOUCH_ROTATE:if(i.enableRotate===!1)return;$o(v),i.update();break;case s.TOUCH_PAN:if(i.enablePan===!1)return;Jo(v),i.update();break;case s.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Ga(v),i.update();break;case s.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ba(v),i.update();break;default:o=s.NONE}}this.onContextMenu=function(M){i.enabled!==!1&&M.preventDefault()};function Na(v){b.push(v)}function Za(v){delete G[v.pointerId];for(let M=0;M<b.length;M++)if(b[M].pointerId==v.pointerId){b.splice(M,1);return}}function tn(v){let M=G[v.pointerId];M===void 0&&(M=new wt,G[v.pointerId]=M),M.set(v.pageX,v.pageY)}function js(v){let M=v.pointerId===b[0].pointerId?b[1]:b[0];return G[M.pointerId]}i.domElement.addEventListener("contextmenu",this.onContextMenu),i.domElement.addEventListener("pointerdown",this.onPointerDown),i.domElement.addEventListener("pointercancel",this.onPointerUp),i.domElement.addEventListener("wheel",this.onMouseWheel,{passive:!1}),this.update()}};var fs=class extends us{registryEvent(){this.addEventListener("change",this.onChange),this.context.addEventListener("update",this.tweenUpdate)}unRegistryEvent(){this.removeEventListener("change",this.onChange),this.context.removeEventListener("update",this.tweenUpdate)}setPolarAngle(t,e){e===void 0&&(e=!1);let{maxPolarAngle:i,minPolarAngle:s}=this,o=i===s;(e||t<=i&&t>=s)&&(this.maxPolarAngle=t,this.minPolarAngle=t,this.update()),o||(this.maxPolarAngle=i,this.minPolarAngle=s)}setPolarAngleByDuration(t,e,i){return g(this,null,function*(){return e===void 0&&(e=!1),i===void 0&&(i=500),i<=0?this.setPolarAngle(t,e):Mt(new Promise(s=>{let o={polar:this.getPolarAngle()},n={polar:t},r=new ms(o,this.tweenGroup).to(n,i).onUpdate(()=>{this.setPolarAngle(o.polar,e)}).onComplete(()=>{this.enabled=!0,this.tweenGroup.remove(r),s(!0)}).onStart(()=>{this.enabled=!1}).start()}),i+500)})}setAzimuthalAngle(t,e){let{maxAzimuthAngle:i,minAzimuthAngle:s}=this,o=i===s;(e||t<=i&&t>=s)&&(this.maxAzimuthAngle=t,this.minAzimuthAngle=t,this.update()),o||(this.maxAzimuthAngle=i,this.minAzimuthAngle=s)}setAzimuthalAngleDuration(t,e,i){return e===void 0&&(e=!1),i===void 0&&(i=500),i<=0?this.setAzimuthalAngle(t,e):Mt(new Promise(s=>{let o={azimuthal:this.getAzimuthalAngle()},n={azimuthal:t},r=new ms(o,this.tweenGroup).to(n,i).onUpdate(()=>{this.setAzimuthalAngle(o.azimuthal,e)}).onComplete(()=>{this.enabled=!0,this.tweenGroup.remove(r),s(!0)}).onStart(()=>{this.enabled=!1}).start()}),i+500)}getCameraLookAt(){return new Zr().subVectors(this.target,this.camera.position)}setCameraPositionByTarget(t,e){return g(this,null,function*(){let i=this.target.clone(),s=this.getCameraLookAt();if(!e){this.camera.position.copy(t.clone().sub(s)),this.target.copy(t.clone()),this.update();return}return Mt(new Promise(o=>{let n=new ms(i,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(i.clone().sub(s)),this.target.copy(i.clone()),this.update()}).onComplete(()=>{this.tweenGroup.remove(n),this.enabled=!0,o(!0)}).onStart(()=>{this.enabled=!1}).start()}),e+500)})}setZoom(t,e,i){i===void 0&&(i=!1);let{minZoom:s,maxZoom:o}=this;(i||t>=s&&t<=o)&&(this.camera.position.copy(e.clone().sub(this.getCameraLookAt())),this.target.copy(e),this.camera.zoom=t,this.update())}setZoomByDuration(t,e,i,s){return g(this,null,function*(){i===void 0&&(i=!1),s===void 0&&(s=500);let o={zoom:this.camera.zoom,target:this.target.clone()};if(!(t===this.camera.zoom&&!i))return s?Mt(new Promise(n=>{let r=new ms(o,this.tweenGroup).to({zoom:t,target:e},s).onUpdate(()=>{this.setZoom(o.zoom,o.target,i)}).onComplete(()=>{this.tweenGroup.remove(r),this.enabled=!0,n(!0)}).onStart(()=>{this.enabled=!1}).start()}),s+500).finally(()=>{this.enabled=!0}):this.setZoom(t,e,i)})}setTargetByOffset(t,e){if(e===void 0&&(e=this.target.clone()),this.camera.updateMatrix(),t){let i=new Zr;i.setFromMatrixColumn(this.camera.matrix,1),i.normalize(),i.multiplyScalar(t/this.camera.zoom),e.add(i)}this.setCameraPositionByTarget(e,0)}clearTween(){this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll()}dispose(){super.dispose(),this.unRegistryEvent(),this.clearTween()}constructor(t,e,i){super(e,i),this.context=t,this.camera=e,this.domElement=i,this.prevCameraZoom=1,this.tweenGroup=new Yd,this.offsetY=0,this.onChange=()=>{let s=this.camera.zoom;s!==this.prevCameraZoom&&(this.prevCameraZoom=s,this.dispatchEvent({type:"change-zoom",zoom:s}))},this.tweenUpdate=()=>{this.tweenGroup.update()},this.enableDamping=!1,this.zoomSpeed=.5,this.prevCameraZoom=e.zoom,this.registryEvent()}};import{EventDispatcher as qd,WebGLRenderer as $d,LinearToneMapping as Jd}from"three";var gs=class extends $d{setCameraAndScene(t,e){this.scene=t,this.camera=e}autoRender(){if(this.scene&&this.camera&&this.enable&&(this.event.dispatchEvent({type:"update"}),this.render(this.scene,this.camera)),this.context.config.renderAnimation==="requestAnimationFrame")this.timer.requestAnimationFrame(()=>{this.autoRender()});else{let t=1e3/this.context.config.fps;this.timer.setTimeout(()=>{this.autoRender()},t)}}pauseRender(){this.enable=!1}continueRender(){this.enable=!0}addEventListener(t,e){this.event.addEventListener(t,e)}removeEventListener(t,e){this.event.removeEventListener(t,e)}constructor(t,e){var i,s;super(w({antialias:!0,alpha:!0},e)),this.context=t,this.event=new qd,this.enable=!0,this.timer=new K,this.onContextLost=r=>{r.preventDefault(),this.enable=!1,console.warn("[crc-bmap] WebGL context lost")},this.onContextRestored=()=>{this.enable=!0,console.warn("[crc-bmap] WebGL context restored"),this.context.forceUpdate()},this.autoClear=!0;let o=((s=this.context.config)==null||(i=s.renderer)==null?void 0:i.maxPixelRatio)||2;this.setPixelRatio(Math.min(window.devicePixelRatio||1,o)),this.toneMapping=Jd,this.toneMappingExposure=1,this.domElement.addEventListener("webglcontextlost",this.onContextLost,!1),this.domElement.addEventListener("webglcontextrestored",this.onContextRestored,!1);let n=this.dispose;this.dispose=()=>{var r,h;this.timer.dispose(),this.enable=!1,(r=this.domElement)==null||r.removeEventListener("webglcontextlost",this.onContextLost,!1),(h=this.domElement)==null||h.removeEventListener("webglcontextrestored",this.onContextRestored,!1),n.call(this),this.domElement.remove(),this.domElement=null,this.shadowMap=null,this.info.programs&&(this.info.programs.length=0),this.info=null}}};import{Scene as eu}from"three";import{PMREMGenerator as Qd}from"three";import{RoomEnvironment as tu}from"three/examples/jsm/environments/RoomEnvironment.js";function jr(a,t){t===void 0&&(t=.85);let e=new Qd(a);return e.compileEquirectangularShader(),e.fromScene(new tu).texture}var ys=class extends eu{dispose(){var t;(t=this.environment)==null||t.dispose(),this.environment=null,F(this),this.clear()}constructor(t){super(),this.environment=jr(t)}};import{OrthographicCamera as iu}from"three";var vs=class extends iu{constructor(t,e){super(-t/2,t/2,e/2,-e/2,-1e4,5e4),this.up.set(0,0,1),this.position.set(0,0,100),this.lookAt(0,0,0)}};import{polygon as Kr}from"@turf/turf";import"core-js/modules/es.array.unshift.js";import"core-js/modules/es.array.push.js";import{Vector3 as su}from"three";var xs=class{registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-change",this.onControlChange),this.context.addEventListener("resize",this.onControlChange)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-change",this.onControlChange),this.context.removeEventListener("resize",this.onControlChange)}changePoiLevelOrCollisionEnable(t){let e=this.objects.findIndex(i=>i===t);e!==-1&&(this.objects.splice(e,1),this.addObject(t))}addObject(t){if(!this.objects.includes(t)){if(this.needsUpdate=!0,!t.options.collision_enable){this.objects.unshift(t);return}if(t.options.level===0){this.objects.push(t);return}for(let e=0;e<this.objects.length;e++){let i=this.objects[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.objects.splice(e,0,t);return}}this.objects.push(t)}}removeObject(t){let e=this.objects.indexOf(t);e!==-1&&(this.objects.splice(e,1),this.needsUpdate=!0)}removeObjects(t){this.objects=this.objects.filter(e=>!t.includes(e)),this.needsUpdate=!0}getObjectById(t){return this.objects.find(e=>e.options.id===t)||null}validShowParkingSpace(t){t===void 0&&(t=60);let{clientSize:{width:e,height:i},control:s,camera:o}=this.context,n=Math.min(e/t,i/t,s.maxZoom-1);return o.zoom>=n}detectCollisions(){if(!this.needsUpdate)return;let t=[],{camera:e}=this.context;e.updateMatrixWorld();let i=l=>l<=1&&l>=-1,s=e.projectionMatrix.clone();s.multiply(e.matrixWorldInverse);let o=e.zoom/this.context.basicZoom,n=25/30,r=Math.min(25,Math.max(1,o*n)),h=this.validShowParkingSpace();this.objects.filter(l=>{if(l.visible){if(!(r<=l.options.maxWeight&&r>=l.options.minWeight)||!h&&l.userData.type==="parkingSpace")return l.parentSetVisible(!1),!1;let p=l.getLabelOriginWorldPosition(new su);return p.applyMatrix4(s),l.screenPosition=p,i(p.x)&&i(p.y)&&i(p.z)?!0:(l.parentSetVisible(!1),!1)}return!1}).forEach((l,p)=>{let d=l.getBox(l.screenPosition);if(d===null)return;if(p===0||!l.options.collision_enable){t.push(d),l.parentSetVisible(!0);return}let u=t.some(f=>f.intersectsBox(d));l.parentSetVisible(!u),u||t.push(d)}),this.needsUpdate=!1}markForUpdate(){this.needsUpdate=!0}clear(){this.objects=[],this.needsUpdate=!0}dispose(){this.objects=[],this.unRegistryEvent()}constructor(t){this.context=t,this.objects=[],this.needsUpdate=!0,this.onUpdate=()=>{this.detectCollisions()},this.onControlChange=()=>{this.needsUpdate=!0},this.registryEvent()}};var ws=class extends ou{get config(){return this.bmap.config}get center(){return this.bmap.buildingCenter}setRange(t){this.range=Kr([t])}resizeClientSize(){let{x:t,y:e,width:i,height:s}=this.container.getBoundingClientRect();this.clientSize={width:i||this.container.clientWidth,height:s||this.container.clientHeight,x:t,y:e}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=new vs(t,e),this.renderer.setSize(t,e),this.renderer.setCameraAndScene(this.scene,this.camera),this.renderer.autoRender(),this.control=new fs(this,this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",this.onControlChange),this.control.addEventListener("change-zoom",this.onControlChangeZoom),this.renderer.addEventListener("update",this.onRendererUpdate),this.cameraBound=new ls(this)}getRatio(t,e){t===void 0&&(t=new Dt(0,0,0)),e===void 0&&(e=new Dt(100,0,0));let{clientWidth:i,clientHeight:s}=this.container,o=L(t,this.camera,i,s),n=L(e,this.camera,i,s);return Math.ceil(Math.sqrt((n.x-o.x)**2+(n.y-o.y)**2))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof hu&&(e.color=new au(t))})}switchFloor(t,e){e===void 0&&(e=!0),console.log("switchFloor",e),this.currentFloor&&(this.scene.remove(this.currentFloor),e?this.currentFloor.dispose():this.currentFloor.onRemoveFromScene()),this.currentFloor=t,this.setRange(t.userData.range||[]),this.scene.add(t),t.onAddToScene("scene"),this.cameraBound.updateBox()}getGraphicsByDeviceXy(t,e){var i,s;let o=new me;o.x=t/this.clientSize.width*2-1,o.y=e/this.clientSize.height*-2+1;let n=new Vr;n.setFromCamera(o,this.camera),n.ray.origin.sub(n.ray.direction.clone().multiplyScalar(100));let r=(i=this.currentFloor)==null?void 0:i.graphicLayer.getGraphicByRaycaster(n),h=(s=this.currentFloor)==null?void 0:s.parkingSpaceLayer.getParkingSpaceByRaycaster(n);return r!=null&&r.graphics.length&&(h!=null&&h.graphics.length)?r.distance<h.distance?r:h:r!=null&&r.graphics.length?r:h!=null&&h.graphics.length?h:{graphics:[],position:null}}getPoisByDeviceXy(t,e){var i,s;let o=(i=this.currentFloor)==null?void 0:i.poiLayer.getPoiByDeviceXy(t,e),n=(s=this.currentFloor)==null?void 0:s.poiLayer2.getPoiByDeviceXy(t,e);return(o||[]).concat(n||[])}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.container.addEventListener("pointercancel",this.onPointerleave),this.container.addEventListener("pointerout",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.container.removeEventListener("pointercancel",this.onPointerleave),this.container.removeEventListener("pointerout",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange),this.control.removeEventListener("change",this.onControlChange),this.control.removeEventListener("change-zoom",this.onControlChangeZoom),this.renderer.removeEventListener("update",this.onRendererUpdate)}setPolarAngle(t,e){return e===void 0&&(e=500),this.control.setPolarAngleByDuration(t,!0,e)}setAzimuthalAngle(t,e){return e===void 0&&(e=500),this.control.setAzimuthalAngleDuration(t,!0,e)}getCameraLookAt(){return this.control.getCameraLookAt()}setZoom(t,e,i){return i===void 0&&(i=500),this.control.setZoomByDuration(t,e,!0,i)}getFitCameraToObjectZoom(t,e,i){return e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=!0),this.getFitCameraToBoxZoom(new ru().setFromObject(t),e,i)}getFitCameraToBoxZoom(t,e,i){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=!0);let[s,o,n,r]=e,{clientSize:{width:h,height:c}}=this,l=this.control.getPolarAngle();i&&this.setPolarAngle(0,0),this.camera.updateMatrixWorld(),this.camera.updateProjectionMatrix();let{max:p,min:d}=t,u=new Dt(d.x,p.y,p.z),f=new Dt(p.x,p.y,p.z),x=new Dt(p.x,d.y,d.z),m=new Dt(d.x,d.y,d.z),y=L(u,this.camera,h,c),_=L(f,this.camera,h,c),P=L(m,this.camera,h,c),S=L(x,this.camera,h,c),k=new nu().setFromPoints([new me(y.x,y.y),new me(_.x,_.y),new me(P.x,P.y),new me(S.x,S.y)]).getSize(new me),b=(h-o-r)/k.x,G=(c-s-n)/k.y,R=Math.min(b,G),O=new Dt((p.x+d.x)/2,(p.y+d.y)/2,(p.z+d.z)/2),$=R*this.camera.zoom,nt=this.camera.clone();nt.zoom=$,nt.updateMatrix();let W=(o-r)/2,J=(s-n)/2;if(W){let z=new Dt;z.setFromMatrixColumn(nt.matrix,0),z.normalize(),z.multiplyScalar(W/$),O.add(z)}if(J){let z=new Dt;z.setFromMatrixColumn(nt.matrix,1),z.normalize(),z.multiplyScalar(J/$),O.add(z)}return i&&this.setPolarAngle(l,0),{zoom:R*this.camera.zoom,center:O}}fitCameraToObject(t,e,i,s){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500),s===void 0&&(s=!0);let{zoom:o,center:n}=this.getFitCameraToObjectZoom(t,e,s);return this.setZoom(o,n,i)}fitCameraToBox(t,e,i,s){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500),s===void 0&&(s=!0);let{zoom:o,center:n}=this.getFitCameraToBoxZoom(t,e,s);return this.setZoom(o,n,i)}getFitCameraToGroundZoom(t,e,i){if(t===void 0&&(t=[20,20,20,20]),e===void 0&&(e=500),i===void 0&&(i=!0),this.currentFloor&&this.currentFloor.hasElement)return this.getFitCameraToObjectZoom(this.currentFloor.groundUpper,t,i).zoom}fitCameraToGround(t,e,i){return t===void 0&&(t=[20,20,20,20]),e===void 0&&(e=500),i===void 0&&(i=!0),this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundLayer,t,e,i):Promise.resolve(!1)}setCameraPosition(t,e){return g(this,null,function*(){return this.control.setCameraPositionByTarget(t,e)})}pauseRender(){this.renderer.pauseRender()}continueRender(){this.renderer.continueRender()}forceUpdate(){this.collisionSystem.needsUpdate=!0}dispose(){var t;this.collisionSystem.dispose(),(t=this.currentFloor)==null||t.dispose(),this.control.dispose(),this.cameraBound.dispose(),this.selection.dispose(),this.hoverHelper.dispose(),this.unRegistryEvent(),this.renderer.dispose(),this.lights.children.forEach(e=>e.dispose()),this.scene.dispose(),this.container=null,this.renderer=null}constructor(t,e){super(),this.container=t,this.lights=nn(),this.range=Kr([]),this.clientSize={width:0,height:0,x:0,y:0},this.renderRf=0,this.basicZoom=1,this.debugCollisionBox=!1,this.onControlChange=()=>{this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})},this.onControlChangeZoom=s=>{let{zoom:o}=s;this.dispatchEvent({type:"control-zoom-change",zoom:o})},this.onRendererUpdate=()=>{this.dispatchEvent({type:"update"})},this.onWindowResize=()=>{let{container:s,camera:o,renderer:n}=this,{clientWidth:r,clientHeight:h}=s;r=Math.max(1,r),h=Math.max(1,h),o.left=-r/2,o.right=r/2,o.top=h/2,o.bottom=-h/2,o.updateProjectionMatrix(),n.setSize(r,h),this.resizeClientSize(),this.dispatchEvent({type:"resize",width:r,height:h})},this.onClick=s=>{let{graphics:o,position:n}=this.getGraphicsByDeviceXy(s.offsetX,s.offsetY);o.length&&this.dispatchEvent({type:"graphic-click",graphics:o,position:n});let r=this.getPoisByDeviceXy(s.offsetX,s.offsetY);r.length&&this.dispatchEvent({type:"poi-click",pois:r});let h=null,c=new me;c.x=s.offsetX/this.clientSize.width*2-1,c.y=s.offsetY/this.clientSize.height*-2+1;let l=new Vr;l.setFromCamera(c,this.camera);let p=new cu(new Dt(0,0,1),0),d=new Dt;if(l.ray.intersectPlane(p,d)?h=d:(l.ray.direction.negate(),l.ray.intersectPlane(p,d)&&(h=d)),h){let u=this.bmap.coordinateTransform.worldToMercator(h);this.dispatchEvent({type:"click",position:h,mercator:u})}},this.onPointerover=s=>{let{graphics:o,position:n}=this.getGraphicsByDeviceXy(s.offsetX,s.offsetY),r=this.getPoisByDeviceXy(s.offsetX,s.offsetY);this.dispatchEvent({type:"pointer-over",e:s,graphics:o,pois:r,position:n})},this.onPointermove=s=>{let{graphics:o,position:n}=this.getGraphicsByDeviceXy(s.offsetX,s.offsetY),r=this.getPoisByDeviceXy(s.offsetX,s.offsetY);this.dispatchEvent({type:"pointer-move",e:s,graphics:o,pois:r,position:n})},this.onPointerleave=s=>{this.dispatchEvent({type:"pointer-level"})},this.onSelectionSelect=s=>{let{graphics:o,isMultipleSelect:n}=s;this.dispatchEvent({type:"select-graphic",graphics:o,isMultipleSelect:n})},this.onHoverChange=s=>{let{graphics:o}=s;this.dispatchEvent({type:"hover",graphics:o})},this.bmap=e,this.container.style.position="relative",this.container.style.overflow="hidden";var i;this.renderer=new gs(this,{antialias:(i=this.config.renderer.antialias)!=null?i:!vi}),this.scene=new ys(this.renderer),this.collisionSystem=new xs(this),this.init(),this.selection=new hs(this),this.hoverHelper=new cs(this),this.resizeClientSize(),this.registryEvent()}};import{merge as lu}from"lodash";var pu={placeId:0,fps:30,apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get",equipmentList:"/api/inception-map/equipment/get",roadNetwork:"/api/inception-map/road_network/get",loadPlaceInfo:"https://screen.aibee.cn/ai-map/map/get-floor-map"},enableBoxSelect:!0,resizeObserver:{enable:!1,debounceTime:5},initTransToMark:!1,heatMap:{radius:50,minOpacity:.1,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2,defaultPolar:1.1,defaultAzimuthal:0,maxZoomScale:30},defaultPadding:[20,20,20,20],svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:100},ground:{color:"#F6F6F6",opacity:1,height:.001,stroke:!1,strokeColor:"#E6E6E6",strokeOpacity:1},markGraphic:{color:"#EEF0F3",opacity:1,height:.001,stroke:!1,strokeColor:"#000",strokeOpacity:1},graphic:{fillOpacity:1},cameraBound:{padding:[150,150,150,150]},poi:{boxScale:1,batchText:!0,batchIcon:!0},loaderPlaceConfig:{textFontSize:14},poiTextBackground:{enable:!1,color:"#FFFFFF",opacity:1},poiTextFontFamily:"sans-serif",renderAnimation:"setTimeout",renderer:{maxPixelRatio:2}};function Xr(a){return typeof a.resizeObserver=="boolean"&&(a.resizeObserver={enable:a.resizeObserver}),lu({},pu,a)}import{debounce as Du}from"lodash";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.error.cause.js";import{Vector3 as Su,Color as Cu}from"three";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";var _s=function(a){return a.LAYERED_RENDER_VERSION="layeredRender",a.MERGED_RENDER_VERSION="mergedRender",a}({});function Ps(a,t){let e=a.poi_info.showName||a.store_name||a.poi_info.text;switch(t){case"zh-cn":return e;case"en":var i;return((i=a.store_info_ext)==null?void 0:i.poi_name)||e;case"zh-hk":var s;return((s=a.store_info_ext)==null?void 0:s.traditional_name)||e}}function Ms(a,t){let e=a.poi_info.showName||a.store_name||a.poi_info.text;switch(t){case"zh-cn":return e;case"en":var i;return((i=a.infra_info_ext)==null?void 0:i.poi_name)||e;case"zh-hk":var s;return((s=a.infra_info_ext)==null?void 0:s.traditional_name)||e}}var Lo=["range","ground","store","facility","parkingSpace"];function Yr(a){return Lo.indexOf(a.l_type)===-1?Lo.length:Lo.indexOf(a.l_type)}function du(a){a.layers.sort((t,e)=>Yr(t)-Yr(e))}function uu(a){let t=a.layers.find(i=>i.l_type==="range"),e=[t.elements[0].center_x,t.elements[0].center_y];a.layers.map(i=>{if(i.l_type!=="range")return Pi(i.elements,e)})}function oi(a){du(a),uu(a)}function Re(a,t){return t===void 0&&(t=6),a.floor_id+"_"+a.version_id+(t?"_"+t:"")}function qr(a,t,e){switch(a.l_type){case"ground":return ko(a,t);case"graph":return mu(a,t,e);case"wall":return fu(a,t);case"lane":return gu(a,t);case"texture2d":case"texture3d":return yu(a,t);case"glb":return vu(a,t);case"store":return xu(a,t,e);case"facility":return _u(a,t,e);case"parkingSpace":return Mu(a,t,e);case"text":return Eu(a,t)}}function $r(a,t,e,i,s){switch(a.l_type){case"store":return wu(a,t,e,i,s);case"facility":return Pu(a,t,e,i,s);case"parkingSpace":return bu(a,t,i,s)}}function mu(a,t,e){e.mergeGraphic?t.mergeGraphicLayer.addGraphics(a.elements,a.mergedElements):a.elements.map(i=>{let s=t.addGraphic(w({},i,{dashed:!1}));t.userData.graphics.push(s),t.userData.graphicMap.set(i.id,s)})}function ko(a,t){let e=a.elements.map(i=>new Y(t.context,w({},i,{dashed:!1})));t.addGrounds(e)}function fu(a,t){if(a.mergedElements)a.mergedElements.map(e=>{if(e.instancedGeometry){let i=new rs(t.context,e.instancedGeometry);t.wallLayer.add(i)}if(e.mergedGeometry){let i=new is(t.context,e);t.wallLayer.add(i),e.mergedGeometry=null}});else{let e=a.elements.reduce((i,s)=>{let{fillColor:o,fillOpacity:n,strokeColor:r,strokeOpacity:h,height:c}=s,l=o.toLowerCase()+"-"+n+"-"+r.toLowerCase()+"-"+h+"-"+c;return h===0&&(l=o.toLowerCase()+"-"+n+"-"+c),i[l]?i[l].push(s):i[l]=[s],i},{});Object.values(e).forEach(i=>{let s=new Ji(t.context,i);t.wallLayer.add(s)})}}function gu(a,t){if(a.mergedElements){let e=new os(t.context,a.mergedElements);t.laneLayer.add(e)}else{let e=new ts(t.context,a.elements);t.laneLayer.add(e)}}function yu(a,t){if(a.mergedMatrixes)a.mergedMatrixes.map(e=>{let i=new pe(t.context,e);t.textureLayer.add(i)});else if(a.elements.length){let e=new le(t.context,a.elements);t.textureLayer.add(e)}}function vu(a,t){t.glbModelLayer.addModels(a.elements.map(e=>w({},e,{url:e.secondUrl,rotate:e.secondRotate,width:e.secondWidth,center_x:e.center_coord_x,center_y:e.center_coord_y,deltaHeight:0})))}function xu(a,t,e){e.mergeGraphic?t.mergeGraphicLayer.addGraphics(a.elements,a.mergedElements):a.elements.map(i=>{let s=t.addGraphic(w({},i,{dashed:!1}));t.userData.graphics.push(s),t.userData.graphicMap.set(i.id,s)})}function wu(a,t,e,i,s){a.elements.filter(o=>s.filterPoi(o)).map(o=>{try{let n=Ps(o,e),r=new et(t.context,{id:o.id,icon:o.poi_info.showImageUrl||o.poi_info.icon,text:n,position:{x:o.center_coord_x,y:o.center_coord_y,z:o.airHeight+o.height},icon_size:[24,24],level:o.poi_info.level||0,hide_text:!i.showStoreName,maxWeight:o.poi_info.maxWeight||25,minWeight:o.poi_info.minWeight||1,text_font_size:i.textFontSize});t.poiLayer2.pushPoi(r),r&&(r.userData.type="store",r.userData.data=o,r.userData.floor=t.name)}catch(n){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",n,o)}})}function _u(a,t,e){e.mergeGraphic?t.mergeGraphicLayer.addGraphics(a.elements,a.mergedElements):a.elements.map(i=>{let s=t.addGraphic(w({},i,{dashed:!1}));t.userData.graphics.push(s),t.userData.graphicMap.set(i.id,s)})}function Pu(a,t,e,i,s){a.elements.filter(o=>o.poi_info).filter(o=>s.filterPoi(o)).map(o=>{try{let n=Ms(o,e),r=new et(t.context,{id:o.id,icon:o.poi_info.showImageUrl||o.poi_info.icon,text:n,position:{x:o.center_coord_x,y:o.center_coord_y,z:o.airHeight+o.height},icon_size:[24,24],level:o.poi_info.level||0,hide_text:!i.showFacilityName,maxWeight:o.poi_info.maxWeight||25,minWeight:o.poi_info.minWeight||1,text_font_size:i.textFontSize});t.poiLayer2.pushPoi(r),r.userData.type="facility",r.userData.data=o,r.userData.floor=t.name}catch(n){console.log("\u6DFB\u52A0facility\u5931\u8D25",n,o)}})}function Mu(a,t,e){t.parkingSpaceLayer.load(a,e.mergeParkingSpace),t.userData.parkingSpaces=t.parkingSpaceLayer.graphicMap.values(),t.userData.parkingSpacesGraphicMap=t.parkingSpaceLayer.graphicMap}function bu(a,t,e,i){return g(this,null,function*(){a.elements.filter(o=>o.texts[0]).filter(o=>i.filterPoi(o)).forEach(o=>{try{let n=o.displayName||o.texts[0],r=new et(t.context,{id:o.id,text:n,position:{x:o.center_coord_x,y:o.center_coord_y,z:o.airHeight+o.height},text_font_size:e.textFontSize});r&&(r.userData.type="parkingSpace",r.userData.data=o,r.userData.floor=t.name),t.poiLayer2.pushPoi(r)}catch(n){console.log("\u6DFB\u52A0\u8F66\u4F4Dpoi\u5931\u8D25",n,o)}})})}function Eu(a,t){let e=new es(t.context,a.elements.map(i=>w({},i,{center_x:i.center_coord_x,center_y:i.center_coord_y})));t.textTextureLayer.add(e)}function Ao(){return new Worker(new URL("./worker/loader.worker-XZ4WO3FM.js",import.meta.url))}var Tu={mergeParkingSpace:!0,mergeGraphic:!0,renderVersion:_s.MERGED_RENDER_VERSION,layers:["graph","wall","lane","texture2d","texture3d","glb","store","facility","parkingSpace","text"],filterPoi:()=>!0},Oe=class extends st{initDb(){return g(this,null,function*(){try{let{db:t}=yield Ye();this.db=t}catch(t){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",t)}})}load(t,e){return g(this,null,function*(){if(Array.isArray(t))this.floors=t,e&&(this.placeConfig=w({},this.placeConfig,e));else if(typeof t=="string"){let i=yield fetch(t).then(s=>s.json());if(i.code===200){let s=location.origin;this.floors=i.data.list.map(o=>{let n=/^http(s?):\/\//.test(o.entry_infra_url),r=/^http(s?):\/\//.test(o.map_url),h=/^http(s?):\/\//.test(o.route_url);return w({},o,{entry_infra_url:n?o.entry_infra_url:""+s+o.entry_infra_url,map_url:r?o.map_url:""+s+o.map_url,route_url:h?o.route_url:""+s+o.route_url})}),this.placeConfig=w({},this.placeConfig,JSON.parse(i.data.config||"{}"),e)}}else return this.load("https://screen.aibee.cn/ai-map/map/get-floor-map?place_id="+t,e);this.preloadPromise=this.getOtherDataByFreeTime()})}waitForPreload(){return this.preloadPromise}setCacheData(t,e,i){return g(this,null,function*(){let s=yield Xe();return this.db=s,Ti(t,""+e,i,s)})}getCacheData(t,e){return g(this,null,function*(){let i=yield Xe();return this.db=i,qe(t,""+e,i)})}getCacheDataWithRetry(t,e,i,s){return g(this,null,function*(){i===void 0&&(i=3),s===void 0&&(s=50);for(let o=0;o<i;o++){let n=yield this.getCacheData(t,e);if(n)return n;o<i-1&&(yield new Promise(r=>setTimeout(r,s)))}return null})}getFloorData(t){return g(this,null,function*(){let e=yield this.getFloorJsonData(t);return e?this.getDataByJson(e):null})}getFloorDataByFloorInfo(t){return g(this,null,function*(){let e=yield this.getFloorJsonDataByFloorInfo(t);return this.getDataByJson(e)})}setLocale(t){this.locale=t,this.bmap.context.currentFloor&&this.bmap.context.currentFloor.poiLayer2.pois.forEach(e=>{e.userData.type==="store"&&(e.options.text=Ps(e.userData.data,t)),e.userData.type==="facility"&&(e.options.text=Ms(e.userData.data,t))})}readFloorFromCache(t,e){return g(this,null,function*(){e===void 0&&(e=!1);try{let i=Re(t),s=e?yield this.getCacheDataWithRetry(ct.MAP_DATA,i):yield this.getCacheData(ct.MAP_DATA,i);if(s&&s.transformed)return console.log("\u4ECE\u7F13\u5B58\u4E2D\u53D6\u5230\u4E86\u5408\u5E76\u540E\u7684\u6570\u636E"),s;if(this.options.renderVersion===_s.LAYERED_RENDER_VERSION){let o=Re(t,1),n=e?yield this.getCacheDataWithRetry(ct.MAP_DATA,o):yield this.getCacheData(ct.MAP_DATA,o);if(n)return console.log("\u4ECE\u7F13\u5B58\u4E2D\u53D6\u5230\u4E86\u6570\u636E"),n}return null}catch(i){return console.warn("[read floor cache error]",i),null}})}getFloorJsonDataByFloorInfo(t){return g(this,null,function*(){let e=yield this.readFloorFromCache(t);if(e)return e;let i=this.getFloorDataPromise.get(t.floor);if(i)return i;let s=Re(t),o=g(this,null,function*(){let r=yield fetch(t.map_url).then(h=>h.json());r.floor=t.floor,oi(r);try{yield this.setCacheData(ct.MAP_DATA,s,r),yield this.setCacheData(ct.MAP_VERSION,s,t.version_id)}catch(h){console.warn("[cache floor data error]",h)}return r});this.getFloorDataPromise.set(t.floor,o);let n=()=>{this.getFloorDataPromise.get(t.floor)===o&&this.getFloorDataPromise.delete(t.floor)};return o.then(n,n),o})}getFloorJsonData(t,e){return g(this,null,function*(){e===void 0&&(e=!1);let i=this.floors.find(s=>s.floor===t);return i?new Promise(s=>g(this,null,function*(){try{let o=yield this.readFloorFromCache(i,e);if(o){s(o);return}let n=this.getFloorDataPromise.get(t);if(n)try{s(yield n);return}catch(r){this.getFloorDataPromise.delete(t)}if(e){s(this.getFloorJsonDataByFloorInfo(i));return}if(console.log("\u7F13\u5B58\u4E2D\u6CA1\u6709\u6570\u636E"),this.loadWorker){H(this.loadWorker,"adjust_floor_priority",{floor:t});let r,h=c=>{if(c.data.type==="floor_success"&&c.data.data.floor===t){var l;r&&clearTimeout(r),(l=this.loadWorker)==null||l.removeEventListener("message",h),s(this.getFloorJsonData(t,!0))}};r=setTimeout(()=>{var c;(c=this.loadWorker)==null||c.removeEventListener("message",h),s(this.getFloorJsonDataByFloorInfo(i))},1500),this.loadWorker.addEventListener("message",h)}else s(this.getFloorJsonDataByFloorInfo(i))}catch(o){console.log("[get floor data error]",o),s(this.getFloorJsonDataByFloorInfo(i))}})):null})}getRoadNetworkData(){return g(this,null,function*(){return(yield Promise.all(this.floors.map(e=>g(this,null,function*(){let i=Re(e,0);try{let s=yield this.getCacheData(ct.ROAD_NETWORK_DATA,i);if(s)return s;let o=yield fetch(e.route_url).then(n=>n.json());return this.setCacheData(ct.ROAD_NETWORK_DATA,i,o),this.setCacheData(ct.ROUTE_VERSION,i,e.version_id),o}catch(s){let o=yield fetch(e.route_url).then(n=>n.json());return this.setCacheData(ct.ROAD_NETWORK_DATA,i,o),o}})))).filter(e=>e.points)})}getFacilitiesData(){return g(this,null,function*(){let t=this.floors.reduce((s,o)=>s.updated_at>o.updated_at?s:o,this.floors[0]);if(!t)return null;let e=Re(t,0),i=()=>g(this,null,function*(){let s=yield fetch(t.entry_infra_url).then(o=>o.json());return s&&(this.setCacheData(ct.FACILITY_DATA,e,s),this.setCacheData(ct.FACILITY_VERSION,e,t.version_id)),s});try{let s=yield this.getCacheData(ct.FACILITY_DATA,e);return s||i()}catch(s){return console.log("[get facility error]",s),i()}})}getOtherDataByFreeTime(){return g(this,null,function*(){yield this.initDbPromise,this.loadWorker&&(yield H(this.loadWorker,"load",{floors:this.floors,version:this.options.renderVersion})),this.closeWorker()})}getMulFloorsData(t){return g(this,null,function*(){return Promise.all(t.map(e=>this.getFloorData(e))).then(e=>e.filter(i=>i))})}getDataByUrl(t){return g(this,null,function*(){let e=yield fetch(t).then(i=>i.json());return this.getDataByJson(e)})}getDataByJson(t,e,i){return g(this,null,function*(){t.transformed||oi(t),e=this.getFloorBaseLayer(t,e);let s=w({},this.placeConfig,i);return yield this.getFloorContentLayer(t,e),yield this.getFloorPoi(t,e,s),this.changeFloorBox(t,e),e})}getDataByJsonStep(t,e,i){return g(this,null,function*(){t.transformed||oi(t),e=this.getFloorBaseLayer(t,e);let s=w({},this.placeConfig,i);return this.changeFloorBox(t,e),requestAnimationFrame(()=>g(this,null,function*(){yield this.getFloorContentLayer(t,e),this.changeFloorBox(t,e),requestAnimationFrame(()=>g(this,null,function*(){yield this.getFloorPoi(t,e,s),this.changeFloorBox(t,e)}))})),e})}changeFloorBox(t,e){e.updateBox();let i=e.box.getSize(new Su),s=Math.max(i.x,i.y,i.z);e.userData.height=s/4+t.floorHeight}switchFloor(t,e){return g(this,null,function*(){return new Promise(i=>{let s={run:()=>this._switchFloor(t,e),meta:{type:"switchFloor"}},o=this.taskQueue.replaceByMetaType(s),n=r=>{let{task:h,res:c}=r;h.tid===o&&(this.taskQueue.removeEventListener("active-task-end",n),i(c))};this.taskQueue.addEventListener("active-task-end",n)})})}_switchFloor(t,e){return g(this,null,function*(){var i;let s=typeof t=="string"?t:(i=t==null?void 0:t.floor)!=null?i:"";try{var o;let h=t;if(typeof t=="string"){let u=yield this.getFloorJsonData(t);if(!u)throw new Error("floor data unavailable: "+t);h=u}else t.transformed||oi(t);let c=w({},this.placeConfig,e),l=new zt(this.bmap.context);l.userData.data=h;let p=this.floors.find(u=>u.floor===h.floor);var n;let d=(n=p==null?void 0:p.map_angle)!=null?n:0;this.bmap.dispatchEvent({type:lt.SWITCH_FLOOR_BEFORE,data:{curFloor:l,graphics:[]}}),this.dispatchEvent({type:"switch-floor-before",data:{curFloor:l,graphics:[],floorData:h}}),this.bmap.context.scene.background=new Cu(c.backgroundColor),this.getFloorBaseLayer(h,l),this.changeFloorBox(h,l),this.bmap.buildingCenter=l.userData.center;var r;return this.bmap.currentBuildGround=(r=(o=h.layers.find(u=>u.l_type==="range"))==null?void 0:o.elements[0])!=null?r:null,this.bmap.context.switchFloor(l),this.bmap.config.control.defaultAzimuthal=d/180*Math.PI,this.bmap.initialFloorCamera(),this.bmap.context.cameraBound.updateBox(),this.dispatchEvent({type:"switch-floor-ground",data:{curFloor:l,graphics:[]}}),this.bmap.dispatchEvent({type:lt.SWITCH_FLOOR_GROUND,data:{curFloor:l}}),yield qs(),yield this.getFloorContentLayer(h,l),this.changeFloorBox(h,l),this.bmap.context.cameraBound.updateBox(),this.dispatchEvent({type:"switch-floor-content",data:{curFloor:l,graphics:[]}}),yield pn(2),yield this.getFloorPoi(h,l,c),this.dispatchEvent({type:"switch-floor-after",data:{curFloor:l,graphics:l.graphicLayer.children}}),this.bmap.dispatchEvent({type:lt.SWITCH_FLOOR_AFTER,data:{curFloor:l,graphics:l.graphicLayer.children}}),l}catch(h){return console.warn("[switch floor error]",h),this.dispatchEvent({type:"switch-floor-error",data:{floor:s,error:h}}),null}})}getFloorBaseLayer(t,e){e||(e=new zt(this.bmap.context));let i=[0,0];return t.layers.forEach(s=>{switch(s.l_type){case"range":let o=s.elements[0];i=[o.center_x,o.center_y],e.userData.range=o.geometry.cds[0],e.userData.rangeGraphic=o;break;case"ground":ko(s,e);break;default:break}}),e.userData.center=i,e.name=t.floor,e.userData.data=t,e}getFloorContentLayer(t,e){return g(this,null,function*(){e||(e=new zt(this.bmap.context)),e.userData.graphics=[],e.userData.graphicMap=new Map;let i=Date.now();for(let s=0;s<t.layers.length;s++){let o=t.layers[s];["range","ground"].includes(o.l_type)||this.options.layers.includes(o.l_type)&&(qr(o,e,this.options),console.log("time",Date.now()-i,o.l_type),i=Date.now())}return e})}getFloorPoi(t,e,i){return g(this,null,function*(){i===void 0&&(i=this.placeConfig);let s=Date.now();yield Promise.all(t.layers.map(n=>{if(this.options.layers.includes(n.l_type))return $r(n,e,this.locale,i,this.options)})),console.log("poi time",Date.now()-s);let o=Date.now();qs().then(()=>{console.log("poi render time",Date.now()-o)})})}clear(){return g(this,null,function*(){this.db=null,this.getFloorDataPromise.clear()})}closeWorker(){this.loadWorker&&(this.loadWorker.terminate(),this.loadWorker=null)}dispose(){this.disposed||(this.disposed=!0,super.dispose(),this.clear(),this.closeWorker(),this.getFloorDataPromise.clear())}constructor(t,e={}){super(),this.bmap=t,this.disposed=!1,this.floors=[],this.initDbPromise=Promise.resolve(),this.preloadPromise=Promise.resolve(),this.db=null,this.taskQueue=new Pe,this.loadWorker=Ao(),this.locale="zh-cn",this.placeConfig={backgroundColor:"#f1f7f6",showFacilityName:!0,showStoreName:!0,textFontSize:14},this.getFloorDataPromise=new Map,this.options=w({},Tu,e),this.placeConfig=w({},this.placeConfig,t.config.loaderPlaceConfig),this.initDbPromise=this.initDb()}};import"core-js/modules/web.dom-collections.iterator.js";function Jr(a,t){return g(this,null,function*(){let{brand:e,project:i}=a,{apiDomain:s,apiPath:{floorRange:o},apiInfo:n}=t,r=""+s+o+"?brand="+e+"&project="+i+"&phase="+i+"&building="+i;return yield fetch(r,n).then(c=>c.json()).then(c=>c.data).then(c=>{let l=(c||[])[0];return l&&(l.info=JSON.parse(l.info)),l})})}function Qr(a,t){return g(this,null,function*(){let{brand:e,project:i,floor:s,ts:o,resource_type_list:n}=a,{apiDomain:r,apiPath:{floorGraphic:h},apiInfo:c}=t,l=""+r+h+"?brand="+e+"&project="+i+"&phase="+i+"&building="+i+"&floor="+s+"&ts="+o+"&resource_type_list="+n;return yield fetch(l,c).then(d=>d.json()).then(d=>d.data).then(d=>((d||[]).map(u=>u.info=JSON.parse(u.info)),d||[]))})}function G1(a,t){return g(this,null,function*(){let{project:e,floor:i}=a,{apiDomain:s,apiInfo:o}=t,n=s+"/api/inception-map/external_street/get?projectCode="+e+"&floorCode="+i;return yield fetch(n,o).then(h=>h.json()).then(h=>h.data).then(h=>JSON.parse(h[0].streetInfo||"{}")).then(h=>h.fileId?Lu(h.fileId,t):null)})}function Lu(a,t){return g(this,null,function*(){let{apiDomain:e,apiInfo:i}=t;return fetch(e+"/api/inception-map/file/getFileStream?fileId="+a,i).then(s=>s.arrayBuffer()).then(s=>{let n=new TextDecoder("utf-8").decode(s);return n?JSON.parse(n):null})})}var ta=class{load(t){return g(this,null,function*(){let e=ae(t);if(this.cacheData.has(e))return this.cacheData.get(e);let[,i]=yield Promise.all([this.loadBuildGround(t),Qr(t,this.bmap.config)]),s=ae({floor:t.floor,ts:t.ts});Pi(i.map(n=>n.info),this.bmap.buildingCenter,this.floorDataLengthMap.get(s)||0),i.forEach(n=>n.info.transformToBuildingGround=!1),this.cacheData.set(e,i);let o=this.floorDataLengthMap.get(s)||0;return this.floorDataLengthMap.set(s,o+i.length),this.loadExternalStreet(t),i})}loadExternalStreet(t){return g(this,null,function*(){})}switchFloorByData(t,e){if(!t.length)return;let i=e.userData.legacyToGraphicMap||new Map,s=e.userData.graphicMap||new Map,{ground:o,markGraphic:n,graphic:r}=this.bmap.config;for(let h=0;h<t.length;h++){let c=t[h],l=w({},c,{info:w({},c.info)});if(c.info.group==="ground"){l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.height=o.height,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity,e.createGround(l.info);continue}else c.info.userData.mark?(l.info.height=n.height,l.info.fillColor=n.color,l.info.fillOpacity=n.opacity,l.info.stroke=n.stroke,l.info.strokeColor=n.strokeColor,l.info.strokeOpacity=n.strokeOpacity):(l.info.fillOpacity=r.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=n.height,l.info.fillColor=n.color,l.info.stroke=n.stroke,l.info.strokeColor=n.strokeColor,l.info.strokeOpacity=n.strokeOpacity));let p=e.addGraphic(l.info);p.userData.data=c,i.set(c.legacy_id,p),s.set(c.element_uuid,c)}e.userData.legacyToGraphicMap=i,e.userData.graphicMap=s,e.userData.rangeGraphic=this.bmap.currentBuildGround,e.userData.range=this.bmap.currentBuildGround.geometry.cds[0],e.userData.center=this.bmap.buildingCenter,e.updateBox(),e===this.bmap.context.currentFloor?(this.bmap.triggerHooks(lt.SWITCH_FLOOR_BEFORE,{curFloor:e,graphics:e.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(lt.SWITCH_FLOOR_AFTER,{curFloor:e,graphics:e.graphicLayer.children})):this.bmap.switchFloorByFloor(e)}filterData(t,e){let i=e.userData.graphicMap||new Map;return t.filter(s=>!i.has(s.element_uuid))}switchFloorByStoreData(t,e){return g(this,null,function*(){let i=yield this.load(w({},t,{resource_type_list:"6"})),s=this.filterData(i,e);this.switchFloorByData(s,e)})}switchFloorByOtherData(t,e){return g(this,null,function*(){let i=yield this.load(w({},t,{resource_type_list:"1,2,3,4"})),s=this.filterData(i,e);this.switchFloorByData(s,e)})}loadBuildGround(t){return g(this,null,function*(){let{brand:e,project:i}=t,s=yield this.loadBuildingGround({brand:e,project:i});var o;return this.bmap.currentBuildGround=(o=s==null?void 0:s.info)!=null?o:null,this.bmap.changeBuildingCenter(s,{brand:e,project:i}),this.bmap.currentBuildGround})}loadBuildingGround(t){return g(this,null,function*(){let{brand:e,project:i}=t,s=ae({brand:e,project:i});if(this.buildingGroundMap.has(s))return this.buildingGroundMap.get(s);let o=Jr({brand:e,project:i},this.bmap.config).then(n=>(this.buildingGroundMap.set(s,n),n));return this.buildingGroundMap.set(s,o),o})}switchFloor(t){return g(this,null,function*(){let e=new zt(this.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([this.switchFloorByStoreData(t,e),this.switchFloorByOtherData(t,e)])}catch(i){console.log(i)}return e})}dispose(){this.cacheData.clear(),this.floorDataLengthMap.clear(),this.buildingGroundMap.clear()}constructor(t){this.bmap=t,this.cacheData=new Map,this.floorDataLengthMap=new Map,this.buildingGroundMap=new Map,this.externalStreetMap=new Map}};var hT=function(a){return a[a.D2=0]="D2",a[a.D3=1.1]="D3",a}({}),Oo=class a extends Au{get buildingCenter(){return this.coordinateTransform.getBuildingCenter()}set buildingCenter(t){this.coordinateTransform.setBuildingCenter(t)}get basicZoom(){return this.context.basicZoom}set basicZoom(t){this.context.basicZoom=t}changeBuildingCenter(t,e){let{brand:i,project:s}=e,o=t?gi(t.info.geometry.cds[0]):[0,0];this.buildingCenter=o,this.coordinateTransform.setBuildingCenter(o),this.dispatchEvent({type:"center-change",center:o,project:s,brand:i})}use(t){t.bmap=this,this.plugins.push(t)}unUse(t){this.plugins=this.plugins.filter(e=>e!==t)}triggerHooks(t,e){this.dispatchEvent({type:t,data:e})}switchFloor(t){return g(this,null,function*(){return this.loader||(this.loader=new Oe(this),this.loader.placeConfig=w({},this.loader.placeConfig,this.config.loaderPlaceConfig),yield this.loader.load(this.config.apiPath.loadPlaceInfo+"?place_id="+this.config.placeId+"&env=prod")),this.loader.switchFloor(t)})}switchFloorByFloor(t,e,i){e===void 0&&(e=!0),i===void 0&&(i=t.graphicLayer.children),this.triggerHooks(lt.SWITCH_FLOOR_BEFORE,{curFloor:t,graphics:i}),this.buildingCenter=t.userData.center,this.coordinateTransform.setBuildingCenter(t.userData.center),this.currentBuildGround=t.userData.rangeGraphic,this.context.switchFloor(t,e),this.initialFloorCamera(),this.triggerHooks(lt.SWITCH_FLOOR_AFTER,{curFloor:t,graphics:i})}initialFloorCamera(){this.context.cameraBound.setEnable(!1),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,0),this.context.setPolarAngle(this.config.control.defaultPolar,0),this.context.fitCameraToGround(this.config.defaultPadding,0);let t=this.context.camera.zoom;this.context.control.minZoom=t,this.context.control.maxZoom=t*this.config.control.maxZoomScale,this.type==="3d"&&this.context.fitCameraToGround(this.config.defaultPadding,0,!1),this.basicZoom=this.context.camera.zoom,this.context.control.addEventListener("change",this.onControlChange),this.onControlChange(),this.context.cameraBound.setEnable(!0),this.context.cameraBound.changePrevCamera()}addModel(t,e){if(t.options.geometry.type==="polygon"){var i;let s=(i=this.context.currentFloor)==null?void 0:i.addModel(w({},e,{position:t.getPosition().setZ(.1),id:t.options.id}));if(s){let{facilityAngle:o=0,facilityXScale:n=1,facilityYScale:r=1}=t.options.userData;s.rotateZ((180-o)/180*Math.PI),s.scale.set(n,r,1)}}}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.getGraphics())||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.options.centerCoords,s=t.getCenter(),o=(i==null?void 0:i[0])||s.x,n=(i==null?void 0:i[1])||s.y;return console.log(o,n,i,s),this.context.currentFloor.addPoi(w({},e,{position:{x:o,y:n,z:s.z+t.options.height/2}}))}return null}createPoi2ByPosition(t,e){if(this.context.currentFloor){let i=this.mercatorToWorld([t.x,t.y]),s=new et(this.context,w({},e,{position:{x:i.x,y:i.y,z:t.z}}));return this.context.currentFloor.poiLayer2.pushPoi(s),s}return null}translateElementToCenter(t,e,i,s){e===void 0&&(e=500),i===void 0&&(i=0),s===void 0&&(s=0);let o=t.getPosition().clone(),{context:{camera:n}}=this;if(n.updateMatrix(),s){let r=new Ro;r.setFromMatrixColumn(n.matrix,1),r.normalize(),r.multiplyScalar(s/n.zoom),o.add(r)}if(i){let r=new Ro;r.setFromMatrixColumn(n.matrix,0),r.normalize(),r.multiplyScalar(i/n.zoom),o.add(r)}return this.context.setCameraPosition(o,e)}translateElementToCenterX(t,e){return g(this,null,function*(){return e===void 0&&(e=500),Mt(new Promise(i=>{let s=this.context.control.target.clone(),o=t.getPosition();this.timer.requestAnimationFrame(()=>{let{clientSize:{width:n,height:r},camera:h}=this.context,l=L(o,h,n,r).x-n/2,p=new Ro;p.setFromMatrixColumn(this.context.camera.matrix,0),p.normalize(),p.multiplyScalar(l/this.context.camera.zoom),s.add(p),this.context.setCameraPosition(s,e).then(i)})}),e+500)})}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:s}=this.container;return L(e,this.context.camera,i,s)}changeMapType(t,e){return e===void 0&&(e=500),this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(1.1,e)}resetView(t){return g(this,null,function*(){t===void 0&&(t=300);let e=t/3;yield this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,e),yield this.context.setPolarAngle(this.config.control.defaultPolar,e),yield this.context.fitCameraToGround(this.config.defaultPadding,e,!1)})}reduceMap(t,e){t===void 0&&(t=.5),e===void 0&&(e=500);let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t,e){t===void 0&&(t=.5),e===void 0&&(e=500);let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){if(window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp),this.config.resizeObserver.enable){let t=new ResizeObserver(this.debounceResize);t.observe(this.container),this.observe=t}}unRegistryEvent(){var t;this.context.control.removeEventListener("change",this.onControlChange),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp),(t=this.observe)==null||t.disconnect(),this.observe=null}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t,e){t===void 0&&(t=.1),e===void 0&&(e=500);let i=this.context.control.getAzimuthalAngle();return this.context.setAzimuthalAngle(i+t,e)}showCollisionBox(){this.context.debugCollisionBox=!0,this.context.forceUpdate()}hideCollisionBox(){this.context.debugCollisionBox=!1,this.context.forceUpdate()}measureDistance(){return g(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new qi(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",s=>{let{distance:o}=s;t(o)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new $i(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",s=>{let{area:o}=s;t(o)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}fitCameraByPois(t,e,i){return g(this,null,function*(){if(e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500),!t.length)return;let s=new ku;return t.forEach(o=>{let{position:n}=o;s.expandByPoint(n)}),this.context.fitCameraToBox(s,e,i,!1)})}fitCameraByPoiNodeIds(t,e,i){return g(this,null,function*(){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500);let s=t.map(o=>this.getPoiById(o)).filter(o=>!!o);if(s.length)return this.fitCameraByPois(s,e,i)})}getGraphicByNodeId(t){var e,i;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||((i=this.context.currentFloor)==null?void 0:i.parkingSpaceLayer.graphicMap.get(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=gi(this.currentBuildGround.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.coords=JSON.parse(JSON.stringify(t.geometry.cds)),t.geometry.coords.map(s=>{Array.isArray(s)&&s.forEach(o=>{o[0]-=i[0],o[1]-=i[1]})});else{let[s,o]=t.geometry.cds;t.geometry.coords=[s-i[0],o-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}mercatorToWorld(t){return this.coordinateTransform.mercatorToWorld(t)}worldToMercator(t){return this.coordinateTransform.worldToMercator(t)}removePoiById(t){var e,i;(e=this.context.currentFloor)==null||e.poiLayer.removePoiById(t),(i=this.context.currentFloor)==null||i.poiLayer2.removePoiById(t)}getPoiById(t){var e;let i=this.context.collisionSystem.objects;return((e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t))||i.find(s=>s.options.id===t)}getPois(){var t;return[...(((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]).filter(e=>!e.options.built_in),...this.context.collisionSystem.objects||[]]}clearPoi(){this.context.currentFloor&&this.context.currentFloor.poiLayer.clear()}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){if(!this.disposed){this.disposed=!0;try{this.loader&&(this.loader.dispose(),this.loader=null),this.unRegistryEvent(),this.timer.dispose(),this.plugins.forEach(t=>t.dispose()),this.plugins=[],this.context.dispose(),this.context=null,this.container=null}finally{if(--a.liveCount<=0){a.liveCount=0;try{[()=>X.dispose(),()=>ht.dispose(),()=>vt.dispose(),()=>pt.dispose(),()=>C.dispose(),()=>kt.dispose(),()=>Do.Dispose==null?void 0:Do.Dispose.call(Do)].forEach(i=>{try{i()}catch(s){console.warn("[BMap.dispose] \u91CA\u653E\u5171\u4EAB\u8D44\u6E90\u5931\u8D25",s)}})}finally{Xn()}}this.debounceResize=null}}}constructor(t,e={}){super(),this.container=t,this.disposed=!1,this.polarKeys=[],this.azimuthalKeys=[],this.prevCameraZoom=1,this.type="2d",this.currentBuildGround=null,this.observe=null,this.coordinateTransform=new Si([0,0]),this.timer=new K,this.plugins=[],this.loader=null,this.onControlChange=()=>{let{camera:{zoom:i}}=this.context;i!==this.prevCameraZoom&&(this.dispatchEvent({type:"zoom-change",basicZoom:this.basicZoom,cameraZoom:this.context.camera.zoom}),this.prevCameraZoom=i)},this.onKeydown=i=>{this.polarKeys.includes(i.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(i.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)},this.onKeyUp=i=>{if(this.polarKeys.includes(i.code)){let s=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=s,this.context.control.minPolarAngle=s}if(this.azimuthalKeys.includes(i.code)){let s=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=s,this.context.control.minAzimuthAngle=s}},this.resize=()=>{this.context.cameraBound.setEnable(!1),this.context.onWindowResize();let i=this.context.control.getAzimuthalAngle(),s=this.context.camera.zoom;this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0);let o=this.context.getFitCameraToGroundZoom(this.config.defaultPadding,0)||1;this.context.camera.zoom=s,this.context.control.minZoom=o,this.context.control.maxZoom=o*this.config.control.maxZoomScale,this.basicZoom=s,this.context.control.addEventListener("change",this.onControlChange),this.context.setAzimuthalAngle(i,0),this.context.cameraBound.setEnable(!0)},this.config=Xr(e),this.context=new ws(t,this),a.liveCount+=1,Kn(),this.debounceResize=Du(this.resize,this.config.resizeObserver.debounceTime),this.registryEvent()}};Oo.liveCount=0;var pT=function(a){return a.HALF="half",a.POWER="power",a.MECHANICAL="mechanical",a.NORMAL="normal",a.VIP="vip",a.GSADV="gsadv",a}({});import"core-js/modules/web.dom-collections.iterator.js";var N=class extends st{dispose(){let t=this.bmap.plugins.findIndex(e=>e===this);t!==-1&&this.bmap.plugins.splice(t,1),this.bmap=null,super.dispose()}constructor(t){super(),this.bmap=t,this.bmap.use(this)}};var ea=class extends N{fetchEquipment(){return g(this,null,function*(){let{apiDomain:t,apiPath:{equipmentList:e},apiInfo:i}=this.bmap.config,s=""+t+e;yield fetch(s,i).then(o=>o.json()).then(o=>o.data).then(o=>{this.equipmentList=o,this.equipmentMap=new Map(o.map(n=>[n.equipment_id,n]))}),this.dispatchEvent({type:"change-equipment-list",data:this.equipmentList}),this.bmap.context.currentFloor&&this.changeGraphicToEquipment(this.bmap.context.currentFloor.graphicLayer.children)})}getGraphicEquipment(t){return t.userData.data.info.userData.equipment}changeGraphicToEquipment(t){t.filter(e=>{let i=this.getGraphicEquipment(e);return i&&this.equipmentMap.has(i)}).forEach(e=>{let i=this.equipmentMap.get(this.getGraphicEquipment(e)),s=this.bmap.createGraphicPoi(e,{icon:i==null?void 0:i.equipment_icon,built_in:!0,icon_size:[14,14]});s&&(s.userData.data=i,s.userData.type="equipment")})}dispose(){var t;this.bmap.removeEventListener(lt.SWITCH_FLOOR_AFTER,this.onSwitchFloor),Array.from(((t=this.bmap.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]).forEach(e=>{if(e.userData.type==="equipment"){var i;(i=this.bmap.context.currentFloor)==null||i.poiLayer.removePoi(e)}}),super.dispose()}constructor(t){super(t),this.equipmentList=[],this.equipmentMap=new Map,this.onSwitchFloor=e=>{let{data:{graphics:i}}=e;this.equipmentList.length&&this.changeGraphicToEquipment(i)},this.fetchEquipment(),this.bmap.addEventListener(lt.SWITCH_FLOOR_AFTER,this.onSwitchFloor)}};import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.promise.finally.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Mesh as Wu,Object3D as Uu,TextureLoader as Hu,Color as Nu,Vector2 as Io,Vector3 as Zu,NormalBlending as ju,RepeatWrapping as Vu}from"three";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.typed-array.uint16-array.js";import{BufferGeometry as Ru,Matrix4 as sa,Vector3 as fe,Ray as Ou,Sphere as Fu,LineSegments as Iu,BufferAttribute as se,ShaderChunk as _t,ShaderMaterial as oa,UniformsLib as Gu,Color as Bu,Vector2 as ia}from"three";var Pt=class extends Ru{constructor(){super(),this.isMeshLine=!0,this.type="MeshLine",this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this._points=[],this._geom=null,this.widthCallback=null,this.matrixWorld=new sa,Object.defineProperties(this,{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(t){this.setGeometry(t,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(t){this.setPoints(t,this.widthCallback)}}})}};Pt.prototype.setMatrixWorld=function(a){this.matrixWorld=a};Pt.prototype.setGeometry=function(a,t){this._geometry=a,this.setPoints(a.getAttribute("position").array,t)};Pt.prototype.setPoints=function(a,t){if(!(a instanceof Float32Array)&&!(a instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=a,this.widthCallback=t,this.positions=[],this.counters=[],a.length&&a[0]instanceof fe)for(var e=0;e<a.length;e++){var i=a[e],s=e/a.length;this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(s),this.counters.push(s)}else for(var e=0;e<a.length;e+=3){var s=e/a.length;this.positions.push(a[e],a[e+1],a[e+2]),this.positions.push(a[e],a[e+1],a[e+2]),this.counters.push(s),this.counters.push(s)}this.process()};function zu(a,t){var e=new sa,i=new Ou,s=new Fu,o=new fe,n=this.geometry;if(n.boundingSphere||n.computeBoundingSphere(),s.copy(n.boundingSphere),s.applyMatrix4(this.matrixWorld),a.ray.intersectSphere(s,o)!==!1){e.copy(this.matrixWorld).invert(),i.copy(a.ray).applyMatrix4(e);var r=new fe,h=new fe,c=new fe,l=this instanceof Iu?2:1,p=n.index,d=n.attributes;if(p!==null)for(var u=p.array,f=d.position.array,x=d.width.array,m=0,y=u.length-1;m<y;m+=l){var _=u[m],P=u[m+1];r.fromArray(f,_*3),h.fromArray(f,P*3);var S=x[Math.floor(m/3)]!==void 0?x[Math.floor(m/3)]:1,E=a.params.Line.threshold+this.material.lineWidth*S/2,k=E*E,b=i.distanceSqToSegment(r,h,o,c);if(!(b>k)){o.applyMatrix4(this.matrixWorld);var G=a.ray.origin.distanceTo(o);G<a.near||G>a.far||(t.push({distance:G,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}),m=y)}}}}Pt.prototype.raycast=zu;Pt.prototype.compareV3=function(a,t){var e=a*6,i=t*6;return this.positions[e]===this.positions[i]&&this.positions[e+1]===this.positions[i+1]&&this.positions[e+2]===this.positions[i+2]};Pt.prototype.copyV3=function(a){var t=a*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]};Pt.prototype.getDistance=function(a){let t=0;for(let e=0;e<a;e++){let i=6*e,s=new fe(this.positions[i],this.positions[i+1],this.positions[i+2]),o=new fe(this.positions[i+6],this.positions[i+7],this.positions[i+8]),n=s.distanceTo(o);t+=n}return t};Pt.prototype.process=function(){var a=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var t;let e=this.getDistance(a-1);var i;this.compareV3(0,a-1)?i=this.copyV3(a-2):i=this.copyV3(0),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);for(var s=0;s<a;s++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(s/(a-1)):t=1,this.width.push(t),this.width.push(t),s===0)this.uvs.push(0,0),this.uvs.push(0,1);else if(s===a-1)this.uvs.push(1,0),this.uvs.push(1,1);else{let n=this.getDistance(s)/e;this.uvs.push(n,0),this.uvs.push(n,1)}if(s<a-1){i=this.copyV3(s),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);var o=s*2;this.indices_array.push(o,o+1,o+2),this.indices_array.push(o+2,o+1,o+3)}s>0&&(i=this.copyV3(s),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]))}this.compareV3(a-1,0)?i=this.copyV3(1):i=this.copyV3(a-1),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new se(new Float32Array(this.positions),3),previous:new se(new Float32Array(this.previous),3),next:new se(new Float32Array(this.next),3),side:new se(new Float32Array(this.side),1),width:new se(new Float32Array(this.width),1),uv:new se(new Float32Array(this.uvs),2),index:new se(new Uint16Array(this.indices_array),1),counters:new se(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function Fo(a,t,e,i,s){var o;if(a=a.subarray||a.slice?a:a.buffer,e=e.subarray||e.slice?e:e.buffer,a=t?a.subarray?a.subarray(t,s&&t+s):a.slice(t,s&&t+s):a,e.set)e.set(a,i);else for(o=0;o<a.length;o++)e[o+i]=a[o];return e}Pt.prototype.advance=function(a){var t=this._attributes.position.array,e=this._attributes.previous.array,i=this._attributes.next.array,s=t.length;Fo(t,0,e,0,s),Fo(t,6,t,0,s-6),t[s-6]=a.x,t[s-5]=a.y,t[s-4]=a.z,t[s-3]=a.x,t[s-2]=a.y,t[s-1]=a.z,Fo(t,6,i,0,s-6),i[s-6]=a.x,i[s-5]=a.y,i[s-4]=a.z,i[s-3]=a.x,i[s-2]=a.y,i[s-1]=a.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0};_t.meshline_vert=["",_t.logdepthbuf_pars_vertex,_t.fog_pars_vertex,"","attribute vec3 previous;","attribute vec3 next;","attribute float side;","attribute float width;","attribute float counters;","","uniform vec2 resolution;","uniform float lineWidth;","uniform vec3 color;","uniform float opacity;","uniform float sizeAttenuation;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","vec2 fix( vec4 i, float aspect ) {",""," vec2 res = i.xy / i.w;"," res.x *= aspect;"," vCounters = counters;"," return res;","","}","","void main() {",""," float aspect = resolution.x / resolution.y;",""," vColor = vec4( color, opacity );"," vUV = uv;",""," mat4 m = projectionMatrix * modelViewMatrix;"," vec4 finalPosition = m * vec4( position, 1.0 );"," vec4 prevPos = m * vec4( previous, 1.0 );"," vec4 nextPos = m * vec4( next, 1.0 );",""," vec2 currentP = fix( finalPosition, aspect );"," vec2 prevP = fix( prevPos, aspect );"," vec2 nextP = fix( nextPos, aspect );",""," float w = lineWidth * width;",""," vec2 dir;"," if( nextP == currentP ) dir = normalize( currentP - prevP );"," else if( prevP == currentP ) dir = normalize( nextP - currentP );"," else {"," vec2 dir1 = normalize( currentP - prevP );"," vec2 dir2 = normalize( nextP - currentP );"," dir = normalize( dir1 + dir2 );",""," vec2 perp = vec2( -dir1.y, dir1.x );"," vec2 miter = vec2( -dir.y, dir.x );"," //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );",""," }",""," //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;"," vec4 normal = vec4( -dir.y, dir.x, 0., 1. );"," normal.xy *= .5 * w;"," normal *= projectionMatrix;"," if( sizeAttenuation == 0. ) {"," normal.xy *= finalPosition.w;"," normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;"," }",""," finalPosition.xy += normal.xy * side;",""," gl_Position = finalPosition;","",_t.logdepthbuf_vertex,_t.fog_vertex&&" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",_t.fog_vertex,"}"].join(`
624
+ `,i=-1/0,s=this.geometry.getAttribute("position");if(s)for(let n=0;n<s.count;n++){let r=s.getZ(n);r>i&&(i=r)}let o=new Wp({uniforms:{maxZ:{value:i},uColor:{value:new Rr(this.options[0].fillColor).convertLinearToSRGB()},uColor2:{value:new Rr(Xt(this.options[0].fillColor)).convertLinearToSRGB()},uOpacity:{value:this.options[0].fillOpacity}},vertexShader:t,fragmentShader:e,transparent:!0});this.material=o}initLineMaterial(){let t=C.createLineMaterial({color:this.options[0].strokeColor,opacity:this.options[0].strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Gp(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options[0].height+this.options[0].deltaHeight;return this.options.map(i=>{let{coords:s}=i.geometry;for(let o=0;o<s.length;o++){let n=s[o];for(let r=0;r<n.length;r++){let h=n[r],c=r+1===n.length?n[0]:n[r+1];t.push(new Dr(h[0],h[1],e)),t.push(new Dr(c[0],c[1],e))}}}),t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new Bp().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new zp(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}dispose(){var t,e;this.geometry?(this.geometry.dispose(),this._listeners={}):this.addEventListener("init-geometry",()=>{var i;(i=this.geometry)==null||i.dispose(),this._listeners={}}),(t=this.material)==null||t.dispose(),(e=this.line)==null||e.geometry.dispose(),this.clear()}constructor(t,e,i){super(),this.context=t,this.mergedElement=i,this.options=[],i?(this.options=[i],this.initMergedElement()):(this.options=e.map(s=>w({},At,s)),this.init())}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.string.trim.js";import{Matrix4 as So,Mesh as Hp,Object3D as Np}from"three";import{mergeGeometries as Zp}from"three/examples/jsm/utils/BufferGeometryUtils.js";var jp={airHeight:0,deltaHeight:0,height:0,geometry:{cds:[],type:"polygon",coords:[],curveCpt:[],curveIndex:[]},texts:[],fillColor:"#ffffff",fillOpacity:0,strokeColor:"#ffffff",strokeOpacity:0,secondHeight:0,secondRotate:0,center_x:0,center_y:0},Vp={fontFamily:"sans-serif",fontWeight:"normal",fontSize:64},Kp=2048,Xp=1,es=class extends Np{init(){return g(this,null,function*(){let t=yield Promise.all(this.options.map(n=>g(this,null,function*(){let r=yield X.ensureText(n.texts[0],Vp);return{options:n,atlas:r,layout:wi(n.texts[0],r.charMap,r.spec,Kp)}}))),e=[],i=[];for(let n of t){let{options:r,layout:h,atlas:c}=n,l=Ue(h,{pivotX:.5,pivotY:.5,normalizeBottom:h.inkBottom,normalizeHeight:h.inkHeight});if(!l.length)continue;let p=new So().makeTranslation(r.center_x,r.center_y,r.airHeight+r.deltaHeight+r.height).multiply(new So().makeRotationZ(r.secondRotate)).multiply(new So().makeScale(r.secondHeight,r.secondHeight,1));for(let d of l)d.geometry.applyMatrix4(p),d.geometry.computeBoundingSphere(),e.push(d.geometry),i.push(this.createMaterial(n,c.pages[d.page].texture))}if(!e.length)return;let s=Zp(e,!0);e.forEach(n=>n.dispose());let o=new Hp(s,i);o.frustumCulled=!1,o.renderOrder=9e5,this.mesh=o,this.position.z+=.04,this.add(o)})}createMaterial(t,e){let{options:i,atlas:s}=t,o=typeof window!="undefined"&&window.devicePixelRatio||1;return Li({atlas:e,fillColor:i.fillColor,fillOpacity:i.fillOpacity,outlineColor:i.strokeColor,outlineOpacity:i.strokeOpacity,outlineWidth:Xp*o,edge:1-s.spec.cutoff,depthWrite:!1})}get materials(){var t;let e=(t=this.mesh)==null?void 0:t.material;return e?Array.isArray(e)?e:[e]:[]}setOpacity(t){this.materials.forEach(e=>{e.uniforms.uOpacity.value=t})}dispose(){var t;(t=this.mesh)==null||t.geometry.dispose(),this.materials.forEach(e=>e.dispose()),this.clear()}constructor(t,e){super(),this.context=t,this.options=e.map(i=>w({},jp,i)).filter(i=>i.texts[0].trim()),this.options.length&&this.init()}};import{Object3D as Yp}from"three";import{Line2 as qp}from"three/examples/jsm/lines/Line2.js";import{LineGeometry as $p}from"three/examples/jsm/lines/LineGeometry.js";import{LineMaterial as Jp}from"three/examples/jsm/lines/LineMaterial.js";var ii=class extends Yp{registryEvent(){this.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.context.removeEventListener("resize",this.onResize)}setPosition(t,e){this.lineGeometry.setPositions([t.x,t.y,t.z,e.x,e.y,e.z]),this.line||this.createLine()}createLine(){this.line=new qp(this.lineGeometry,this.lineMaterial),this.line.renderOrder=100003,this.add(this.line)}dispose(){var t;this.unRegistryEvent(),this.line&&F(this.line),this.lineGeometry=null,this.lineMaterial=null,this.clear(),(t=this.line)==null||t.clear(),this.line=null}constructor(t,e,i){super(),this.context=t,this.lineGeometry=new $p,this.lineMaterial=new Jp({color:0,transparent:!0,depthTest:!1,linewidth:2}),this.line=null,this.onResize=()=>{let{width:s,height:o}=this.context.clientSize;this.lineMaterial.resolution.set(s,o)},this.onResize(),this.registryEvent(),e&&i&&this.setPosition(e,i)}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Qp,InstancedMesh as td,Object3D as ed,Vector3 as id}from"three";import{Matrix4 as si}from"three";var Zi=class extends ed{loadModel(){return g(this,null,function*(){let t=yield pt.loadModel(this.options[0].url);t.scene.updateMatrixWorld(!0);let e=t.scene.matrixWorld.clone().invert();t.scene.traverse(h=>{if(h.isMesh){let c=e.clone().multiply(h.matrixWorld),l=h.material;this.subMeshes.push({geometry:h.geometry,material:h.material,initialMatrix:c}),Array.isArray(l)?l.forEach(p=>{p.transparent=!0,this.materialOriginParams.set(p,{opacity:p.opacity})}):(l.transparent=!0,this.materialOriginParams.set(l,{opacity:l.opacity}))}});let i=this.subMeshes.map(h=>{let{geometry:c,material:l}=h;return new td(c,l,this.options.length)});t.scene.rotation.set(Math.PI/2,0,0);let o=new Qp().setFromObject(t.scene).getSize(new id),n=Math.max(o.x,o.y);this.options.map(h=>{let c=new si,l=h.width/n;return c.multiply(new si().makeTranslation(h.center_x,h.center_y,h.airHeight+h.deltaHeight)).multiply(new si().makeScale(l,l,l)).multiply(new si().makeRotationZ(h.rotate)).multiply(new si().makeRotationX(Math.PI/2)),h.url==="https://robot-vr-public.cdn.bcebos.com/ai-map-resource/757/1865371442288267264/smzsdrc.glb"&&console.log(h,c),c}).forEach((h,c)=>{i.forEach((l,p)=>{let d=h.clone().multiply(this.subMeshes[p].initialMatrix);l.setMatrixAt(c,d)})}),i.forEach(h=>{h.instanceMatrix.needsUpdate=!0,this.meshSetMaterial(h),this.add(h)})})}meshSetMaterial(t){t.isMesh&&(t.frustumCulled=!1,t.castShadow=!0,Array.isArray(t.material)?t.material.map(e=>{e.emissiveIntensity*=.95}):(t.material.emissiveIntensity*=.95,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map))}setOpacity(t,e){e===void 0&&(e=!1),this.subMeshes.forEach(i=>{let{material:s}=i;if(Array.isArray(s))s.forEach(o=>{if(e)o.opacity=t;else{let n=this.materialOriginParams.get(o)||{opacity:1};t>n.opacity?o.opacity=n.opacity:o.opacity=t}o.needsUpdate=!0});else{let o=this.materialOriginParams.get(s)||{opacity:1};t>o.opacity?s.opacity=o.opacity:s.opacity=t,s.needsUpdate=!0}}),this.children.forEach(i=>{i.instanceMatrix.needsUpdate=!0})}dispose(){this.children.forEach(t=>t.dispose()),F(this),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.subMeshes=[],this.materialOriginParams=new Map,this.loadModel()}};import{Object3D as sd,Mesh as od,LineSegments as nd,ObjectLoader as rd}from"three";var ei=class extends sd{init(){return g(this,null,function*(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.deltaHeight+this.options.airHeight,this.options.lineGeometry&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder()),this.options.mergedGeometry=null,this.options.lineGeometry=null})}initGeometry(){return this.loader.parseGeometries([this.options.mergedGeometry])[this.options.mergedGeometry.uuid]}initMaterial(){this.material=C.GetMergeAttributeGraphicMaterial()}initLineMaterial(){return this.lineMaterial=C.GetMergeAttributeGraphicLineMaterial()}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new od(this.geometry,this.material),this.add(this.mesh)}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.loader.parseGeometries([this.options.lineGeometry]);this.lineGeometry=t[this.options.lineGeometry.uuid]}createBorder(){this.line&&this.remove(this.line);let t=new nd(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}dispose(){var t;this.geometry&&this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.loader=new rd,this.options=w({},At,e),this.init()}};import{Mesh as ad,Object3D as hd,ObjectLoader as cd}from"three";var is=class extends hd{initGeometry(){return g(this,null,function*(){let t=new cd().parseGeometries([this.options.mergedGeometry]);this.geometry=t[this.options.mergedGeometry.uuid]})}init(){return g(this,null,function*(){var t;yield this.initGeometry();let e=new ad(this.geometry,ut.GetMergeAttributeWallMaterial());this.add(e);let i=(t=this.geometry)==null?void 0:t.getAttribute("opacity");i&&(this.originOpacities=Array.from(i.array))})}setOpacity(t,e){e===void 0&&(e=!1);var i;let s=(i=this.geometry)==null?void 0:i.getAttribute("opacity");if(s){for(let n=0;n<s.count;n++)if(e)s.setX(n,t);else{var o;s.setX(n,Math.min(t,(o=this.originOpacities[n])!=null?o:1))}s.needsUpdate=!0}}dispose(){var t;(t=this.geometry)==null||t.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.originOpacities=[],this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import{Float32BufferAttribute as ld,FrontSide as pd,InstancedBufferAttribute as dd,InstancedMesh as ud,MeshBasicMaterial as md,Object3D as fd,Shape as gd,ShapeGeometry as yd,Vector2 as ss}from"three";var pe=class extends fd{init(){return g(this,null,function*(){let t=this.options.iconUrl,e=yield ht.getTextureByUrl(t),i=new md({map:e,transparent:!0,alphaTest:.2,side:pd}),s=new ud(this.geometry,i,this.options.mergedMatrixes.size);s.instanceMatrix=new dd(new Float32Array(this.options.mergedMatrixes.array),16),this.add(s),this.mesh=s,this.position.z+=.004})}setOpacity(t){this.mesh&&(this.mesh.material.opacity=t,this.mesh.material.needsUpdate=!0,this.mesh.instanceMatrix.needsUpdate=!0)}dispose(){var t;this.mesh&&F(this.mesh),(t=this.mesh)==null||t.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.geometry=new yd(new gd([new ss(-.5,-.5),new ss(-.5,.5),new ss(.5,.5),new ss(.5,-.5)])),this.options=w({},Eo,e);let i=new ld([0,0,0,1,1,1,1,0],2);this.geometry.setAttribute("uv",i),this.init()}};import"core-js/modules/es.array.push.js";import{Mesh as vd,Object3D as xd,ObjectLoader as wd,Vector2 as Fr}from"three";import{LineSegments2 as Ir}from"three/examples/jsm/lines/LineSegments2.js";import{LineSegmentsGeometry as Gr}from"three/examples/jsm/lines/LineSegmentsGeometry.js";var os=class extends xd{initGeometry(){return g(this,null,function*(){let t=this.loader.parseGeometries([this.options.mergedGeometry]);this.geometry=t[this.options.mergedGeometry.uuid]})}initMaterial(){let t=C.createMeshBasicMaterial({color:"#ffffff",opacity:1,vertexColors:!0});return this.material=t,t}initDoubleLine(){if(this.options.dashedLineGeometry){let t=C.createLine2MaterialMap({color:"#ffffff",width:.2,dashed:!0,resolution:new Fr(this.context.clientSize.width,this.context.clientSize.height),vertexColors:!0});t.transparent=!0,t.needsUpdate=!0;let e=new Gr;e.setPositions(this.options.dashedLineGeometry.positions),e.setColors(this.options.dashedLineGeometry.colors);let i=new Ir(e,t);i.computeLineDistances(),i.position.z+=.01,this.add(i),this.doubleLines.push(i)}if(this.options.lineGeometry){let t=C.createLine2MaterialMap({color:"#ffffff",width:.2,dashed:!1,resolution:new Fr(this.context.clientSize.width,this.context.clientSize.height),vertexColors:!0}),e=new Gr;e.setPositions(this.options.lineGeometry.positions),e.setColors(this.options.lineGeometry.colors);let i=new Ir(e,t);i.position.z+=.01,this.add(i),this.doubleLines.push(i)}}init(){return g(this,null,function*(){yield this.initGeometry(),this.initMaterial();let t=new vd(this.geometry,this.material);this.add(t),this.initDoubleLine(),this.position.z+=.02})}setOpacity(t){this.material.opacity=t,this.material.needsUpdate=!0,this.doubleLines.forEach(e=>{e.material.opacity=t,e.material.needsUpdate=!0})}dispose(){var t,e;(t=this.geometry)==null||t.dispose(),(e=this.lineGeometry)==null||e.dispose(),this.doubleLines.map(i=>i.geometry.dispose()),this.clear()}constructor(t,e){super(),this.context=t,this.options=e,this.doubleLines=[],this.loader=new wd,this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/web.dom-collections.iterator.js";import{Object3D as _d,Vector3 as Co,BufferGeometry as Pd,LineSegments as bd,Color as Br,BoxGeometry as Md,InstancedMesh as Ed,Matrix4 as Sd,Quaternion as Cd,InstancedBufferAttribute as zr,BufferAttribute as Wr}from"three";var Qe=class extends _d{setColorByIndex(t,e){this.mesh&&(this.mesh.setColorAt(t,new Br(e).convertLinearToSRGB()),this.mesh.instanceColor.needsUpdate=!0)}init(){return g(this,null,function*(){this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options[0].deltaHeight+this.options[0].airHeight,this.options[0].strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())})}initMaterial(){this.material=C.GetInstancedGraphicMaterial()}initLineMaterial(){let t=C.GetMergeAttributeGraphicLineMaterial();this.lineMaterial=t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Ed(this.geometry,this.material,this.options.length);let t=new zr(new Float32Array(this.options.length),1),e=new zr(new Float32Array(this.options.length),1);this.options.forEach((i,s)=>{let o=i.geometry.coords[0],[n,r,h]=o.slice(0,3),c=Math.sqrt((r[0]-n[0])**2+(r[1]-n[1])**2),l=Math.sqrt((h[0]-r[0])**2+(h[1]-r[1])**2),p=[c,l],d=Math.max(...p),u=Math.min(...p),f;d===c?f=[r[0]-n[0],r[1]-n[1]]:f=[h[0]-r[0],h[1]-r[1]];let[x,m]=f,y=Math.atan2(m,x)-Math.PI/2,_=new Sd().compose(new Co(i.center_coord_x,i.center_coord_y,(i.deltaHeight||0)+i.airHeight+i.height/2),new Cd().setFromAxisAngle(new Co(0,0,1),y),new Co(u,d,i.height));this.mesh.setMatrixAt(s,_),this.mesh.setColorAt(s,new Br(i.fillColor).convertLinearToSRGB());var P;t.array[s]=(P=i.fillOpacity)!=null?P:1;var S;e.array[s]=((S=i.deltaHeight)!=null?S:0)+i.airHeight+i.height}),this.originOpacity=[...t.array],this.geometry.setAttribute("opacity",t),this.geometry.setAttribute("maxZ",e),this.add(this.mesh),this.mesh.instanceMatrix.needsUpdate=!0}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let{points:t,colors:e,opacities:i}=no(this.options),s=new Pd().setFromPoints(t);s.setAttribute("color",new Wr(new Float32Array(e),3)),s.setAttribute("opacity",new Wr(new Float32Array(i),1)),this.lineOriginOpacity=[...i],this.lineGeometry=s}createBorder(){this.line&&this.remove(this.line);let t=new bd(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}setOpacity(t,e){e===void 0&&(e=!1);let i=this.geometry.getAttribute("opacity");for(let n=0;n<i.count;n++)if(e)i.array[n]=t;else{var s;i.array[n]=Math.min(t,(s=this.originOpacity[n])!=null?s:1)}if(i.needsUpdate=!0,this.lineGeometry){let n=this.lineGeometry.getAttribute("opacity");for(let r=0;r<n.count;r++)if(e)n.array[r]=t;else{var o;n.array[r]=Math.min(t,(o=this.lineOriginOpacity[r])!=null?o:1)}n.needsUpdate=!0}}dispose(){var t,e;this.geometry.dispose(),(t=this.mesh)==null||t.dispose(),(e=this.line)==null||e.geometry.dispose(),this.clear()}constructor(t,e){super(),this.context=t,this.geometry=new Md(1,1,1),this.options=[],this.originOpacity=[],this.lineOriginOpacity=[],this.options=e.map(i=>w({},At,i)),this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/web.dom-collections.iterator.js";import{Object3D as Td,Color as Ld,BoxGeometry as kd,InstancedMesh as Ad,InstancedBufferAttribute as To}from"three";var Se=class extends Td{init(){return g(this,null,function*(){this.initMaterial(),this.initMesh()})}initMaterial(){this.material=C.GetInstancedGraphicMaterial()}initMesh(){if(this.mesh&&this.remove(this.mesh),!this.elements)return;this.mesh=new Ad(this.geometry,this.material,this.elements.size);let t=new To(new Float32Array(this.elements.opacities),1),e=new To(new Float32Array(this.elements.maxZs),1);this.originOpacities=[...t.array],this.geometry.setAttribute("opacity",t),this.geometry.setAttribute("maxZ",e),this.mesh.instanceMatrix.set(this.elements.matrixes),this.mesh.instanceColor=new To(new Float32Array(this.elements.colors),3),this.add(this.mesh),this.mesh.instanceMatrix.needsUpdate=!0}setColorByIndex(t,e){this.mesh&&(this.mesh.setColorAt(t,new Ld(e).convertLinearToSRGB()),this.mesh.instanceColor.needsUpdate=!0)}setOpacityByIndex(t,e){if(this.mesh){let i=this.geometry.getAttribute("opacity");i.setX(t,e),i.needsUpdate=!0}}setMatrixByIndex(t,e){this.mesh&&(this.mesh.setMatrixAt(t,e),this.mesh.instanceMatrix.needsUpdate=!0)}setMaxZByIndex(t,e){if(this.mesh){let i=this.geometry.getAttribute("maxZ");i.setX(t,e),i.needsUpdate=!0}}setColorById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setColorByIndex(i,e)}setOpacityById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setOpacityByIndex(i,e)}setMatrixById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setMatrixByIndex(i,e)}setMaxZById(t,e){if(!this.elements)return;let i=this.elements.ids.findIndex(s=>s===t);i!==-1&&this.setMaxZByIndex(i,e)}setOpacity(t,e){if(e===void 0&&(e=!1),!this.geometry)return;let i=this.geometry.getAttribute("opacity");for(let o=0;o<i.count;o++)if(e)i.array[o]=t;else{var s;i.array[o]=Math.min(t,(s=this.originOpacities[o])!=null?s:1)}i.needsUpdate=!0}pushElements(t){this.elements?(this.elements.size+=t.size,this.elements.colors=[...this.elements.colors,...t.colors],this.elements.matrixes=[...this.elements.matrixes,...t.matrixes],this.elements.opacities=[...this.elements.opacities,...t.opacities],this.elements.maxZs=[...this.elements.maxZs,...t.maxZs],this.elements.ids=[...this.elements.ids,...t.ids],this.originOpacities=[...this.originOpacities,...t.opacities]):this.elements=t,this.refesh()}removeInstanceById(t){if(this.elements){if(this.mesh){let e=this.elements.ids.indexOf(t);e!==-1&&(this.elements.size--,this.elements.colors.splice(e*3,3),this.elements.matrixes.splice(e*16,16),this.elements.opacities.splice(e,1),this.elements.maxZs.splice(e,1),this.elements.ids.splice(e,1),this.originOpacities.splice(e,1))}this.refesh()}}refesh(){this.mesh&&(this.mesh.dispose(),this.remove(this.mesh)),this.init()}dispose(){var t;this.material=null,this.originOpacities.length=0,this.geometry.dispose(),(t=this.mesh)==null||t.dispose(),this.clear()}constructor(t,e){super(),this.geometry=new kd(1,1,1),this.material=null,this.elements=null,this.originOpacities=[],this.elements=e,this.init()}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/web.dom-collections.iterator.js";import{Object3D as Dd,BoxGeometry as Rd,InstancedMesh as Od,InstancedBufferAttribute as ns}from"three";var rs=class extends Dd{init(){return g(this,null,function*(){this.initMaterial(),this.initMesh()})}initMaterial(){this.material=C.GetInstancedWallMaterial()}initMesh(){if(this.mesh&&this.remove(this.mesh),!this.elements)return;this.mesh=new Od(this.geometry,this.material,this.elements.size);let t=new ns(new Float32Array(this.elements.opacities),1),e=new ns(new Float32Array(this.elements.maxZs),1),i=new ns(new Float32Array(this.elements.minZs),1);this.originOpacities=[...t.array],this.geometry.setAttribute("opacity",t),this.geometry.setAttribute("maxZ",e),this.geometry.setAttribute("minZ",i),this.mesh.instanceMatrix.set(this.elements.matrixes),this.mesh.instanceColor=new ns(new Float32Array(this.elements.colors),3),this.add(this.mesh),this.mesh.instanceMatrix.needsUpdate=!0}setOpacityByIndex(t,e){if(this.mesh){let i=this.geometry.getAttribute("opacity");i.setX(t,e),i.needsUpdate=!0}}setOpacity(t,e){e===void 0&&(e=!1),this.elements&&this.elements.opacities.forEach((i,s)=>{let o=e?t:Math.min(t,this.originOpacities[s]);this.setOpacityByIndex(s,o)})}dispose(){this.mesh&&(this.mesh.dispose(),this.remove(this.mesh)),this.material=null,this.geometry&&this.geometry.dispose(),this.elements=null}constructor(t,e){super(),this.geometry=new Rd(1,1,1),this.material=null,this.elements=null,this.originOpacities=[],this.elements=e,this.init()}};import{Object3D as Fd,LineSegments as Id,ObjectLoader as Gd}from"three";var de=class extends Fd{init(){return g(this,null,function*(){this.initLineGeometry(),this.initLineMaterial(),this.createBorder(),this.options=null})}initLineMaterial(){return this.lineMaterial=C.GetMergeAttributeGraphicLineMaterial()}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.loader.parseGeometries([this.options]);this.lineGeometry=t[this.options.uuid]}createBorder(){this.line&&this.remove(this.line);let t=new Id(this.lineGeometry,this.lineMaterial);return t.position.z=.01,this.line=t,this.add(t),t}dispose(){var t;(t=this.lineGeometry)==null||t.dispose(),this.lineMaterial=null,this.clear()}constructor(t,e){super(),this.context=t,this.lineMaterial=null,this.loader=new Gd,this.options=w({},At,e),this.init()}};import{Frustum as Bd}from"three";var as=class extends dt{setEnable(t){super.setEnable(t),j(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=L(this.startPoint,e,i,s),n=L(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof Y&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=L(d,s,o,n);return te(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=L(h,s,o,n),p=L(c,s,o,n);return!(!te(l,e,i)||!te(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new Bd,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);j(this.rect,n.x,n.y,r,h)}else j(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=gt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var hs=class extends zd{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.context.config.enableBoxSelect||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}constructor(t){super(),this.context=t,this._list=new Set,this.downPoint=null,this.downTime=0,this.isMultipleSelect=!1,this.onPointerDown=e=>{Date.now()-this.downTime<200||(this.downPoint={x:e.offsetX,y:e.offsetY},this.downTime=Date.now())},this.onPointerUp=e=>{if(!this.downPoint)return;let{offsetX:i,offsetY:s}=e,{x:o,y:n}=this.downPoint;if(Math.sqrt((o-i)**2+(n-s)**2)>3)return;let{graphics:r}=this.context.getGraphicsByDeviceXy(i,s),h=new Set(r.map(l=>l.options.id));this.context.getPoisByDeviceXy(i,s).forEach(l=>{if(!h.has(l.options.id)){var p;let d=((p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id))||null;d&&d.options.geometry.type==="point"&&(r.push(d),h.add(l.options.id))}}),(re?e.metaKey:e.ctrlKey)||this._list.clear(),r.forEach(l=>this._list.add(l)),this.selectEnd(),this.downPoint=null},this.onPointerOut=e=>{this.disableBoxSelection()},this.onKeyDown=e=>{ve(e.key)&&this.enableBoxSelection()},this.onKeyUp=e=>{ve(e.key)&&this.disableBoxSelection()},this.onBoxSelected=e=>{let{list:i}=e;this._list.clear(),i.forEach(s=>{this._list.add(s)}),this.selectEnd()},this.boxSelection=new as(t),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as Wd,Vector2 as Ud}from"three";var cs=class extends Wd{handleHoverGraphicsChange(t){t===void 0&&(t=this.curGraphics),this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel),document.body.addEventListener("pointermove",this.onBodyPointerMove)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel),document.body.removeEventListener("pointermove",this.onBodyPointerMove)}dispose(){this.unRegistryEvent(),this.timer.dispose()}constructor(t){super(),this.context=t,this.curGraphics=new Set,this.timer=new K,this.graphicTimerMap=new Map,this.onPointerMove=e=>{let{graphics:i,pois:s,e:o}=e,n=s.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!i.length&&!n.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:r}=this.context.config.hover,h=new Set;if(n.length){let l,p=1e4;n.forEach(d=>{let u=s.find(f=>f.options.id===d.options.id);if(u instanceof ce){let{x:f,y:x}=u.clientPos,m=Math.sqrt((f-o.offsetX)**2+(x-o.offsetY)**2);m<p&&(p=m,l=d)}else if(u instanceof et){let{x:f,y:x}=u.box.getCenter(new Ud),m=Math.sqrt((f-o.offsetX)**2+(x-o.offsetY)**2);m<p&&(p=m,l=d)}}),h.add(l)}h.size||i.forEach(l=>h.add(l)),h.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},r);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{h.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let c=this.curGraphics.size;this.curGraphics.forEach(l=>{h.has(l)||this.curGraphics.delete(l)}),c!==this.curGraphics.size&&this.handleHoverGraphicsChange()},this.onPointerLevel=()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()},this.onBodyPointerMove=e=>{if(this.curGraphics.size){let i=this.context.container.getBoundingClientRect();(e.clientX<i.left||e.clientX>i.right||e.clientY<i.top||e.clientY>i.bottom)&&this.onPointerLevel()}},this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Box3 as Hd,Vector3 as Wt}from"three";import{polygon as Ur,intersect as Nd}from"@turf/turf";var ls=class{updateBox(){this.box.setFromObject(this.context.scene)}setEnable(t){this.enable=t,t?this.registryEvent():this.unRegistryEvent()}changePrevCamera(){this.prevCamera={position:this.context.camera.position.clone(),zoom:this.context.camera.zoom,target:this.context.control.target.clone()}}backToPrevCamera(){this.setEnable(!1),this.context.camera.position.copy(this.prevCamera.position),this.context.camera.zoom=this.prevCamera.zoom,this.context.control.target.copy(this.prevCamera.target),this.context.control.update(),this.setEnable(!0)}registryEvent(){this.context.addEventListener("control-change",this.onCameraChange)}unRegistryEvent(){this.context.removeEventListener("control-change",this.onCameraChange)}getCurFloorScreenPosition(){if(!this.context.scene.children.filter(f=>f instanceof zt).length)return null;let e=this.box,{camera:i,clientSize:{width:s,height:o}}=this.context,{min:n,max:r}=e,c=[new Wt(n.x,n.y,n.z),new Wt(r.x,n.y,n.z),new Wt(n.x,r.y,n.z),new Wt(r.x,r.y,n.z),new Wt(n.x,n.y,r.z),new Wt(r.x,n.y,r.z),new Wt(n.x,r.y,r.z),new Wt(r.x,r.y,r.z)].map(f=>L(f,i,s,o)),l=Math.min(...c.map(f=>f.x)),p=Math.max(...c.map(f=>f.x)),d=Math.min(...c.map(f=>f.y)),u=Math.max(...c.map(f=>f.y));return{left:l,right:p,top:d,bottom:u}}checkDistanceToScreenEdge(t){let{left:e,right:i,top:s,bottom:o}=t,{width:n,height:r}=this.context.clientSize,[h,c,l,p]=this.context.config.cameraBound.padding,d=Ur([[[e,s],[i,s],[i,o],[e,o],[e,s]]]),u=Ur([[[p,h],[n-c,h],[n-c,r-l],[p,r-l],[p,h]]]);try{return Nd(d,u)!==null}catch(f){return console.warn("\u8BA1\u7B97\u4EA4\u96C6\u51FA\u9519:",f),!1}}dispose(){this.unRegistryEvent()}constructor(t){this.context=t,this.prevCamera={position:new Wt,zoom:1,target:new Wt},this.enable=!0,this.box=new Hd,this.onCameraChange=()=>{let e=this.getCurFloorScreenPosition();if(e){let{left:i,right:s,top:o,bottom:n}=e;if([i,s,o,n].every(h=>!h))return;this.checkDistanceToScreenEdge({left:i,right:s,top:o,bottom:n})?this.changePrevCamera():this.backToPrevCamera()}},this.registryEvent(),this.changePrevCamera()}};import"core-js/modules/es.promise.finally.js";import{Vector3 as Zr}from"three";import{Tween as ms,Group as Yd}from"@tweenjs/tween.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{EventDispatcher as Zd,MOUSE as Ae,Quaternion as Hr,Spherical as ps,TOUCH as De,Vector2 as wt,Vector3 as St,Plane as jd,Ray as Vd,MathUtils as Kd}from"three";var ds=new Vd,Nr=new jd,Xd=Math.cos(70*Kd.DEG2RAD),us=class extends Zd{dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerUp),this.domElement.removeEventListener("wheel",this.onMouseWheel),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this.onKeyDown),this._domElementKeyEvents=null)}constructor(t,e){super(),this.rotateLineStart=new wt,this.rotateLineEnd=new wt,this.spherical=new ps,this.sphericalDelta=new ps,this.object=t,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new St,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.screenSpacePanning=!1,this.mouseButtons={LEFT:Ae.PAN,MIDDLE:Ae.DOLLY,RIGHT:Ae.ROTATE},this.touches={ONE:De.PAN,TWO:De.DOLLY_ROTATE},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(v){v.addEventListener("keydown",this.onKeyDown),this._domElementKeyEvents=v},this.stopListenToKeyEvents=function(){var v;(v=this._domElementKeyEvents)==null||v.removeEventListener("keydown",this.onKeyDown),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent({type:"change"}),i.update(),o=s.NONE},this.update=function(){let v=new St,b=new Hr().setFromUnitVectors(t.up,new St(0,1,0)),U=b.clone().invert(),tt=new St,xt=new Hr,It=new St,Ct=2*Math.PI;return function(Ge){Ge===void 0&&(Ge=null);let Ht=i.object.position;v.copy(Ht).sub(i.target),v.applyQuaternion(b),r.setFromVector3(v),i.autoRotate&&o===s.NONE&&$(R(Ge)),i.enableDamping?(r.theta+=h.theta*i.dampingFactor,r.phi+=h.phi*i.dampingFactor):(r.theta+=h.theta,r.phi+=h.phi);let Nt=i.minAzimuthAngle,Zt=i.maxAzimuthAngle;isFinite(Nt)&&isFinite(Zt)&&(Nt<-Math.PI?Nt+=Ct:Nt>Math.PI&&(Nt-=Ct),Zt<-Math.PI?Zt+=Ct:Zt>Math.PI&&(Zt-=Ct),Nt<=Zt?r.theta=Math.max(Nt,Math.min(Zt,r.theta)):r.theta=r.theta>(Nt+Zt)/2?Math.max(Nt,r.theta):Math.min(Zt,r.theta)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi)),r.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(l,i.dampingFactor):i.target.add(l),i.zoomToCursor&&k||i.object.isOrthographicCamera?r.radius=D(r.radius):r.radius=D(r.radius*c),v.setFromSpherical(r),v.applyQuaternion(U),Ht.copy(i.target).add(v),i.object.lookAt(i.target),i.enableDamping===!0?(h.theta*=1-i.dampingFactor,h.phi*=1-i.dampingFactor,l.multiplyScalar(1-i.dampingFactor)):(h.set(0,0,0),l.set(0,0,0));let pi=!1;if(i.zoomToCursor&&k){let Be=null;if(i.object.isPerspectiveCamera){let ze=v.length();Be=D(ze*c);let di=ze-Be;i.object.position.addScaledVector(S,di),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){let ze=new St(E.x,E.y,0);ze.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),pi=!0;let di=new St(E.x,E.y,0);di.unproject(i.object),i.object.position.sub(di).add(ze),i.object.updateMatrixWorld(),Be=v.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;Be!==null&&(i.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(Be).add(i.object.position):(ds.origin.copy(i.object.position),ds.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(ds.direction))<Xd?t.lookAt(i.target):(Nr.setFromNormalAndCoplanarPoint(i.object.up,i.target),ds.intersectPlane(Nr,i.target))))}else i.object.isOrthographicCamera&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),pi=!0);return c=1,k=!1,pi||tt.distanceToSquared(i.object.position)>n||8*(1-xt.dot(i.object.quaternion))>n||It.distanceToSquared(i.target)>0?(i.dispatchEvent({type:"change"}),tt.copy(i.object.position),xt.copy(i.object.quaternion),It.copy(i.target),pi=!1,!0):!1}}();let i=this,s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},o=s.NONE,n=1e-6,r=new ps,h=new ps,c=1,l=new St,p=new wt,d=new wt,u=new wt,f=new wt,x=new wt,m=new wt,y=new wt,_=new wt,P=new wt,S=new St,E=new wt,k=!1,M=[],G={};function R(v){return v!==null?2*Math.PI/60*i.autoRotateSpeed*v:2*Math.PI/60/60*i.autoRotateSpeed}function O(){return Math.pow(.95,i.zoomSpeed)}function $(v){h.theta-=v}function nt(v){h.phi-=v}let W=function(){let v=new St;return function(U,tt){v.setFromMatrixColumn(tt,0),v.multiplyScalar(-U),l.add(v)}}(),J=function(){let v=new St;return function(U,tt){i.screenSpacePanning===!0?v.setFromMatrixColumn(tt,1):(v.setFromMatrixColumn(tt,0),v.crossVectors(i.object.up,v)),v.multiplyScalar(U),l.add(v)}}(),z=function(){let v=new St;return function(U,tt){let xt=i.domElement;if(i.object.isPerspectiveCamera){let It=i.object.position;v.copy(It).sub(i.target);let Ct=v.length();Ct*=Math.tan(i.object.fov/2*Math.PI/180),W(2*U*Ct/xt.clientHeight,i.object.matrix),J(2*tt*Ct/xt.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(W(U*(i.object.right-i.object.left)/i.object.zoom/xt.clientWidth,i.object.matrix),J(tt*(i.object.top-i.object.bottom)/i.object.zoom/xt.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function mt(v){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c/=v:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function Q(v){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c*=v:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function I(v){if(!i.zoomToCursor)return;k=!0;let b=i.domElement.getBoundingClientRect(),U=v.clientX-b.left,tt=v.clientY-b.top,xt=b.width,It=b.height;E.x=U/xt*2-1,E.y=-(tt/It)*2+1,S.set(E.x,E.y,1).unproject(i.object).sub(i.object.position).normalize()}function D(v){return Math.max(i.minDistance,Math.min(i.maxDistance,v))}function V(v){p.set(v.clientX,v.clientY)}function Z(v){I(v),y.set(v.clientX,v.clientY)}function Ot(v){f.set(v.clientX,v.clientY)}function Ft(v){d.set(v.clientX,v.clientY),u.subVectors(d,p).multiplyScalar(i.rotateSpeed);let b=i.domElement;$(2*Math.PI*u.x/b.clientHeight),nt(2*Math.PI*u.y/b.clientHeight),p.copy(d),i.update()}function Qt(v){_.set(v.clientX,v.clientY),P.subVectors(_,y),P.y>0?mt(O()):P.y<0&&Q(O()),y.copy(_),i.update()}function Ut(v){x.set(v.clientX,v.clientY),m.subVectors(x,f).multiplyScalar(i.panSpeed),z(m.x,m.y),f.copy(x),i.update()}function Ie(v){I(v),v.deltaY<0?Q(O()):v.deltaY>0&&mt(O()),i.update()}function Oa(v){let b=!1;switch(v.code){case i.keys.UP:v.ctrlKey||v.metaKey||v.shiftKey?nt(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(0,i.keyPanSpeed),b=!0;break;case i.keys.BOTTOM:v.ctrlKey||v.metaKey||v.shiftKey?nt(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(0,-i.keyPanSpeed),b=!0;break;case i.keys.LEFT:v.ctrlKey||v.metaKey||v.shiftKey?$(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(i.keyPanSpeed,0),b=!0;break;case i.keys.RIGHT:v.ctrlKey||v.metaKey||v.shiftKey?$(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):z(-i.keyPanSpeed,0),b=!0;break}b&&(v.preventDefault(),i.update())}function Xo(){if(M.length===1)p.set(M[0].pageX,M[0].pageY);else{let v=(M[0].pageX-M[0].pageY)/(M[1].pageX-M[1].pageY),b=M[0].pageY-v*M[0].pageX;i.rotateLineStart.set(v,b);let U=.5*(M[0].pageX+M[1].pageX),tt=.5*(M[0].pageY+M[1].pageY);p.set(U,tt)}}function Yo(){if(M.length===1)f.set(M[0].pageX,M[0].pageY);else{let v=.5*(M[0].pageX+M[1].pageX),b=.5*(M[0].pageY+M[1].pageY);f.set(v,b)}}function qo(){let v=M[0].pageX-M[1].pageX,b=M[0].pageY-M[1].pageY,U=Math.sqrt(v*v+b*b);y.set(0,U)}function Fa(){i.enableZoom&&qo(),i.enablePan&&Yo()}function Ia(){i.enableZoom&&qo(),i.enableRotate&&Xo()}function $o(v){if(M.length==1)d.set(v.pageX,v.pageY);else{let U=js(v),tt=.5*(v.pageX+U.x),xt=.5*(v.pageY+U.y);d.set(tt,xt);let It=(v.pageY-U.y)/(v.pageX-U.x),Ct=U.y-It*U.x;if(i.rotateLineEnd.set(It,Ct),Number.isFinite(i.rotateLineEnd.x)&&Number.isFinite(i.rotateLineStart.x)){let Vs=(i.rotateLineStart.y-i.rotateLineEnd.y)/(i.rotateLineEnd.x-i.rotateLineStart.x),Ge=It*Vs+Ct;if(Number.isFinite(Vs)&&Number.isFinite(Ge)){let Ht=Math.atan(i.rotateLineEnd.x)-Math.atan(i.rotateLineStart.x);Math.PI-Math.abs(Ht)<.5&&(Ht=-Math.sign(Ht)*(Math.PI-Math.abs(Ht))),Math.abs(Ht)<.1&&(h.theta+=Ht)}}i.rotateLineStart.copy(i.rotateLineEnd)}u.subVectors(d,p).multiplyScalar(i.rotateSpeed);let b=i.domElement;nt(2*Math.PI*u.y/b.clientHeight),p.copy(d)}function Jo(v){if(M.length===1)x.set(v.pageX,v.pageY);else{let b=js(v),U=.5*(v.pageX+b.x),tt=.5*(v.pageY+b.y);x.set(U,tt)}m.subVectors(x,f).multiplyScalar(i.panSpeed),z(m.x,m.y),f.copy(x)}function Qo(v){let b=js(v),U=v.pageX-b.x,tt=v.pageY-b.y,xt=Math.sqrt(U*U+tt*tt);_.set(0,xt),P.set(0,Math.pow(_.y/y.y,i.zoomSpeed)),mt(P.y),y.copy(_)}function Ga(v){i.enableZoom&&Qo(v),i.enablePan&&Jo(v)}function Ba(v){i.enableZoom&&Qo(v),i.enableRotate&&$o(v)}this.onPointerDown=function(b){i.enabled!==!1&&(M.length===0&&(i.domElement.setPointerCapture(b.pointerId),i.domElement.addEventListener("pointermove",i.onPointerMove),i.domElement.addEventListener("pointerup",i.onPointerUp)),Na(b),b.pointerType==="touch"?Ua(b):za(b))},this.onPointerMove=function(b){i.enabled!==!1&&(b.pointerType==="touch"?Ha(b):Wa(b))},this.onPointerUp=function(b){Za(b),M.length===0&&(i.domElement.releasePointerCapture(b.pointerId),i.domElement.removeEventListener("pointermove",i.onPointerMove),i.domElement.removeEventListener("pointerup",i.onPointerUp)),i.dispatchEvent({type:"end"}),o=s.NONE};function za(v){let b;switch(v.button){case 0:b=i.mouseButtons.LEFT;break;case 1:b=i.mouseButtons.MIDDLE;break;case 2:b=i.mouseButtons.RIGHT;break;default:b=-1}switch(b){case Ae.DOLLY:if(i.enableZoom===!1)return;Z(v),o=s.DOLLY;break;case Ae.ROTATE:if(v.ctrlKey||v.metaKey||v.shiftKey){if(i.enablePan===!1)return;Ot(v),o=s.PAN}else{if(i.enableRotate===!1)return;V(v),o=s.ROTATE}break;case Ae.PAN:if(v.ctrlKey||v.metaKey||v.shiftKey){if(i.enableRotate===!1)return;V(v),o=s.ROTATE}else{if(i.enablePan===!1)return;Ot(v),o=s.PAN}break;default:o=s.NONE}o!==s.NONE&&i.dispatchEvent({type:"start"})}function Wa(v){switch(o){case s.ROTATE:if(i.enableRotate===!1)return;Ft(v);break;case s.DOLLY:if(i.enableZoom===!1)return;Qt(v);break;case s.PAN:if(i.enablePan===!1)return;Ut(v);break}}this.onMouseWheel=function(b){i.enabled===!1||i.enableZoom===!1||o!==s.NONE||(b.preventDefault(),i.dispatchEvent({type:"start"}),Ie(b),i.dispatchEvent({type:"end"}))},this.onKeyDown=function(b){i.enabled===!1||i.enablePan===!1||Oa(b)};function Ua(v){switch(tn(v),M.length){case 1:switch(i.touches.ONE){case De.ROTATE:if(i.enableRotate===!1)return;Xo(),o=s.TOUCH_ROTATE;break;case De.PAN:if(i.enablePan===!1)return;Yo(),o=s.TOUCH_PAN;break;default:o=s.NONE}break;case 2:switch(i.touches.TWO){case De.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Fa(),o=s.TOUCH_DOLLY_PAN;break;case De.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ia(),o=s.TOUCH_DOLLY_ROTATE;break;default:o=s.NONE}break;default:o=s.NONE}o!==s.NONE&&i.dispatchEvent({type:"start"})}function Ha(v){switch(tn(v),o){case s.TOUCH_ROTATE:if(i.enableRotate===!1)return;$o(v),i.update();break;case s.TOUCH_PAN:if(i.enablePan===!1)return;Jo(v),i.update();break;case s.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Ga(v),i.update();break;case s.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Ba(v),i.update();break;default:o=s.NONE}}this.onContextMenu=function(b){i.enabled!==!1&&b.preventDefault()};function Na(v){M.push(v)}function Za(v){delete G[v.pointerId];for(let b=0;b<M.length;b++)if(M[b].pointerId==v.pointerId){M.splice(b,1);return}}function tn(v){let b=G[v.pointerId];b===void 0&&(b=new wt,G[v.pointerId]=b),b.set(v.pageX,v.pageY)}function js(v){let b=v.pointerId===M[0].pointerId?M[1]:M[0];return G[b.pointerId]}i.domElement.addEventListener("contextmenu",this.onContextMenu),i.domElement.addEventListener("pointerdown",this.onPointerDown),i.domElement.addEventListener("pointercancel",this.onPointerUp),i.domElement.addEventListener("wheel",this.onMouseWheel,{passive:!1}),this.update()}};var fs=class extends us{registryEvent(){this.addEventListener("change",this.onChange),this.context.addEventListener("update",this.tweenUpdate)}unRegistryEvent(){this.removeEventListener("change",this.onChange),this.context.removeEventListener("update",this.tweenUpdate)}setPolarAngle(t,e){e===void 0&&(e=!1);let{maxPolarAngle:i,minPolarAngle:s}=this,o=i===s;(e||t<=i&&t>=s)&&(this.maxPolarAngle=t,this.minPolarAngle=t,this.update()),o||(this.maxPolarAngle=i,this.minPolarAngle=s)}setPolarAngleByDuration(t,e,i){return g(this,null,function*(){return e===void 0&&(e=!1),i===void 0&&(i=500),i<=0?this.setPolarAngle(t,e):bt(new Promise(s=>{let o={polar:this.getPolarAngle()},n={polar:t},r=new ms(o,this.tweenGroup).to(n,i).onUpdate(()=>{this.setPolarAngle(o.polar,e)}).onComplete(()=>{this.enabled=!0,this.tweenGroup.remove(r),s(!0)}).onStart(()=>{this.enabled=!1}).start()}),i+500)})}setAzimuthalAngle(t,e){let{maxAzimuthAngle:i,minAzimuthAngle:s}=this,o=i===s;(e||t<=i&&t>=s)&&(this.maxAzimuthAngle=t,this.minAzimuthAngle=t,this.update()),o||(this.maxAzimuthAngle=i,this.minAzimuthAngle=s)}setAzimuthalAngleDuration(t,e,i){return e===void 0&&(e=!1),i===void 0&&(i=500),i<=0?this.setAzimuthalAngle(t,e):bt(new Promise(s=>{let o={azimuthal:this.getAzimuthalAngle()},n={azimuthal:t},r=new ms(o,this.tweenGroup).to(n,i).onUpdate(()=>{this.setAzimuthalAngle(o.azimuthal,e)}).onComplete(()=>{this.enabled=!0,this.tweenGroup.remove(r),s(!0)}).onStart(()=>{this.enabled=!1}).start()}),i+500)}getCameraLookAt(){return new Zr().subVectors(this.target,this.camera.position)}setCameraPositionByTarget(t,e){return g(this,null,function*(){let i=this.target.clone(),s=this.getCameraLookAt();if(!e){this.camera.position.copy(t.clone().sub(s)),this.target.copy(t.clone()),this.update();return}return bt(new Promise(o=>{let n=new ms(i,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(i.clone().sub(s)),this.target.copy(i.clone()),this.update()}).onComplete(()=>{this.tweenGroup.remove(n),this.enabled=!0,o(!0)}).onStart(()=>{this.enabled=!1}).start()}),e+500)})}setZoom(t,e,i){i===void 0&&(i=!1);let{minZoom:s,maxZoom:o}=this;(i||t>=s&&t<=o)&&(this.camera.position.copy(e.clone().sub(this.getCameraLookAt())),this.target.copy(e),this.camera.zoom=t,this.update())}setZoomByDuration(t,e,i,s){return g(this,null,function*(){i===void 0&&(i=!1),s===void 0&&(s=500);let o={zoom:this.camera.zoom,target:this.target.clone()};if(!(t===this.camera.zoom&&!i))return s?bt(new Promise(n=>{let r=new ms(o,this.tweenGroup).to({zoom:t,target:e},s).onUpdate(()=>{this.setZoom(o.zoom,o.target,i)}).onComplete(()=>{this.tweenGroup.remove(r),this.enabled=!0,n(!0)}).onStart(()=>{this.enabled=!1}).start()}),s+500).finally(()=>{this.enabled=!0}):this.setZoom(t,e,i)})}setTargetByOffset(t,e){if(e===void 0&&(e=this.target.clone()),this.camera.updateMatrix(),t){let i=new Zr;i.setFromMatrixColumn(this.camera.matrix,1),i.normalize(),i.multiplyScalar(t/this.camera.zoom),e.add(i)}this.setCameraPositionByTarget(e,0)}clearTween(){this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll()}dispose(){super.dispose(),this.unRegistryEvent(),this.clearTween()}constructor(t,e,i){super(e,i),this.context=t,this.camera=e,this.domElement=i,this.prevCameraZoom=1,this.tweenGroup=new Yd,this.offsetY=0,this.onChange=()=>{let s=this.camera.zoom;s!==this.prevCameraZoom&&(this.prevCameraZoom=s,this.dispatchEvent({type:"change-zoom",zoom:s}))},this.tweenUpdate=()=>{this.tweenGroup.update()},this.enableDamping=!1,this.zoomSpeed=.5,this.prevCameraZoom=e.zoom,this.registryEvent()}};import{EventDispatcher as qd,WebGLRenderer as $d,LinearToneMapping as Jd}from"three";var gs=class extends $d{setCameraAndScene(t,e){this.scene=t,this.camera=e}autoRender(){if(this.scene&&this.camera&&this.enable&&(this.event.dispatchEvent({type:"update"}),this.render(this.scene,this.camera)),this.context.config.renderAnimation==="requestAnimationFrame")this.timer.requestAnimationFrame(()=>{this.autoRender()});else{let t=1e3/this.context.config.fps;this.timer.setTimeout(()=>{this.autoRender()},t)}}pauseRender(){this.enable=!1}continueRender(){this.enable=!0}addEventListener(t,e){this.event.addEventListener(t,e)}removeEventListener(t,e){this.event.removeEventListener(t,e)}constructor(t,e){var i,s;super(w({antialias:!0,alpha:!0},e)),this.context=t,this.event=new qd,this.enable=!0,this.timer=new K,this.onContextLost=r=>{r.preventDefault(),this.enable=!1,console.warn("[crc-bmap] WebGL context lost")},this.onContextRestored=()=>{this.enable=!0,console.warn("[crc-bmap] WebGL context restored"),this.context.forceUpdate()},this.autoClear=!0;let o=((s=this.context.config)==null||(i=s.renderer)==null?void 0:i.maxPixelRatio)||2;this.setPixelRatio(Math.min(window.devicePixelRatio||1,o)),this.toneMapping=Jd,this.toneMappingExposure=1,this.domElement.addEventListener("webglcontextlost",this.onContextLost,!1),this.domElement.addEventListener("webglcontextrestored",this.onContextRestored,!1);let n=this.dispose;this.dispose=()=>{var r,h;this.timer.dispose(),this.enable=!1,(r=this.domElement)==null||r.removeEventListener("webglcontextlost",this.onContextLost,!1),(h=this.domElement)==null||h.removeEventListener("webglcontextrestored",this.onContextRestored,!1),n.call(this),this.domElement.remove(),this.domElement=null,this.shadowMap=null,this.info.programs&&(this.info.programs.length=0),this.info=null}}};import{Scene as eu}from"three";import{PMREMGenerator as Qd}from"three";import{RoomEnvironment as tu}from"three/examples/jsm/environments/RoomEnvironment.js";function jr(a,t){t===void 0&&(t=.85);let e=new Qd(a);return e.compileEquirectangularShader(),e.fromScene(new tu).texture}var ys=class extends eu{dispose(){var t;(t=this.environment)==null||t.dispose(),this.environment=null,F(this),this.clear()}constructor(t){super(),this.environment=jr(t)}};import{OrthographicCamera as iu}from"three";var vs=class extends iu{constructor(t,e){super(-t/2,t/2,e/2,-e/2,-1e4,5e4),this.up.set(0,0,1),this.position.set(0,0,100),this.lookAt(0,0,0)}};import{polygon as Kr}from"@turf/turf";import"core-js/modules/es.array.unshift.js";import"core-js/modules/es.array.push.js";import{Vector3 as su}from"three";var xs=class{registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-change",this.onControlChange),this.context.addEventListener("resize",this.onControlChange)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-change",this.onControlChange),this.context.removeEventListener("resize",this.onControlChange)}changePoiLevelOrCollisionEnable(t){let e=this.objects.findIndex(i=>i===t);e!==-1&&(this.objects.splice(e,1),this.addObject(t))}addObject(t){if(!this.objects.includes(t)){if(this.needsUpdate=!0,!t.options.collision_enable){this.objects.unshift(t);return}if(t.options.level===0){this.objects.push(t);return}for(let e=0;e<this.objects.length;e++){let i=this.objects[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.objects.splice(e,0,t);return}}this.objects.push(t)}}removeObject(t){let e=this.objects.indexOf(t);e!==-1&&(this.objects.splice(e,1),this.needsUpdate=!0)}removeObjects(t){this.objects=this.objects.filter(e=>!t.includes(e)),this.needsUpdate=!0}getObjectById(t){return this.objects.find(e=>e.options.id===t)||null}validShowParkingSpace(t){t===void 0&&(t=60);let{clientSize:{width:e,height:i},control:s,camera:o}=this.context,n=Math.min(e/t,i/t,s.maxZoom-1);return o.zoom>=n}detectCollisions(){if(!this.needsUpdate)return;let t=[],{camera:e}=this.context;e.updateMatrixWorld();let i=l=>l<=1&&l>=-1,s=e.projectionMatrix.clone();s.multiply(e.matrixWorldInverse);let o=e.zoom/this.context.basicZoom,n=25/30,r=Math.min(25,Math.max(1,o*n)),h=this.validShowParkingSpace();this.objects.filter(l=>{if(l.visible){if(!(r<=l.options.maxWeight&&r>=l.options.minWeight)||!h&&l.userData.type==="parkingSpace")return l.parentSetVisible(!1),!1;let p=l.getLabelOriginWorldPosition(new su);return p.applyMatrix4(s),l.screenPosition=p,i(p.x)&&i(p.y)&&i(p.z)?!0:(l.parentSetVisible(!1),!1)}return!1}).forEach((l,p)=>{let d=l.getBox(l.screenPosition);if(d===null)return;if(p===0||!l.options.collision_enable){t.push(d),l.parentSetVisible(!0);return}let u=t.some(f=>f.intersectsBox(d));l.parentSetVisible(!u),u||t.push(d)}),this.needsUpdate=!1}markForUpdate(){this.needsUpdate=!0}clear(){this.objects=[],this.needsUpdate=!0}dispose(){this.objects=[],this.unRegistryEvent()}constructor(t){this.context=t,this.objects=[],this.needsUpdate=!0,this.onUpdate=()=>{this.detectCollisions()},this.onControlChange=()=>{this.needsUpdate=!0},this.registryEvent()}};var ws=class extends ou{get config(){return this.bmap.config}get center(){return this.bmap.buildingCenter}setRange(t){this.range=Kr([t])}resizeClientSize(){let{x:t,y:e,width:i,height:s}=this.container.getBoundingClientRect();this.clientSize={width:i||this.container.clientWidth,height:s||this.container.clientHeight,x:t,y:e}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=new vs(t,e),this.renderer.setSize(t,e),this.renderer.setCameraAndScene(this.scene,this.camera),this.renderer.autoRender(),this.control=new fs(this,this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",this.onControlChange),this.control.addEventListener("change-zoom",this.onControlChangeZoom),this.renderer.addEventListener("update",this.onRendererUpdate),this.cameraBound=new ls(this)}getRatio(t,e){t===void 0&&(t=new Dt(0,0,0)),e===void 0&&(e=new Dt(100,0,0));let{clientWidth:i,clientHeight:s}=this.container,o=L(t,this.camera,i,s),n=L(e,this.camera,i,s);return Math.ceil(Math.sqrt((n.x-o.x)**2+(n.y-o.y)**2))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof hu&&(e.color=new au(t))})}switchFloor(t,e){e===void 0&&(e=!0),console.log("switchFloor",e),this.currentFloor&&(this.scene.remove(this.currentFloor),e?this.currentFloor.dispose():this.currentFloor.onRemoveFromScene()),this.currentFloor=t,this.setRange(t.userData.range||[]),this.scene.add(t),t.onAddToScene("scene"),this.cameraBound.updateBox()}getGraphicsByDeviceXy(t,e){var i,s;let o=new me;o.x=t/this.clientSize.width*2-1,o.y=e/this.clientSize.height*-2+1;let n=new Vr;n.setFromCamera(o,this.camera),n.ray.origin.sub(n.ray.direction.clone().multiplyScalar(100));let r=(i=this.currentFloor)==null?void 0:i.graphicLayer.getGraphicByRaycaster(n),h=(s=this.currentFloor)==null?void 0:s.parkingSpaceLayer.getParkingSpaceByRaycaster(n);return r!=null&&r.graphics.length&&(h!=null&&h.graphics.length)?r.distance<h.distance?r:h:r!=null&&r.graphics.length?r:h!=null&&h.graphics.length?h:{graphics:[],position:null}}getPoisByDeviceXy(t,e){var i,s;let o=(i=this.currentFloor)==null?void 0:i.poiLayer.getPoiByDeviceXy(t,e),n=(s=this.currentFloor)==null?void 0:s.poiLayer2.getPoiByDeviceXy(t,e);return(o||[]).concat(n||[])}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.container.addEventListener("pointercancel",this.onPointerleave),this.container.addEventListener("pointerout",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.container.removeEventListener("pointercancel",this.onPointerleave),this.container.removeEventListener("pointerout",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange),this.control.removeEventListener("change",this.onControlChange),this.control.removeEventListener("change-zoom",this.onControlChangeZoom),this.renderer.removeEventListener("update",this.onRendererUpdate)}setPolarAngle(t,e){return e===void 0&&(e=500),this.control.setPolarAngleByDuration(t,!0,e)}setAzimuthalAngle(t,e){return e===void 0&&(e=500),this.control.setAzimuthalAngleDuration(t,!0,e)}getCameraLookAt(){return this.control.getCameraLookAt()}setZoom(t,e,i){return i===void 0&&(i=500),this.control.setZoomByDuration(t,e,!0,i)}getFitCameraToObjectZoom(t,e,i){return e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=!0),this.getFitCameraToBoxZoom(new ru().setFromObject(t),e,i)}getFitCameraToBoxZoom(t,e,i){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=!0);let[s,o,n,r]=e,{clientSize:{width:h,height:c}}=this,l=this.control.getPolarAngle();i&&this.setPolarAngle(0,0),this.camera.updateMatrixWorld(),this.camera.updateProjectionMatrix();let{max:p,min:d}=t,u=new Dt(d.x,p.y,p.z),f=new Dt(p.x,p.y,p.z),x=new Dt(p.x,d.y,d.z),m=new Dt(d.x,d.y,d.z),y=L(u,this.camera,h,c),_=L(f,this.camera,h,c),P=L(m,this.camera,h,c),S=L(x,this.camera,h,c),k=new nu().setFromPoints([new me(y.x,y.y),new me(_.x,_.y),new me(P.x,P.y),new me(S.x,S.y)]).getSize(new me),M=(h-o-r)/k.x,G=(c-s-n)/k.y,R=Math.min(M,G),O=new Dt((p.x+d.x)/2,(p.y+d.y)/2,(p.z+d.z)/2),$=R*this.camera.zoom,nt=this.camera.clone();nt.zoom=$,nt.updateMatrix();let W=(o-r)/2,J=(s-n)/2;if(W){let z=new Dt;z.setFromMatrixColumn(nt.matrix,0),z.normalize(),z.multiplyScalar(W/$),O.add(z)}if(J){let z=new Dt;z.setFromMatrixColumn(nt.matrix,1),z.normalize(),z.multiplyScalar(J/$),O.add(z)}return i&&this.setPolarAngle(l,0),{zoom:R*this.camera.zoom,center:O}}fitCameraToObject(t,e,i,s){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500),s===void 0&&(s=!0);let{zoom:o,center:n}=this.getFitCameraToObjectZoom(t,e,s);return this.setZoom(o,n,i)}fitCameraToBox(t,e,i,s){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500),s===void 0&&(s=!0);let{zoom:o,center:n}=this.getFitCameraToBoxZoom(t,e,s);return this.setZoom(o,n,i)}getFitCameraToGroundZoom(t,e,i){if(t===void 0&&(t=[20,20,20,20]),e===void 0&&(e=500),i===void 0&&(i=!0),this.currentFloor&&this.currentFloor.hasElement)return this.getFitCameraToObjectZoom(this.currentFloor.groundUpper,t,i).zoom}fitCameraToGround(t,e,i){return t===void 0&&(t=[20,20,20,20]),e===void 0&&(e=500),i===void 0&&(i=!0),this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundLayer,t,e,i):Promise.resolve(!1)}setCameraPosition(t,e){return g(this,null,function*(){return this.control.setCameraPositionByTarget(t,e)})}pauseRender(){this.renderer.pauseRender()}continueRender(){this.renderer.continueRender()}forceUpdate(){this.collisionSystem.needsUpdate=!0}dispose(){var t;this.collisionSystem.dispose(),(t=this.currentFloor)==null||t.dispose(),this.control.dispose(),this.cameraBound.dispose(),this.selection.dispose(),this.hoverHelper.dispose(),this.unRegistryEvent(),this.renderer.dispose(),this.lights.children.forEach(e=>e.dispose()),this.scene.dispose(),this.container=null,this.renderer=null}constructor(t,e){super(),this.container=t,this.lights=nn(),this.range=Kr([]),this.clientSize={width:0,height:0,x:0,y:0},this.renderRf=0,this.basicZoom=1,this.debugCollisionBox=!1,this.onControlChange=()=>{this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})},this.onControlChangeZoom=s=>{let{zoom:o}=s;this.dispatchEvent({type:"control-zoom-change",zoom:o})},this.onRendererUpdate=()=>{this.dispatchEvent({type:"update"})},this.onWindowResize=()=>{let{container:s,camera:o,renderer:n}=this,{clientWidth:r,clientHeight:h}=s;r=Math.max(1,r),h=Math.max(1,h),o.left=-r/2,o.right=r/2,o.top=h/2,o.bottom=-h/2,o.updateProjectionMatrix(),n.setSize(r,h),this.resizeClientSize(),this.dispatchEvent({type:"resize",width:r,height:h})},this.onClick=s=>{let{graphics:o,position:n}=this.getGraphicsByDeviceXy(s.offsetX,s.offsetY);o.length&&this.dispatchEvent({type:"graphic-click",graphics:o,position:n});let r=this.getPoisByDeviceXy(s.offsetX,s.offsetY);r.length&&this.dispatchEvent({type:"poi-click",pois:r});let h=null,c=new me;c.x=s.offsetX/this.clientSize.width*2-1,c.y=s.offsetY/this.clientSize.height*-2+1;let l=new Vr;l.setFromCamera(c,this.camera);let p=new cu(new Dt(0,0,1),0),d=new Dt;if(l.ray.intersectPlane(p,d)?h=d:(l.ray.direction.negate(),l.ray.intersectPlane(p,d)&&(h=d)),h){let u=this.bmap.coordinateTransform.worldToMercator(h);this.dispatchEvent({type:"click",position:h,mercator:u})}},this.onPointerover=s=>{let{graphics:o,position:n}=this.getGraphicsByDeviceXy(s.offsetX,s.offsetY),r=this.getPoisByDeviceXy(s.offsetX,s.offsetY);this.dispatchEvent({type:"pointer-over",e:s,graphics:o,pois:r,position:n})},this.onPointermove=s=>{let{graphics:o,position:n}=this.getGraphicsByDeviceXy(s.offsetX,s.offsetY),r=this.getPoisByDeviceXy(s.offsetX,s.offsetY);this.dispatchEvent({type:"pointer-move",e:s,graphics:o,pois:r,position:n})},this.onPointerleave=s=>{this.dispatchEvent({type:"pointer-level"})},this.onSelectionSelect=s=>{let{graphics:o,isMultipleSelect:n}=s;this.dispatchEvent({type:"select-graphic",graphics:o,isMultipleSelect:n})},this.onHoverChange=s=>{let{graphics:o}=s;this.dispatchEvent({type:"hover",graphics:o})},this.bmap=e,this.container.style.position="relative",this.container.style.overflow="hidden";var i;this.renderer=new gs(this,{antialias:(i=this.config.renderer.antialias)!=null?i:!vi}),this.scene=new ys(this.renderer),this.collisionSystem=new xs(this),this.init(),this.selection=new hs(this),this.hoverHelper=new cs(this),this.resizeClientSize(),this.registryEvent()}};import{merge as lu}from"lodash";var pu={placeId:0,fps:30,apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get",equipmentList:"/api/inception-map/equipment/get",roadNetwork:"/api/inception-map/road_network/get",loadPlaceInfo:"https://screen.aibee.cn/ai-map/map/get-floor-map"},enableBoxSelect:!0,resizeObserver:{enable:!1,debounceTime:5},initTransToMark:!1,heatMap:{radius:50,minOpacity:.1,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2,defaultPolar:1.1,defaultAzimuthal:0,maxZoomScale:30},defaultPadding:[20,20,20,20],svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:100},ground:{color:"#F6F6F6",opacity:1,height:.001,stroke:!1,strokeColor:"#E6E6E6",strokeOpacity:1},markGraphic:{color:"#EEF0F3",opacity:1,height:.001,stroke:!1,strokeColor:"#000",strokeOpacity:1},graphic:{fillOpacity:1},cameraBound:{padding:[150,150,150,150]},poi:{boxScale:1,batchText:!0,batchIcon:!0},loaderPlaceConfig:{textFontSize:14},poiTextBackground:{enable:!1,color:"#FFFFFF",opacity:1},poiTextFontFamily:"sans-serif",renderAnimation:"setTimeout",renderer:{maxPixelRatio:2}};function Xr(a){return typeof a.resizeObserver=="boolean"&&(a.resizeObserver={enable:a.resizeObserver}),lu({},pu,a)}import{debounce as Du}from"lodash";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.error.cause.js";import{Vector3 as Su,Color as Cu}from"three";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";var _s=function(a){return a.LAYERED_RENDER_VERSION="layeredRender",a.MERGED_RENDER_VERSION="mergedRender",a}({});function Ps(a,t){let e=a.poi_info.showName||a.store_name||a.poi_info.text;switch(t){case"zh-cn":return e;case"en":var i;return((i=a.store_info_ext)==null?void 0:i.poi_name)||e;case"zh-hk":var s;return((s=a.store_info_ext)==null?void 0:s.traditional_name)||e}}function bs(a,t){let e=a.poi_info.showName||a.store_name||a.poi_info.text;switch(t){case"zh-cn":return e;case"en":var i;return((i=a.infra_info_ext)==null?void 0:i.poi_name)||e;case"zh-hk":var s;return((s=a.infra_info_ext)==null?void 0:s.traditional_name)||e}}var Lo=["range","ground","store","facility","parkingSpace"];function Yr(a){return Lo.indexOf(a.l_type)===-1?Lo.length:Lo.indexOf(a.l_type)}function du(a){a.layers.sort((t,e)=>Yr(t)-Yr(e))}function uu(a){let t=a.layers.find(i=>i.l_type==="range"),e=[t.elements[0].center_x,t.elements[0].center_y];a.layers.map(i=>{if(i.l_type!=="range")return Pi(i.elements,e)})}function oi(a){du(a),uu(a)}function Re(a,t){return t===void 0&&(t=6),a.floor_id+"_"+a.version_id+(t?"_"+t:"")}function qr(a,t,e){switch(a.l_type){case"ground":return ko(a,t);case"graph":return mu(a,t,e);case"wall":return fu(a,t);case"lane":return gu(a,t);case"texture2d":case"texture3d":return yu(a,t);case"glb":return vu(a,t);case"store":return xu(a,t,e);case"facility":return _u(a,t,e);case"parkingSpace":return bu(a,t,e);case"text":return Eu(a,t)}}function $r(a,t,e,i,s){switch(a.l_type){case"store":return wu(a,t,e,i,s);case"facility":return Pu(a,t,e,i,s);case"parkingSpace":return Mu(a,t,i,s)}}function mu(a,t,e){e.mergeGraphic?t.mergeGraphicLayer.addGraphics(a.elements,a.mergedElements):a.elements.map(i=>{let s=t.addGraphic(w({},i,{dashed:!1}));t.userData.graphics.push(s),t.userData.graphicMap.set(i.id,s)})}function ko(a,t){let e=a.elements.map(i=>new Y(t.context,w({},i,{dashed:!1})));t.addGrounds(e)}function fu(a,t){if(a.mergedElements)a.mergedElements.map(e=>{if(e.instancedGeometry){let i=new rs(t.context,e.instancedGeometry);t.wallLayer.add(i)}if(e.mergedGeometry){let i=new is(t.context,e);t.wallLayer.add(i),e.mergedGeometry=null}});else{let e=a.elements.reduce((i,s)=>{let{fillColor:o,fillOpacity:n,strokeColor:r,strokeOpacity:h,height:c}=s,l=o.toLowerCase()+"-"+n+"-"+r.toLowerCase()+"-"+h+"-"+c;return h===0&&(l=o.toLowerCase()+"-"+n+"-"+c),i[l]?i[l].push(s):i[l]=[s],i},{});Object.values(e).forEach(i=>{let s=new Ji(t.context,i);t.wallLayer.add(s)})}}function gu(a,t){if(a.mergedElements){let e=new os(t.context,a.mergedElements);t.laneLayer.add(e)}else{let e=new ts(t.context,a.elements);t.laneLayer.add(e)}}function yu(a,t){if(a.mergedMatrixes)a.mergedMatrixes.map(e=>{let i=new pe(t.context,e);t.textureLayer.add(i)});else if(a.elements.length){let e=new le(t.context,a.elements);t.textureLayer.add(e)}}function vu(a,t){t.glbModelLayer.addModels(a.elements.map(e=>w({},e,{url:e.secondUrl,rotate:e.secondRotate,width:e.secondWidth,center_x:e.center_coord_x,center_y:e.center_coord_y,deltaHeight:0})))}function xu(a,t,e){e.mergeGraphic?t.mergeGraphicLayer.addGraphics(a.elements,a.mergedElements):a.elements.map(i=>{let s=t.addGraphic(w({},i,{dashed:!1}));t.userData.graphics.push(s),t.userData.graphicMap.set(i.id,s)})}function wu(a,t,e,i,s){a.elements.filter(o=>s.filterPoi(o)).map(o=>{try{let n=Ps(o,e),r=new et(t.context,{id:o.id,icon:o.poi_info.showImageUrl||o.poi_info.icon,text:n,position:{x:o.center_coord_x,y:o.center_coord_y,z:o.airHeight+o.height},icon_size:[24,24],level:o.poi_info.level||0,hide_text:!i.showStoreName,maxWeight:o.poi_info.maxWeight||25,minWeight:o.poi_info.minWeight||1,text_font_size:i.textFontSize});t.poiLayer2.pushPoi(r),r&&(r.userData.type="store",r.userData.data=o,r.userData.floor=t.name)}catch(n){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",n,o)}})}function _u(a,t,e){e.mergeGraphic?t.mergeGraphicLayer.addGraphics(a.elements,a.mergedElements):a.elements.map(i=>{let s=t.addGraphic(w({},i,{dashed:!1}));t.userData.graphics.push(s),t.userData.graphicMap.set(i.id,s)})}function Pu(a,t,e,i,s){a.elements.filter(o=>o.poi_info).filter(o=>s.filterPoi(o)).map(o=>{try{let n=bs(o,e),r=new et(t.context,{id:o.id,icon:o.poi_info.showImageUrl||o.poi_info.icon,text:n,position:{x:o.center_coord_x,y:o.center_coord_y,z:o.airHeight+o.height},icon_size:[24,24],level:o.poi_info.level||0,hide_text:!i.showFacilityName,maxWeight:o.poi_info.maxWeight||25,minWeight:o.poi_info.minWeight||1,text_font_size:i.textFontSize});t.poiLayer2.pushPoi(r),r.userData.type="facility",r.userData.data=o,r.userData.floor=t.name}catch(n){console.log("\u6DFB\u52A0facility\u5931\u8D25",n,o)}})}function bu(a,t,e){t.parkingSpaceLayer.load(a,e.mergeParkingSpace),t.userData.parkingSpaces=t.parkingSpaceLayer.graphicMap.values(),t.userData.parkingSpacesGraphicMap=t.parkingSpaceLayer.graphicMap}function Mu(a,t,e,i){return g(this,null,function*(){a.elements.filter(o=>o.texts[0]).filter(o=>i.filterPoi(o)).forEach(o=>{try{let n=o.displayName||o.texts[0],r=new et(t.context,{id:o.id,text:n,position:{x:o.center_coord_x,y:o.center_coord_y,z:o.airHeight+o.height},text_font_size:e.textFontSize});r&&(r.userData.type="parkingSpace",r.userData.data=o,r.userData.floor=t.name),t.poiLayer2.pushPoi(r)}catch(n){console.log("\u6DFB\u52A0\u8F66\u4F4Dpoi\u5931\u8D25",n,o)}})})}function Eu(a,t){let e=new es(t.context,a.elements.map(i=>w({},i,{center_x:i.center_coord_x,center_y:i.center_coord_y})));t.textTextureLayer.add(e)}function Ao(){return new Worker(new URL("./worker/loader.worker-XZ4WO3FM.js",import.meta.url))}var Tu={mergeParkingSpace:!0,mergeGraphic:!0,renderVersion:_s.MERGED_RENDER_VERSION,layers:["graph","wall","lane","texture2d","texture3d","glb","store","facility","parkingSpace","text"],filterPoi:()=>!0},Oe=class extends st{initDb(){return g(this,null,function*(){try{let{db:t}=yield Ye();this.db=t}catch(t){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",t)}})}load(t,e){return g(this,null,function*(){if(Array.isArray(t))this.floors=t,e&&(this.placeConfig=w({},this.placeConfig,e));else if(typeof t=="string"){let i=yield fetch(t).then(s=>s.json());if(i.code===200){let s=location.origin;this.floors=i.data.list.map(o=>{let n=/^http(s?):\/\//.test(o.entry_infra_url),r=/^http(s?):\/\//.test(o.map_url),h=/^http(s?):\/\//.test(o.route_url);return w({},o,{entry_infra_url:n?o.entry_infra_url:""+s+o.entry_infra_url,map_url:r?o.map_url:""+s+o.map_url,route_url:h?o.route_url:""+s+o.route_url})}),this.placeConfig=w({},this.placeConfig,JSON.parse(i.data.config||"{}"),e)}}else return this.load("https://screen.aibee.cn/ai-map/map/get-floor-map?place_id="+t,e);this.preloadPromise=this.getOtherDataByFreeTime()})}waitForPreload(){return this.preloadPromise}setCacheData(t,e,i){return g(this,null,function*(){let s=yield Xe();return this.db=s,Ti(t,""+e,i,s)})}getCacheData(t,e){return g(this,null,function*(){let i=yield Xe();return this.db=i,qe(t,""+e,i)})}getCacheDataWithRetry(t,e,i,s){return g(this,null,function*(){i===void 0&&(i=3),s===void 0&&(s=50);for(let o=0;o<i;o++){let n=yield this.getCacheData(t,e);if(n)return n;o<i-1&&(yield new Promise(r=>setTimeout(r,s)))}return null})}getFloorData(t){return g(this,null,function*(){let e=yield this.getFloorJsonData(t);return e?this.getDataByJson(e):null})}getFloorDataByFloorInfo(t){return g(this,null,function*(){let e=yield this.getFloorJsonDataByFloorInfo(t);return this.getDataByJson(e)})}setLocale(t){this.locale=t,this.bmap.context.currentFloor&&this.bmap.context.currentFloor.poiLayer2.pois.forEach(e=>{e.userData.type==="store"&&(e.options.text=Ps(e.userData.data,t)),e.userData.type==="facility"&&(e.options.text=bs(e.userData.data,t))})}readFloorFromCache(t,e){return g(this,null,function*(){e===void 0&&(e=!1);try{let i=Re(t),s=e?yield this.getCacheDataWithRetry(ct.MAP_DATA,i):yield this.getCacheData(ct.MAP_DATA,i);if(s&&s.transformed)return console.log("\u4ECE\u7F13\u5B58\u4E2D\u53D6\u5230\u4E86\u5408\u5E76\u540E\u7684\u6570\u636E"),s;if(this.options.renderVersion===_s.LAYERED_RENDER_VERSION){let o=Re(t,1),n=e?yield this.getCacheDataWithRetry(ct.MAP_DATA,o):yield this.getCacheData(ct.MAP_DATA,o);if(n)return console.log("\u4ECE\u7F13\u5B58\u4E2D\u53D6\u5230\u4E86\u6570\u636E"),n}return null}catch(i){return console.warn("[read floor cache error]",i),null}})}getFloorJsonDataByFloorInfo(t){return g(this,null,function*(){let e=yield this.readFloorFromCache(t);if(e)return e;let i=this.getFloorDataPromise.get(t.floor);if(i)return i;let s=Re(t),o=g(this,null,function*(){let r=yield fetch(t.map_url).then(h=>h.json());r.floor=t.floor,oi(r);try{yield this.setCacheData(ct.MAP_DATA,s,r),yield this.setCacheData(ct.MAP_VERSION,s,t.version_id)}catch(h){console.warn("[cache floor data error]",h)}return r});this.getFloorDataPromise.set(t.floor,o);let n=()=>{this.getFloorDataPromise.get(t.floor)===o&&this.getFloorDataPromise.delete(t.floor)};return o.then(n,n),o})}getFloorJsonData(t,e){return g(this,null,function*(){e===void 0&&(e=!1);let i=this.floors.find(s=>s.floor===t);return i?new Promise(s=>g(this,null,function*(){try{let o=yield this.readFloorFromCache(i,e);if(o){s(o);return}let n=this.getFloorDataPromise.get(t);if(n)try{s(yield n);return}catch(r){this.getFloorDataPromise.delete(t)}if(e){s(this.getFloorJsonDataByFloorInfo(i));return}if(console.log("\u7F13\u5B58\u4E2D\u6CA1\u6709\u6570\u636E"),this.loadWorker){H(this.loadWorker,"adjust_floor_priority",{floor:t});let r,h=c=>{if(c.data.type==="floor_success"&&c.data.data.floor===t){var l;r&&clearTimeout(r),(l=this.loadWorker)==null||l.removeEventListener("message",h),s(this.getFloorJsonData(t,!0))}};r=setTimeout(()=>{var c;(c=this.loadWorker)==null||c.removeEventListener("message",h),s(this.getFloorJsonDataByFloorInfo(i))},1500),this.loadWorker.addEventListener("message",h)}else s(this.getFloorJsonDataByFloorInfo(i))}catch(o){console.log("[get floor data error]",o),s(this.getFloorJsonDataByFloorInfo(i))}})):null})}getRoadNetworkData(){return g(this,null,function*(){return(yield Promise.all(this.floors.map(e=>g(this,null,function*(){let i=Re(e,0);try{let s=yield this.getCacheData(ct.ROAD_NETWORK_DATA,i);if(s)return s;let o=yield fetch(e.route_url).then(n=>n.json());return this.setCacheData(ct.ROAD_NETWORK_DATA,i,o),this.setCacheData(ct.ROUTE_VERSION,i,e.version_id),o}catch(s){let o=yield fetch(e.route_url).then(n=>n.json());return this.setCacheData(ct.ROAD_NETWORK_DATA,i,o),o}})))).filter(e=>e.points)})}getFacilitiesData(){return g(this,null,function*(){let t=this.floors.reduce((s,o)=>s.updated_at>o.updated_at?s:o,this.floors[0]);if(!t)return null;let e=Re(t,0),i=()=>g(this,null,function*(){let s=yield fetch(t.entry_infra_url).then(o=>o.json());return s&&(this.setCacheData(ct.FACILITY_DATA,e,s),this.setCacheData(ct.FACILITY_VERSION,e,t.version_id)),s});try{let s=yield this.getCacheData(ct.FACILITY_DATA,e);return s||i()}catch(s){return console.log("[get facility error]",s),i()}})}getOtherDataByFreeTime(){return g(this,null,function*(){yield this.initDbPromise,this.loadWorker&&(yield H(this.loadWorker,"load",{floors:this.floors,version:this.options.renderVersion})),this.closeWorker()})}getMulFloorsData(t){return g(this,null,function*(){return Promise.all(t.map(e=>this.getFloorData(e))).then(e=>e.filter(i=>i))})}getDataByUrl(t){return g(this,null,function*(){let e=yield fetch(t).then(i=>i.json());return this.getDataByJson(e)})}getDataByJson(t,e,i){return g(this,null,function*(){t.transformed||oi(t),e=this.getFloorBaseLayer(t,e);let s=w({},this.placeConfig,i);return yield this.getFloorContentLayer(t,e),yield this.getFloorPoi(t,e,s),this.changeFloorBox(t,e),e})}getDataByJsonStep(t,e,i){return g(this,null,function*(){t.transformed||oi(t),e=this.getFloorBaseLayer(t,e);let s=w({},this.placeConfig,i);return this.changeFloorBox(t,e),requestAnimationFrame(()=>g(this,null,function*(){yield this.getFloorContentLayer(t,e),this.changeFloorBox(t,e),requestAnimationFrame(()=>g(this,null,function*(){yield this.getFloorPoi(t,e,s),this.changeFloorBox(t,e)}))})),e})}changeFloorBox(t,e){e.updateBox();let i=e.box.getSize(new Su),s=Math.max(i.x,i.y,i.z);e.userData.height=s/4+t.floorHeight}switchFloor(t,e){return g(this,null,function*(){return new Promise(i=>{let s={run:()=>this._switchFloor(t,e),meta:{type:"switchFloor"}},o=this.taskQueue.replaceByMetaType(s),n=r=>{let{task:h,res:c}=r;h.tid===o&&(this.taskQueue.removeEventListener("active-task-end",n),i(c))};this.taskQueue.addEventListener("active-task-end",n)})})}_switchFloor(t,e){return g(this,null,function*(){var i;let s=typeof t=="string"?t:(i=t==null?void 0:t.floor)!=null?i:"";try{var o;let h=t;if(typeof t=="string"){let u=yield this.getFloorJsonData(t);if(!u)throw new Error("floor data unavailable: "+t);h=u}else t.transformed||oi(t);let c=w({},this.placeConfig,e),l=new zt(this.bmap.context);l.userData.data=h;let p=this.floors.find(u=>u.floor===h.floor);var n;let d=(n=p==null?void 0:p.map_angle)!=null?n:0;this.bmap.dispatchEvent({type:lt.SWITCH_FLOOR_BEFORE,data:{curFloor:l,graphics:[]}}),this.dispatchEvent({type:"switch-floor-before",data:{curFloor:l,graphics:[],floorData:h}}),this.bmap.context.scene.background=new Cu(c.backgroundColor),this.getFloorBaseLayer(h,l),this.changeFloorBox(h,l),this.bmap.buildingCenter=l.userData.center;var r;return this.bmap.currentBuildGround=(r=(o=h.layers.find(u=>u.l_type==="range"))==null?void 0:o.elements[0])!=null?r:null,this.bmap.context.switchFloor(l),this.bmap.config.control.defaultAzimuthal=d/180*Math.PI,this.bmap.initialFloorCamera(),this.bmap.context.cameraBound.updateBox(),this.dispatchEvent({type:"switch-floor-ground",data:{curFloor:l,graphics:[]}}),this.bmap.dispatchEvent({type:lt.SWITCH_FLOOR_GROUND,data:{curFloor:l}}),yield qs(),yield this.getFloorContentLayer(h,l),this.changeFloorBox(h,l),this.bmap.context.cameraBound.updateBox(),this.dispatchEvent({type:"switch-floor-content",data:{curFloor:l,graphics:[]}}),yield pn(2),yield this.getFloorPoi(h,l,c),this.dispatchEvent({type:"switch-floor-after",data:{curFloor:l,graphics:l.graphicLayer.children}}),this.bmap.dispatchEvent({type:lt.SWITCH_FLOOR_AFTER,data:{curFloor:l,graphics:l.graphicLayer.children}}),l}catch(h){return console.warn("[switch floor error]",h),this.dispatchEvent({type:"switch-floor-error",data:{floor:s,error:h}}),null}})}getFloorBaseLayer(t,e){e||(e=new zt(this.bmap.context));let i=[0,0];return t.layers.forEach(s=>{switch(s.l_type){case"range":let o=s.elements[0];i=[o.center_x,o.center_y],e.userData.range=o.geometry.cds[0],e.userData.rangeGraphic=o;break;case"ground":ko(s,e);break;default:break}}),e.userData.center=i,e.name=t.floor,e.userData.data=t,e}getFloorContentLayer(t,e){return g(this,null,function*(){e||(e=new zt(this.bmap.context)),e.userData.graphics=[],e.userData.graphicMap=new Map;let i=Date.now();for(let s=0;s<t.layers.length;s++){let o=t.layers[s];["range","ground"].includes(o.l_type)||this.options.layers.includes(o.l_type)&&(qr(o,e,this.options),console.log("time",Date.now()-i,o.l_type),i=Date.now())}return e})}getFloorPoi(t,e,i){return g(this,null,function*(){i===void 0&&(i=this.placeConfig);let s=Date.now();yield Promise.all(t.layers.map(n=>{if(this.options.layers.includes(n.l_type))return $r(n,e,this.locale,i,this.options)})),console.log("poi time",Date.now()-s);let o=Date.now();qs().then(()=>{console.log("poi render time",Date.now()-o)})})}clear(){return g(this,null,function*(){this.db=null,this.getFloorDataPromise.clear()})}closeWorker(){this.loadWorker&&(this.loadWorker.terminate(),this.loadWorker=null)}dispose(){this.disposed||(this.disposed=!0,super.dispose(),this.clear(),this.closeWorker(),this.getFloorDataPromise.clear())}constructor(t,e={}){super(),this.bmap=t,this.disposed=!1,this.floors=[],this.initDbPromise=Promise.resolve(),this.preloadPromise=Promise.resolve(),this.db=null,this.taskQueue=new Pe,this.loadWorker=Ao(),this.locale="zh-cn",this.placeConfig={backgroundColor:"#f1f7f6",showFacilityName:!0,showStoreName:!0,textFontSize:14},this.getFloorDataPromise=new Map,this.options=w({},Tu,e),this.placeConfig=w({},this.placeConfig,t.config.loaderPlaceConfig),this.initDbPromise=this.initDb()}};import"core-js/modules/web.dom-collections.iterator.js";function Jr(a,t){return g(this,null,function*(){let{brand:e,project:i}=a,{apiDomain:s,apiPath:{floorRange:o},apiInfo:n}=t,r=""+s+o+"?brand="+e+"&project="+i+"&phase="+i+"&building="+i;return yield fetch(r,n).then(c=>c.json()).then(c=>c.data).then(c=>{let l=(c||[])[0];return l&&(l.info=JSON.parse(l.info)),l})})}function Qr(a,t){return g(this,null,function*(){let{brand:e,project:i,floor:s,ts:o,resource_type_list:n}=a,{apiDomain:r,apiPath:{floorGraphic:h},apiInfo:c}=t,l=""+r+h+"?brand="+e+"&project="+i+"&phase="+i+"&building="+i+"&floor="+s+"&ts="+o+"&resource_type_list="+n;return yield fetch(l,c).then(d=>d.json()).then(d=>d.data).then(d=>((d||[]).map(u=>u.info=JSON.parse(u.info)),d||[]))})}function Z1(a,t){return g(this,null,function*(){let{project:e,floor:i}=a,{apiDomain:s,apiInfo:o}=t,n=s+"/api/inception-map/external_street/get?projectCode="+e+"&floorCode="+i;return yield fetch(n,o).then(h=>h.json()).then(h=>h.data).then(h=>JSON.parse(h[0].streetInfo||"{}")).then(h=>h.fileId?Lu(h.fileId,t):null)})}function Lu(a,t){return g(this,null,function*(){let{apiDomain:e,apiInfo:i}=t;return fetch(e+"/api/inception-map/file/getFileStream?fileId="+a,i).then(s=>s.arrayBuffer()).then(s=>{let n=new TextDecoder("utf-8").decode(s);return n?JSON.parse(n):null})})}var ta=class{load(t){return g(this,null,function*(){let e=ae(t);if(this.cacheData.has(e))return this.cacheData.get(e);let[,i]=yield Promise.all([this.loadBuildGround(t),Qr(t,this.bmap.config)]),s=ae({floor:t.floor,ts:t.ts});Pi(i.map(n=>n.info),this.bmap.buildingCenter,this.floorDataLengthMap.get(s)||0),i.forEach(n=>n.info.transformToBuildingGround=!1),this.cacheData.set(e,i);let o=this.floorDataLengthMap.get(s)||0;return this.floorDataLengthMap.set(s,o+i.length),this.loadExternalStreet(t),i})}loadExternalStreet(t){return g(this,null,function*(){})}switchFloorByData(t,e){if(!t.length)return;let i=e.userData.legacyToGraphicMap||new Map,s=e.userData.graphicMap||new Map,{ground:o,markGraphic:n,graphic:r}=this.bmap.config;for(let h=0;h<t.length;h++){let c=t[h],l=w({},c,{info:w({},c.info)});if(c.info.group==="ground"){l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.height=o.height,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity,e.createGround(l.info);continue}else c.info.userData.mark?(l.info.height=n.height,l.info.fillColor=n.color,l.info.fillOpacity=n.opacity,l.info.stroke=n.stroke,l.info.strokeColor=n.strokeColor,l.info.strokeOpacity=n.strokeOpacity):(l.info.fillOpacity=r.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=n.height,l.info.fillColor=n.color,l.info.stroke=n.stroke,l.info.strokeColor=n.strokeColor,l.info.strokeOpacity=n.strokeOpacity));let p=e.addGraphic(l.info);p.userData.data=c,i.set(c.legacy_id,p),s.set(c.element_uuid,c)}e.userData.legacyToGraphicMap=i,e.userData.graphicMap=s,e.userData.rangeGraphic=this.bmap.currentBuildGround,e.userData.range=this.bmap.currentBuildGround.geometry.cds[0],e.userData.center=this.bmap.buildingCenter,e.updateBox(),e===this.bmap.context.currentFloor?(this.bmap.triggerHooks(lt.SWITCH_FLOOR_BEFORE,{curFloor:e,graphics:e.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(lt.SWITCH_FLOOR_AFTER,{curFloor:e,graphics:e.graphicLayer.children})):this.bmap.switchFloorByFloor(e)}filterData(t,e){let i=e.userData.graphicMap||new Map;return t.filter(s=>!i.has(s.element_uuid))}switchFloorByStoreData(t,e){return g(this,null,function*(){let i=yield this.load(w({},t,{resource_type_list:"6"})),s=this.filterData(i,e);this.switchFloorByData(s,e)})}switchFloorByOtherData(t,e){return g(this,null,function*(){let i=yield this.load(w({},t,{resource_type_list:"1,2,3,4"})),s=this.filterData(i,e);this.switchFloorByData(s,e)})}loadBuildGround(t){return g(this,null,function*(){let{brand:e,project:i}=t,s=yield this.loadBuildingGround({brand:e,project:i});var o;return this.bmap.currentBuildGround=(o=s==null?void 0:s.info)!=null?o:null,this.bmap.changeBuildingCenter(s,{brand:e,project:i}),this.bmap.currentBuildGround})}loadBuildingGround(t){return g(this,null,function*(){let{brand:e,project:i}=t,s=ae({brand:e,project:i});if(this.buildingGroundMap.has(s))return this.buildingGroundMap.get(s);let o=Jr({brand:e,project:i},this.bmap.config).then(n=>(this.buildingGroundMap.set(s,n),n));return this.buildingGroundMap.set(s,o),o})}switchFloor(t){return g(this,null,function*(){let e=new zt(this.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([this.switchFloorByStoreData(t,e),this.switchFloorByOtherData(t,e)])}catch(i){console.log(i)}return e})}dispose(){this.cacheData.clear(),this.floorDataLengthMap.clear(),this.buildingGroundMap.clear()}constructor(t){this.bmap=t,this.cacheData=new Map,this.floorDataLengthMap=new Map,this.buildingGroundMap=new Map,this.externalStreetMap=new Map}};var fT=function(a){return a[a.D2=0]="D2",a[a.D3=1.1]="D3",a}({}),Oo=class a extends Au{get buildingCenter(){return this.coordinateTransform.getBuildingCenter()}set buildingCenter(t){this.coordinateTransform.setBuildingCenter(t)}get basicZoom(){return this.context.basicZoom}set basicZoom(t){this.context.basicZoom=t}changeBuildingCenter(t,e){let{brand:i,project:s}=e,o=t?gi(t.info.geometry.cds[0]):[0,0];this.buildingCenter=o,this.coordinateTransform.setBuildingCenter(o),this.dispatchEvent({type:"center-change",center:o,project:s,brand:i})}use(t){t.bmap=this,this.plugins.push(t)}unUse(t){this.plugins=this.plugins.filter(e=>e!==t)}triggerHooks(t,e){this.dispatchEvent({type:t,data:e})}switchFloor(t){return g(this,null,function*(){return this.loader||(this.loader=new Oe(this),this.loader.placeConfig=w({},this.loader.placeConfig,this.config.loaderPlaceConfig),yield this.loader.load(this.config.apiPath.loadPlaceInfo+"?place_id="+this.config.placeId+"&env=prod")),this.loader.switchFloor(t)})}switchFloorByFloor(t,e,i){e===void 0&&(e=!0),i===void 0&&(i=t.graphicLayer.children),this.triggerHooks(lt.SWITCH_FLOOR_BEFORE,{curFloor:t,graphics:i}),this.buildingCenter=t.userData.center,this.coordinateTransform.setBuildingCenter(t.userData.center),this.currentBuildGround=t.userData.rangeGraphic,this.context.switchFloor(t,e),this.initialFloorCamera(),this.triggerHooks(lt.SWITCH_FLOOR_AFTER,{curFloor:t,graphics:i})}initialFloorCamera(){this.context.cameraBound.setEnable(!1),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,0),this.context.setPolarAngle(this.config.control.defaultPolar,0),this.context.fitCameraToGround(this.config.defaultPadding,0);let t=this.context.camera.zoom;this.context.control.minZoom=t,this.context.control.maxZoom=t*this.config.control.maxZoomScale,this.type==="3d"&&this.context.fitCameraToGround(this.config.defaultPadding,0,!1),this.basicZoom=this.context.camera.zoom,this.context.control.addEventListener("change",this.onControlChange),this.onControlChange(),this.context.cameraBound.setEnable(!0),this.context.cameraBound.changePrevCamera()}addModel(t,e){if(t.options.geometry.type==="polygon"){var i;let s=(i=this.context.currentFloor)==null?void 0:i.addModel(w({},e,{position:t.getPosition().setZ(.1),id:t.options.id}));if(s){let{facilityAngle:o=0,facilityXScale:n=1,facilityYScale:r=1}=t.options.userData;s.rotateZ((180-o)/180*Math.PI),s.scale.set(n,r,1)}}}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.getGraphics())||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.options.centerCoords,s=t.getCenter(),o=(i==null?void 0:i[0])||s.x,n=(i==null?void 0:i[1])||s.y;return console.log(o,n,i,s),this.context.currentFloor.addPoi(w({},e,{position:{x:o,y:n,z:s.z+t.options.height/2}}))}return null}createPoi2ByPosition(t,e){if(this.context.currentFloor){let i=this.mercatorToWorld([t.x,t.y]),s=new et(this.context,w({},e,{position:{x:i.x,y:i.y,z:t.z}}));return this.context.currentFloor.poiLayer2.pushPoi(s),s}return null}translateElementToCenter(t,e,i,s){e===void 0&&(e=500),i===void 0&&(i=0),s===void 0&&(s=0);let o=t.getPosition().clone(),{context:{camera:n}}=this;if(n.updateMatrix(),s){let r=new Ro;r.setFromMatrixColumn(n.matrix,1),r.normalize(),r.multiplyScalar(s/n.zoom),o.add(r)}if(i){let r=new Ro;r.setFromMatrixColumn(n.matrix,0),r.normalize(),r.multiplyScalar(i/n.zoom),o.add(r)}return this.context.setCameraPosition(o,e)}translateElementToCenterX(t,e){return g(this,null,function*(){return e===void 0&&(e=500),bt(new Promise(i=>{let s=this.context.control.target.clone(),o=t.getPosition();this.timer.requestAnimationFrame(()=>{let{clientSize:{width:n,height:r},camera:h}=this.context,l=L(o,h,n,r).x-n/2,p=new Ro;p.setFromMatrixColumn(this.context.camera.matrix,0),p.normalize(),p.multiplyScalar(l/this.context.camera.zoom),s.add(p),this.context.setCameraPosition(s,e).then(i)})}),e+500)})}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:s}=this.container;return L(e,this.context.camera,i,s)}changeMapType(t,e){return e===void 0&&(e=500),this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(1.1,e)}resetView(t){return g(this,null,function*(){t===void 0&&(t=300);let e=t/3;yield this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,e),yield this.context.setPolarAngle(this.config.control.defaultPolar,e),yield this.context.fitCameraToGround(this.config.defaultPadding,e,!1)})}reduceMap(t,e){t===void 0&&(t=.5),e===void 0&&(e=500);let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t,e){t===void 0&&(t=.5),e===void 0&&(e=500);let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){if(window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp),this.config.resizeObserver.enable){let t=new ResizeObserver(this.debounceResize);t.observe(this.container),this.observe=t}}unRegistryEvent(){var t;this.context.control.removeEventListener("change",this.onControlChange),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp),(t=this.observe)==null||t.disconnect(),this.observe=null}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t,e){t===void 0&&(t=.1),e===void 0&&(e=500);let i=this.context.control.getAzimuthalAngle();return this.context.setAzimuthalAngle(i+t,e)}showCollisionBox(){this.context.debugCollisionBox=!0,this.context.forceUpdate()}hideCollisionBox(){this.context.debugCollisionBox=!1,this.context.forceUpdate()}measureDistance(){return g(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new qi(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",s=>{let{distance:o}=s;t(o)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new $i(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",s=>{let{area:o}=s;t(o)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}fitCameraByPois(t,e,i){return g(this,null,function*(){if(e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500),!t.length)return;let s=new ku;return t.forEach(o=>{let{position:n}=o;s.expandByPoint(n)}),this.context.fitCameraToBox(s,e,i,!1)})}fitCameraByPoiNodeIds(t,e,i){return g(this,null,function*(){e===void 0&&(e=[20,20,20,20]),i===void 0&&(i=500);let s=t.map(o=>this.getPoiById(o)).filter(o=>!!o);if(s.length)return this.fitCameraByPois(s,e,i)})}getGraphicByNodeId(t){var e,i;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||((i=this.context.currentFloor)==null?void 0:i.parkingSpaceLayer.graphicMap.get(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=gi(this.currentBuildGround.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.coords=JSON.parse(JSON.stringify(t.geometry.cds)),t.geometry.coords.map(s=>{Array.isArray(s)&&s.forEach(o=>{o[0]-=i[0],o[1]-=i[1]})});else{let[s,o]=t.geometry.cds;t.geometry.coords=[s-i[0],o-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}mercatorToWorld(t){return this.coordinateTransform.mercatorToWorld(t)}worldToMercator(t){return this.coordinateTransform.worldToMercator(t)}removePoiById(t){var e,i;(e=this.context.currentFloor)==null||e.poiLayer.removePoiById(t),(i=this.context.currentFloor)==null||i.poiLayer2.removePoiById(t)}getPoiById(t){var e;let i=this.context.collisionSystem.objects;return((e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t))||i.find(s=>s.options.id===t)}getPois(){var t;return[...(((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]).filter(e=>!e.options.built_in),...this.context.collisionSystem.objects||[]]}clearPoi(){this.context.currentFloor&&this.context.currentFloor.poiLayer.clear()}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){if(!this.disposed){this.disposed=!0;try{this.loader&&(this.loader.dispose(),this.loader=null),this.unRegistryEvent(),this.timer.dispose(),this.plugins.forEach(t=>t.dispose()),this.plugins=[],this.context.dispose(),this.context=null,this.container=null}finally{if(--a.liveCount<=0){a.liveCount=0;try{[()=>X.dispose(),()=>ht.dispose(),()=>vt.dispose(),()=>pt.dispose(),()=>C.dispose(),()=>kt.dispose(),()=>Do.Dispose==null?void 0:Do.Dispose.call(Do)].forEach(i=>{try{i()}catch(s){console.warn("[BMap.dispose] \u91CA\u653E\u5171\u4EAB\u8D44\u6E90\u5931\u8D25",s)}})}finally{Xn()}}this.debounceResize=null}}}constructor(t,e={}){super(),this.container=t,this.disposed=!1,this.polarKeys=[],this.azimuthalKeys=[],this.prevCameraZoom=1,this.type="2d",this.currentBuildGround=null,this.observe=null,this.coordinateTransform=new Si([0,0]),this.timer=new K,this.plugins=[],this.loader=null,this.onControlChange=()=>{let{camera:{zoom:i}}=this.context;i!==this.prevCameraZoom&&(this.dispatchEvent({type:"zoom-change",basicZoom:this.basicZoom,cameraZoom:this.context.camera.zoom}),this.prevCameraZoom=i)},this.onKeydown=i=>{this.polarKeys.includes(i.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(i.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)},this.onKeyUp=i=>{if(this.polarKeys.includes(i.code)){let s=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=s,this.context.control.minPolarAngle=s}if(this.azimuthalKeys.includes(i.code)){let s=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=s,this.context.control.minAzimuthAngle=s}},this.resize=()=>{this.context.cameraBound.setEnable(!1),this.context.onWindowResize();let i=this.context.control.getAzimuthalAngle(),s=this.context.camera.zoom;this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0);let o=this.context.getFitCameraToGroundZoom(this.config.defaultPadding,0)||1;this.context.camera.zoom=s,this.context.control.minZoom=o,this.context.control.maxZoom=o*this.config.control.maxZoomScale,this.basicZoom=s,this.context.control.addEventListener("change",this.onControlChange),this.context.setAzimuthalAngle(i,0),this.context.cameraBound.setEnable(!0)},this.config=Xr(e),this.context=new ws(t,this),a.liveCount+=1,Kn(),this.debounceResize=Du(this.resize,this.config.resizeObserver.debounceTime),this.registryEvent()}};Oo.liveCount=0;var vT=function(a){return a.HALF="half",a.POWER="power",a.MECHANICAL="mechanical",a.NORMAL="normal",a.VIP="vip",a.GSADV="gsadv",a}({});import"core-js/modules/web.dom-collections.iterator.js";var N=class extends st{dispose(){let t=this.bmap.plugins.findIndex(e=>e===this);t!==-1&&this.bmap.plugins.splice(t,1),this.bmap=null,super.dispose()}constructor(t){super(),this.bmap=t,this.bmap.use(this)}};var ea=class extends N{fetchEquipment(){return g(this,null,function*(){let{apiDomain:t,apiPath:{equipmentList:e},apiInfo:i}=this.bmap.config,s=""+t+e;yield fetch(s,i).then(o=>o.json()).then(o=>o.data).then(o=>{this.equipmentList=o,this.equipmentMap=new Map(o.map(n=>[n.equipment_id,n]))}),this.dispatchEvent({type:"change-equipment-list",data:this.equipmentList}),this.bmap.context.currentFloor&&this.changeGraphicToEquipment(this.bmap.context.currentFloor.graphicLayer.children)})}getGraphicEquipment(t){return t.userData.data.info.userData.equipment}changeGraphicToEquipment(t){t.filter(e=>{let i=this.getGraphicEquipment(e);return i&&this.equipmentMap.has(i)}).forEach(e=>{let i=this.equipmentMap.get(this.getGraphicEquipment(e)),s=this.bmap.createGraphicPoi(e,{icon:i==null?void 0:i.equipment_icon,built_in:!0,icon_size:[14,14]});s&&(s.userData.data=i,s.userData.type="equipment")})}dispose(){var t;this.bmap.removeEventListener(lt.SWITCH_FLOOR_AFTER,this.onSwitchFloor),Array.from(((t=this.bmap.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]).forEach(e=>{if(e.userData.type==="equipment"){var i;(i=this.bmap.context.currentFloor)==null||i.poiLayer.removePoi(e)}}),super.dispose()}constructor(t){super(t),this.equipmentList=[],this.equipmentMap=new Map,this.onSwitchFloor=e=>{let{data:{graphics:i}}=e;this.equipmentList.length&&this.changeGraphicToEquipment(i)},this.fetchEquipment(),this.bmap.addEventListener(lt.SWITCH_FLOOR_AFTER,this.onSwitchFloor)}};import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.promise.finally.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Mesh as Wu,Object3D as Uu,TextureLoader as Hu,Color as Nu,Vector2 as Io,Vector3 as Zu,NormalBlending as ju,RepeatWrapping as Vu}from"three";import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.typed-array.uint16-array.js";import{BufferGeometry as Ru,Matrix4 as sa,Vector3 as fe,Ray as Ou,Sphere as Fu,LineSegments as Iu,BufferAttribute as se,ShaderChunk as _t,ShaderMaterial as oa,UniformsLib as Gu,Color as Bu,Vector2 as ia}from"three";var Pt=class extends Ru{constructor(){super(),this.isMeshLine=!0,this.type="MeshLine",this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this._points=[],this._geom=null,this.widthCallback=null,this.matrixWorld=new sa,Object.defineProperties(this,{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(t){this.setGeometry(t,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(t){this.setPoints(t,this.widthCallback)}}})}};Pt.prototype.setMatrixWorld=function(a){this.matrixWorld=a};Pt.prototype.setGeometry=function(a,t){this._geometry=a,this.setPoints(a.getAttribute("position").array,t)};Pt.prototype.setPoints=function(a,t){if(!(a instanceof Float32Array)&&!(a instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=a,this.widthCallback=t,this.positions=[],this.counters=[],a.length&&a[0]instanceof fe)for(var e=0;e<a.length;e++){var i=a[e],s=e/a.length;this.positions.push(i.x,i.y,i.z),this.positions.push(i.x,i.y,i.z),this.counters.push(s),this.counters.push(s)}else for(var e=0;e<a.length;e+=3){var s=e/a.length;this.positions.push(a[e],a[e+1],a[e+2]),this.positions.push(a[e],a[e+1],a[e+2]),this.counters.push(s),this.counters.push(s)}this.process()};function zu(a,t){var e=new sa,i=new Ou,s=new Fu,o=new fe,n=this.geometry;if(n.boundingSphere||n.computeBoundingSphere(),s.copy(n.boundingSphere),s.applyMatrix4(this.matrixWorld),a.ray.intersectSphere(s,o)!==!1){e.copy(this.matrixWorld).invert(),i.copy(a.ray).applyMatrix4(e);var r=new fe,h=new fe,c=new fe,l=this instanceof Iu?2:1,p=n.index,d=n.attributes;if(p!==null)for(var u=p.array,f=d.position.array,x=d.width.array,m=0,y=u.length-1;m<y;m+=l){var _=u[m],P=u[m+1];r.fromArray(f,_*3),h.fromArray(f,P*3);var S=x[Math.floor(m/3)]!==void 0?x[Math.floor(m/3)]:1,E=a.params.Line.threshold+this.material.lineWidth*S/2,k=E*E,M=i.distanceSqToSegment(r,h,o,c);if(!(M>k)){o.applyMatrix4(this.matrixWorld);var G=a.ray.origin.distanceTo(o);G<a.near||G>a.far||(t.push({distance:G,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this}),m=y)}}}}Pt.prototype.raycast=zu;Pt.prototype.compareV3=function(a,t){var e=a*6,i=t*6;return this.positions[e]===this.positions[i]&&this.positions[e+1]===this.positions[i+1]&&this.positions[e+2]===this.positions[i+2]};Pt.prototype.copyV3=function(a){var t=a*6;return[this.positions[t],this.positions[t+1],this.positions[t+2]]};Pt.prototype.getDistance=function(a){let t=0;for(let e=0;e<a;e++){let i=6*e,s=new fe(this.positions[i],this.positions[i+1],this.positions[i+2]),o=new fe(this.positions[i+6],this.positions[i+7],this.positions[i+8]),n=s.distanceTo(o);t+=n}return t};Pt.prototype.process=function(){var a=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var t;let e=this.getDistance(a-1);var i;this.compareV3(0,a-1)?i=this.copyV3(a-2):i=this.copyV3(0),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);for(var s=0;s<a;s++){if(this.side.push(1),this.side.push(-1),this.widthCallback?t=this.widthCallback(s/(a-1)):t=1,this.width.push(t),this.width.push(t),s===0)this.uvs.push(0,0),this.uvs.push(0,1);else if(s===a-1)this.uvs.push(1,0),this.uvs.push(1,1);else{let n=this.getDistance(s)/e;this.uvs.push(n,0),this.uvs.push(n,1)}if(s<a-1){i=this.copyV3(s),this.previous.push(i[0],i[1],i[2]),this.previous.push(i[0],i[1],i[2]);var o=s*2;this.indices_array.push(o,o+1,o+2),this.indices_array.push(o+2,o+1,o+3)}s>0&&(i=this.copyV3(s),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]))}this.compareV3(a-1,0)?i=this.copyV3(1):i=this.copyV3(a-1),this.next.push(i[0],i[1],i[2]),this.next.push(i[0],i[1],i[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new se(new Float32Array(this.positions),3),previous:new se(new Float32Array(this.previous),3),next:new se(new Float32Array(this.next),3),side:new se(new Float32Array(this.side),1),width:new se(new Float32Array(this.width),1),uv:new se(new Float32Array(this.uvs),2),index:new se(new Uint16Array(this.indices_array),1),counters:new se(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function Fo(a,t,e,i,s){var o;if(a=a.subarray||a.slice?a:a.buffer,e=e.subarray||e.slice?e:e.buffer,a=t?a.subarray?a.subarray(t,s&&t+s):a.slice(t,s&&t+s):a,e.set)e.set(a,i);else for(o=0;o<a.length;o++)e[o+i]=a[o];return e}Pt.prototype.advance=function(a){var t=this._attributes.position.array,e=this._attributes.previous.array,i=this._attributes.next.array,s=t.length;Fo(t,0,e,0,s),Fo(t,6,t,0,s-6),t[s-6]=a.x,t[s-5]=a.y,t[s-4]=a.z,t[s-3]=a.x,t[s-2]=a.y,t[s-1]=a.z,Fo(t,6,i,0,s-6),i[s-6]=a.x,i[s-5]=a.y,i[s-4]=a.z,i[s-3]=a.x,i[s-2]=a.y,i[s-1]=a.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0};_t.meshline_vert=["",_t.logdepthbuf_pars_vertex,_t.fog_pars_vertex,"","attribute vec3 previous;","attribute vec3 next;","attribute float side;","attribute float width;","attribute float counters;","","uniform vec2 resolution;","uniform float lineWidth;","uniform vec3 color;","uniform float opacity;","uniform float sizeAttenuation;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","vec2 fix( vec4 i, float aspect ) {",""," vec2 res = i.xy / i.w;"," res.x *= aspect;"," vCounters = counters;"," return res;","","}","","void main() {",""," float aspect = resolution.x / resolution.y;",""," vColor = vec4( color, opacity );"," vUV = uv;",""," mat4 m = projectionMatrix * modelViewMatrix;"," vec4 finalPosition = m * vec4( position, 1.0 );"," vec4 prevPos = m * vec4( previous, 1.0 );"," vec4 nextPos = m * vec4( next, 1.0 );",""," vec2 currentP = fix( finalPosition, aspect );"," vec2 prevP = fix( prevPos, aspect );"," vec2 nextP = fix( nextPos, aspect );",""," float w = lineWidth * width;",""," vec2 dir;"," if( nextP == currentP ) dir = normalize( currentP - prevP );"," else if( prevP == currentP ) dir = normalize( nextP - currentP );"," else {"," vec2 dir1 = normalize( currentP - prevP );"," vec2 dir2 = normalize( nextP - currentP );"," dir = normalize( dir1 + dir2 );",""," vec2 perp = vec2( -dir1.y, dir1.x );"," vec2 miter = vec2( -dir.y, dir.x );"," //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );",""," }",""," //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;"," vec4 normal = vec4( -dir.y, dir.x, 0., 1. );"," normal.xy *= .5 * w;"," normal *= projectionMatrix;"," if( sizeAttenuation == 0. ) {"," normal.xy *= finalPosition.w;"," normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;"," }",""," finalPosition.xy += normal.xy * side;",""," gl_Position = finalPosition;","",_t.logdepthbuf_vertex,_t.fog_vertex&&" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",_t.fog_vertex,"}"].join(`
625
625
  `);_t.meshline_frag=["",_t.fog_pars_fragment,_t.logdepthbuf_pars_fragment,"","uniform sampler2D map;","uniform sampler2D alphaMap;","uniform float useMap;","uniform float useAlphaMap;","uniform float useDash;","uniform float dashArray;","uniform float dashOffset;","uniform float dashRatio;","uniform float visibility;","uniform float alphaTest;","uniform vec2 repeat;","uniform float thresholdRatio;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","void main() {",""," if (vUV.x <= thresholdRatio) {"," discard;"," }",_t.logdepthbuf_fragment,""," vec4 c = vColor;"," if( useMap == 1. ) c *= texture2D( map, vUV * repeat );"," if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;"," if( c.a < alphaTest ) discard;"," if( useDash == 1. ){"," c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));"," }"," gl_FragColor = c;"," gl_FragColor.a *= step(vCounters, visibility);","",_t.fog_fragment,"}"].join(`
626
- `);var ni=class extends oa{constructor(t){super({uniforms:Object.assign({},Gu.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new Bu(16777215)},opacity:{value:1},resolution:{value:new ia(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new ia(1,1)},thresholdRatio:{value:0},transparent:{value:!0},depthTest:{vale:!1},depthWrite:{value:!1}}),vertexShader:_t.meshline_vert,fragmentShader:_t.meshline_frag}),this.isMeshLineMaterial=!0,this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(e){this.uniforms.useDash.value=e}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(e){this.uniforms.repeat.value.copy(e)}},thresholdRatio:{enumerable:!0,get:function(){return this.uniforms.thresholdRatio.value},set:function(e){this.uniforms.thresholdRatio.value=e}}}),this.setValues(t)}};ni.prototype.copy=function(a){return oa.prototype.copy.call(this,a),this.lineWidth=a.lineWidth,this.map=a.map,this.useMap=a.useMap,this.alphaMap=a.alphaMap,this.useAlphaMap=a.useAlphaMap,this.color.copy(a.color),this.opacity=a.opacity,this.resolution.copy(a.resolution),this.sizeAttenuation=a.sizeAttenuation,this.dashArray.copy(a.dashArray),this.dashOffset.copy(a.dashOffset),this.dashRatio.copy(a.dashRatio),this.useDash=a.useDash,this.visibility=a.visibility,this.alphaTest=a.alphaTest,this.repeat.copy(a.repeat),this};var na={texture_url:Di,lineWidth:10,color:16777215},bs=class extends Uu{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:i,height:s}}}}}=this,o=t.map(r=>{let[h,c]=r;return L(new Zu(h,c,0),e,i,s)}).map(r=>{let{x:h,y:c}=r;return[h,c]});return ft(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new Io(t,1)}loadTexture(t){return new Promise((e,i)=>{new Hu().load(t,e,void 0,i)})}transformPoints(t){let e=[];for(let i=0;i<t.length;i++)e.push(...t[i],0);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return g(this,null,function*(){let e=this.geometry=new Pt;if(this.updatePoints(t),!this.texture){let o=this.texture=yield this.loadTexture(this.config.texture_url);o.wrapS=o.wrapT=Vu}let i=this.material=new ni({useMap:!0,color:new Nu(this.config.color),transparent:!0,resolution:new Io(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!1,sizeAttenuation:!1,lineWidth:this.config.lineWidth*2,map:this.texture,blending:ju,repeat:new Io(this.getRepeat(),1)}),s=this.mesh=new Wu(e,i);return s.renderOrder=99999,this.add(s),s})}dispose(){var t,e,i;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.texture)==null||i.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=na,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let i=this.navigation.bmap.context.camera.zoom;i!==this.prevCameraZoom&&(this.prevCameraZoom=i,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:i,height:s}=this.navigation.bmap.context.clientSize;this.material.resolution.set(i,s)}},this.config=Object.assign({},na,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};import{Tween as Bo,Easing as im}from"@tweenjs/tween.js";import{Vector2 as sm,Vector3 as Rt}from"three";import"core-js/modules/es.array.unshift.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Vector2 as Go}from"three";import{Tween as Ku}from"@tweenjs/tween.js";import{throttle as Xu}from"lodash";import{booleanPointInPolygon as Yu,point as qu,polygon as $u}from"@turf/turf";var Ju={offsetDistance:15,offsetToResetTime:3e3,directionEmitThreshold:5,simulationSpeed:1,destinationDistanceThreshold:10},Es=class extends st{get curRoutePath(){return this.paths[this.routeIndex]||null}get curRoutePathPoints(){var t;return((t=this.curRoutePath)==null?void 0:t.points)||[]}registryEvent(){this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.addEventListener("add-path",this.onAddPaths)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.removeEventListener("add-path",this.onAddPaths)}setRoadData(t){this.roadData=t}resetStatus(t){this.offset=!1,this.reset=!1,this.routeIndex=0,this.pointIndex=0,this.offsetDistance=0,this.resetTimer&&(this.timer.clearTimeout(this.resetTimer),this.resetTimer=null),t.length&&(this.position=t[0].points[0])}emitNavigationStatus(){let t=this.getNavigationInfo();t&&this.dispatchEvent({type:"navigation-info",info:t})}adsorb(t,e){let{curRoutePathPoints:i,position:s,curRoutePath:o,paths:n,routeIndex:r}=this;if(!i.length)return null;let h=i,c=this.paths[this.routeIndex].floor,l=this.getCurRouteRemainDistance();if(s){let m=Vt(i,s);h=h.slice(m+1),h.unshift(s)}let p=[{floor:o==null?void 0:o.floor,points:h},...n.slice(r+1)],{distance:d,closestPoint:u,index:f,i:x}=p.reduce((m,y,_)=>{if(y.floor!==t)return m;let{distance:P,closestPoint:S,index:E}=y.points.reduce((k,b,G,R)=>{if(!R[G+1])return w({},k,{distance:k.distance===1/0?A(b,e):k.distance});let{distance:O,closestPoint:$}=En(e,b,R[G+1]);if(!this.navigation.options.canBack&&c===t){let nt=[e,...R.slice(G+1)],W=ft(nt);if(l-W>10)return k}return O<k.distance?{distance:O,closestPoint:$,index:G}:k},{distance:1/0,closestPoint:y.points[0],index:0});return P<m.distance?{distance:P,closestPoint:S,index:_,i:E}:m},{distance:1/0,closestPoint:h[0],index:0,i:0});return{distance:d,closestPoint:u,routeIndex:f+r,pointIndex:f===0?x+this.pointIndex:x}}toPosition(t,e){this.actualPosition=e;let i=this.adsorb(t,e);if(!i)return;let{distance:s,closestPoint:o,routeIndex:n,pointIndex:r}=i;this.offsetDistance=s,s>this.options.offsetDistance?(this.offset=!0,this.resetTimer||(this.resetTimer=this.timer.setTimeout(()=>{this.reset=!0,this.resetTimer=null},this.options.offsetToResetTime))):(this.offset=!1,this.reset=!1,this.resetTimer&&(this.timer.clearTimeout(this.resetTimer),this.resetTimer=null)),this.routeIndex=n,this.pointIndex=r,this.position=o,this.emitNavigationStatus()}startSimulation(){this.resetStatus(this.paths),this.emitNavigationStatus(),this.startCurRouteSimulation()}pause(){var t;this.tweenUtil.clear(),(t=this.throttleUpdatePosition)==null||t.cancel(),this.paused=!0}continue(){this.paused=!1,this.startCurRouteSimulation()}startCurRouteSimulation(){return g(this,null,function*(){let{curRoutePath:t}=this;if(!t)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let e=[];return new Promise(i=>{let s=[this.position,...this.curRoutePathPoints.slice(this.pointIndex+1)],o=this.getCurRouteRemainDistance(),n=o/this.options.simulationSpeed,r=this.throttleUpdatePosition=Xu(c=>{let l=xe(s,c.distance);l&&(e.push({floor:t.floor,pos:l}),this.toPosition(t.floor,l))},100),h=this.simulationTween=new Ku({distance:0},this.tweenUtil.group).to({distance:o},n*1e3).onUpdate(r).onComplete(()=>{this.tweenUtil.remove(h),r.flush(),r.cancel(),this.routeIndex+1<this.paths.length?(this.routeIndex++,this.position=this.paths[this.routeIndex].points[0],this.pointIndex=0,setTimeout(()=>{i(this.startCurRouteSimulation())},3e3)):(i(!0),console.log(e,this.routeIndex,this.paths))}).start()})})}changeSimulationSpeed(t){this.options.simulationSpeed=t,this.paused||this.startCurRouteSimulation()}getCurRouteRemainDistance(){let{curRoutePathPoints:t,pointIndex:e,position:i}=this;if(!t.length)return 0;let s=[i,...t.slice(e+1)];return ft(s)}getCurRouteToStartDistance(){let{curRoutePathPoints:t,pointIndex:e,position:i}=this;if(!t.length)return 0;let s=[...t.slice(0,e+1),i];return ft(s)}getRemainDistance(){let t=this.getCurRouteRemainDistance();return{total:this.paths.slice(this.routeIndex+1).reduce((s,o)=>s+o.distance,0)+t,curRoute:t}}getNextDirDistance(){var t;if(!this.position)return null;let{pointIndex:e,curRoutePathPoints:i,position:s,curRoutePath:o}=this,n=e,r=Yt.FRONT,h=(o==null||(t=o.pointInfos[n])==null?void 0:t.crossName)||"",c=0,l=0,p=0;for(;r===Yt.FRONT&&n<=i.length;){let x=i[n],m=i[n+1],y=i[n+2];if(!x||!m)r=Yt.END;else if(c+=A(x,m),!y)r=Yt.END;else{r=Js(x,m,y),l=ge(x,m,y),p=(new Go(y[0]-m[0],y[1]-m[1]).angle()*180/Math.PI-90+360)%360;var d;h=(d=o==null?void 0:o.pointInfos[n+1].crossName)!=null?d:"",n+=1}}i[n]&&(c=A(s,i[n]));let u=Qs(l);if(r===Yt.END&&c<=this.options.directionEmitThreshold)return{dir:r,distance:c,crossName:h,angle:l,nextAngle:p,nextDir:u};let f=this.getCurRouteToStartDistance();return e===0&&f<=5?{dir:Yt.START,distance:c,crossName:h,angle:l,nextAngle:p,nextDir:u}:(c>=this.options.directionEmitThreshold&&(r=Yt.FRONT),{dir:r,distance:c,crossName:h,angle:l,nextAngle:p,nextDir:u})}calcReverseAngle(t){let e=t!=null?t:this.actualPosition;if(!e||!this.position)return null;let{curRoutePathPoints:i,pointIndex:s}=this,o=this.position;if(!i.length)return null;let n=o,r=null;if(i[s+1]?r=i[s+1]:i[s-1]&&(n=i[s-1],r=o),!r)return null;let h=new Go(r[0]-n[0],r[1]-n[1]),c=new Go(e[0]-o[0],e[1]-o[1]);return h.length()===0||c.length()===0?null:h.angleTo(c)*180/Math.PI}getCurPointAreaInfo(){let t=this.roadData.find(e=>e.floor===this.paths[this.routeIndex].floor);if(t){let e=(t.areas||[]).find(i=>{let s=$u(i.cds),o=qu(this.position);return Yu(o,s)});if(e)return e}return{imageUrl:null}}getNavigationInfo(){let{total:t,curRoute:e}=this.getRemainDistance(),i=this.getNextDirDistance();if(!i)return null;let{dir:s,distance:o,crossName:n,angle:r,nextAngle:h,nextDir:c}=i;e<=this.options.destinationDistanceThreshold&&(s=Yt.END);let{imageUrl:l}=this.getCurPointAreaInfo(),p=this.calcReverseAngle();return{distance:t,curRouteDistance:e,nextDirDistance:o,dir:s,angle:r,nextAngle:h,pos:this.position,routeIndex:this.routeIndex,crossName:n,offset:this.offset,reset:this.reset,imageUrl:l,nextDir:c,offsetDistance:this.offsetDistance,reverseAngle:p}}dispose(){this.timer.dispose(),this.unRegistryEvent(),this.tweenUtil.clear(),this.navigation=null}constructor(t,e,i){super(),this.navigation=t,this.offset=!1,this.reset=!1,this.position=[0,0],this.routeIndex=0,this.pointIndex=0,this.paths=[],this.timer=new K,this.resetTimer=null,this.tweenUtil=new ie,this.paused=!1,this.offsetDistance=0,this.actualPosition=null,this.onAddPaths=s=>{let{paths:o}=s;this.paths=o,this.resetStatus(o),this.simulationTween&&!this.paused&&this.startSimulation()},this.onUpdate=()=>{this.tweenUtil.update()},this.options=Object.assign({},Ju,e),this.roadData=i,this.registryEvent()}};import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.typed-array.from.js";import"core-js/modules/web.dom-collections.iterator.js";import{DataTexture as Qu,LinearFilter as ra,RGBAFormat as aa,Sprite as tm,SpriteMaterial as em}from"three";var Jt=class a extends et{addDebug(){a.canvas.style.cssText=`
626
+ `);var ni=class extends oa{constructor(t){super({uniforms:Object.assign({},Gu.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new Bu(16777215)},opacity:{value:1},resolution:{value:new ia(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new ia(1,1)},thresholdRatio:{value:0},transparent:{value:!0},depthTest:{vale:!1},depthWrite:{value:!1}}),vertexShader:_t.meshline_vert,fragmentShader:_t.meshline_frag}),this.isMeshLineMaterial=!0,this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(e){this.uniforms.useDash.value=e}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(e){this.uniforms.repeat.value.copy(e)}},thresholdRatio:{enumerable:!0,get:function(){return this.uniforms.thresholdRatio.value},set:function(e){this.uniforms.thresholdRatio.value=e}}}),this.setValues(t)}};ni.prototype.copy=function(a){return oa.prototype.copy.call(this,a),this.lineWidth=a.lineWidth,this.map=a.map,this.useMap=a.useMap,this.alphaMap=a.alphaMap,this.useAlphaMap=a.useAlphaMap,this.color.copy(a.color),this.opacity=a.opacity,this.resolution.copy(a.resolution),this.sizeAttenuation=a.sizeAttenuation,this.dashArray.copy(a.dashArray),this.dashOffset.copy(a.dashOffset),this.dashRatio.copy(a.dashRatio),this.useDash=a.useDash,this.visibility=a.visibility,this.alphaTest=a.alphaTest,this.repeat.copy(a.repeat),this};var na={texture_url:Di,lineWidth:10,color:16777215},Ms=class extends Uu{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:i,height:s}}}}}=this,o=t.map(r=>{let[h,c]=r;return L(new Zu(h,c,0),e,i,s)}).map(r=>{let{x:h,y:c}=r;return[h,c]});return ft(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new Io(t,1)}loadTexture(t){return new Promise((e,i)=>{new Hu().load(t,e,void 0,i)})}transformPoints(t){let e=[];for(let i=0;i<t.length;i++)e.push(...t[i],0);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return g(this,null,function*(){let e=this.geometry=new Pt;if(this.updatePoints(t),!this.texture){let o=this.texture=yield this.loadTexture(this.config.texture_url);o.wrapS=o.wrapT=Vu}let i=this.material=new ni({useMap:!0,color:new Nu(this.config.color),transparent:!0,resolution:new Io(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!1,sizeAttenuation:!1,lineWidth:this.config.lineWidth*2,map:this.texture,blending:ju,repeat:new Io(this.getRepeat(),1)}),s=this.mesh=new Wu(e,i);return s.renderOrder=99999,this.add(s),s})}dispose(){var t,e,i;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.texture)==null||i.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=na,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let i=this.navigation.bmap.context.camera.zoom;i!==this.prevCameraZoom&&(this.prevCameraZoom=i,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:i,height:s}=this.navigation.bmap.context.clientSize;this.material.resolution.set(i,s)}},this.config=Object.assign({},na,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};import{Tween as Bo,Easing as im}from"@tweenjs/tween.js";import{Vector2 as sm,Vector3 as Rt}from"three";import"core-js/modules/es.array.unshift.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Vector2 as Go}from"three";import{Tween as Ku}from"@tweenjs/tween.js";import{throttle as Xu}from"lodash";import{booleanPointInPolygon as Yu,point as qu,polygon as $u}from"@turf/turf";var Ju={offsetDistance:15,offsetToResetTime:3e3,directionEmitThreshold:5,simulationSpeed:1,destinationDistanceThreshold:10},Es=class extends st{get curRoutePath(){return this.paths[this.routeIndex]||null}get curRoutePathPoints(){var t;return((t=this.curRoutePath)==null?void 0:t.points)||[]}registryEvent(){this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.addEventListener("add-path",this.onAddPaths)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.removeEventListener("add-path",this.onAddPaths)}setRoadData(t){this.roadData=t}resetStatus(t){this.offset=!1,this.reset=!1,this.routeIndex=0,this.pointIndex=0,this.offsetDistance=0,this.resetTimer&&(this.timer.clearTimeout(this.resetTimer),this.resetTimer=null),t.length&&(this.position=t[0].points[0])}emitNavigationStatus(){let t=this.getNavigationInfo();t&&this.dispatchEvent({type:"navigation-info",info:t})}adsorb(t,e){let{curRoutePathPoints:i,position:s,curRoutePath:o,paths:n,routeIndex:r}=this;if(!i.length)return null;let h=i,c=this.paths[this.routeIndex].floor,l=this.getCurRouteRemainDistance();if(s){let m=Vt(i,s);h=h.slice(m+1),h.unshift(s)}let p=[{floor:o==null?void 0:o.floor,points:h},...n.slice(r+1)],{distance:d,closestPoint:u,index:f,i:x}=p.reduce((m,y,_)=>{if(y.floor!==t)return m;let{distance:P,closestPoint:S,index:E}=y.points.reduce((k,M,G,R)=>{if(!R[G+1])return w({},k,{distance:k.distance===1/0?A(M,e):k.distance});let{distance:O,closestPoint:$}=En(e,M,R[G+1]);if(!this.navigation.options.canBack&&c===t){let nt=[e,...R.slice(G+1)],W=ft(nt);if(l-W>10)return k}return O<k.distance?{distance:O,closestPoint:$,index:G}:k},{distance:1/0,closestPoint:y.points[0],index:0});return P<m.distance?{distance:P,closestPoint:S,index:_,i:E}:m},{distance:1/0,closestPoint:h[0],index:0,i:0});return{distance:d,closestPoint:u,routeIndex:f+r,pointIndex:f===0?x+this.pointIndex:x}}toPosition(t,e){this.actualPosition=e;let i=this.adsorb(t,e);if(!i)return;let{distance:s,closestPoint:o,routeIndex:n,pointIndex:r}=i;this.offsetDistance=s,s>this.options.offsetDistance?(this.offset=!0,this.resetTimer||(this.resetTimer=this.timer.setTimeout(()=>{this.reset=!0,this.resetTimer=null},this.options.offsetToResetTime))):(this.offset=!1,this.reset=!1,this.resetTimer&&(this.timer.clearTimeout(this.resetTimer),this.resetTimer=null)),this.routeIndex=n,this.pointIndex=r,this.position=o,this.emitNavigationStatus()}startSimulation(){this.resetStatus(this.paths),this.emitNavigationStatus(),this.startCurRouteSimulation()}pause(){var t;this.tweenUtil.clear(),(t=this.throttleUpdatePosition)==null||t.cancel(),this.paused=!0}continue(){this.paused=!1,this.startCurRouteSimulation()}startCurRouteSimulation(){return g(this,null,function*(){let{curRoutePath:t}=this;if(!t)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let e=[];return new Promise(i=>{let s=[this.position,...this.curRoutePathPoints.slice(this.pointIndex+1)],o=this.getCurRouteRemainDistance(),n=o/this.options.simulationSpeed,r=this.throttleUpdatePosition=Xu(c=>{let l=xe(s,c.distance);l&&(e.push({floor:t.floor,pos:l}),this.toPosition(t.floor,l))},100),h=this.simulationTween=new Ku({distance:0},this.tweenUtil.group).to({distance:o},n*1e3).onUpdate(r).onComplete(()=>{this.tweenUtil.remove(h),r.flush(),r.cancel(),this.routeIndex+1<this.paths.length?(this.routeIndex++,this.position=this.paths[this.routeIndex].points[0],this.pointIndex=0,setTimeout(()=>{i(this.startCurRouteSimulation())},3e3)):(i(!0),console.log(e,this.routeIndex,this.paths))}).start()})})}changeSimulationSpeed(t){this.options.simulationSpeed=t,this.paused||this.startCurRouteSimulation()}getCurRouteRemainDistance(){let{curRoutePathPoints:t,pointIndex:e,position:i}=this;if(!t.length)return 0;let s=[i,...t.slice(e+1)];return ft(s)}getCurRouteToStartDistance(){let{curRoutePathPoints:t,pointIndex:e,position:i}=this;if(!t.length)return 0;let s=[...t.slice(0,e+1),i];return ft(s)}getRemainDistance(){let t=this.getCurRouteRemainDistance();return{total:this.paths.slice(this.routeIndex+1).reduce((s,o)=>s+o.distance,0)+t,curRoute:t}}getNextDirDistance(){var t;if(!this.position)return null;let{pointIndex:e,curRoutePathPoints:i,position:s,curRoutePath:o}=this,n=e,r=Yt.FRONT,h=(o==null||(t=o.pointInfos[n])==null?void 0:t.crossName)||"",c=0,l=0,p=0;for(;r===Yt.FRONT&&n<=i.length;){let x=i[n],m=i[n+1],y=i[n+2];if(!x||!m)r=Yt.END;else if(c+=A(x,m),!y)r=Yt.END;else{r=Js(x,m,y),l=ge(x,m,y),p=(new Go(y[0]-m[0],y[1]-m[1]).angle()*180/Math.PI-90+360)%360;var d;h=(d=o==null?void 0:o.pointInfos[n+1].crossName)!=null?d:"",n+=1}}i[n]&&(c=A(s,i[n]));let u=Qs(l);if(r===Yt.END&&c<=this.options.directionEmitThreshold)return{dir:r,distance:c,crossName:h,angle:l,nextAngle:p,nextDir:u};let f=this.getCurRouteToStartDistance();return e===0&&f<=5?{dir:Yt.START,distance:c,crossName:h,angle:l,nextAngle:p,nextDir:u}:(c>=this.options.directionEmitThreshold&&(r=Yt.FRONT),{dir:r,distance:c,crossName:h,angle:l,nextAngle:p,nextDir:u})}calcReverseAngle(t){let e=t!=null?t:this.actualPosition;if(!e||!this.position)return null;let{curRoutePathPoints:i,pointIndex:s}=this,o=this.position;if(!i.length)return null;let n=o,r=null;if(i[s+1]?r=i[s+1]:i[s-1]&&(n=i[s-1],r=o),!r)return null;let h=new Go(r[0]-n[0],r[1]-n[1]),c=new Go(e[0]-o[0],e[1]-o[1]);return h.length()===0||c.length()===0?null:h.angleTo(c)*180/Math.PI}getCurPointAreaInfo(){let t=this.roadData.find(e=>e.floor===this.paths[this.routeIndex].floor);if(t){let e=(t.areas||[]).find(i=>{let s=$u(i.cds),o=qu(this.position);return Yu(o,s)});if(e)return e}return{imageUrl:null}}getNavigationInfo(){let{total:t,curRoute:e}=this.getRemainDistance(),i=this.getNextDirDistance();if(!i)return null;let{dir:s,distance:o,crossName:n,angle:r,nextAngle:h,nextDir:c}=i;e<=this.options.destinationDistanceThreshold&&(s=Yt.END);let{imageUrl:l}=this.getCurPointAreaInfo(),p=this.calcReverseAngle();return{distance:t,curRouteDistance:e,nextDirDistance:o,dir:s,angle:r,nextAngle:h,pos:this.position,routeIndex:this.routeIndex,crossName:n,offset:this.offset,reset:this.reset,imageUrl:l,nextDir:c,offsetDistance:this.offsetDistance,reverseAngle:p}}dispose(){this.timer.dispose(),this.unRegistryEvent(),this.tweenUtil.clear(),this.navigation=null}constructor(t,e,i){super(),this.navigation=t,this.offset=!1,this.reset=!1,this.position=[0,0],this.routeIndex=0,this.pointIndex=0,this.paths=[],this.timer=new K,this.resetTimer=null,this.tweenUtil=new ie,this.paused=!1,this.offsetDistance=0,this.actualPosition=null,this.onAddPaths=s=>{let{paths:o}=s;this.paths=o,this.resetStatus(o),this.simulationTween&&!this.paused&&this.startSimulation()},this.onUpdate=()=>{this.tweenUtil.update()},this.options=Object.assign({},Ju,e),this.roadData=i,this.registryEvent()}};import"core-js/modules/es.typed-array.uint8-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.typed-array.from.js";import"core-js/modules/web.dom-collections.iterator.js";import{DataTexture as Qu,LinearFilter as ra,RGBAFormat as aa,Sprite as tm,SpriteMaterial as em}from"three";var Jt=class a extends et{addDebug(){a.canvas.style.cssText=`
627
627
  position: fixed;
628
628
  top: 0;
629
629
  left: 0;
630
630
  z-index: 9999;
631
- `,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new tm(new em({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new Qu(Uint8Array.from(t.data),e[0],e[1],aa);return i.format=aa,i.magFilter=ra,i.minFilter=ra,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};Jt.canvas=document.createElement("canvas");Jt.ctx=Jt.canvas.getContext("2d",{willReadFrequently:!0});Jt.textureMap=new Map;var om={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},ha=class extends N{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(lt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new Jt(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(lt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new bs(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new et(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ii(this.bmap.context,new Rt(e[0][0],e[0][1],.51),new Rt(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new et(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return _i(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=Vt(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new Rt(i[0]-e[0],i[1]-e[1],0).normalize(),o=new Rt(0,1,0).normalize(),n=s.angleTo(o),r=new Rt().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=Vt(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new sm(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return g(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return Mt(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new Bo(h,this.tweenUtil.group).to(c,n).easing(im.Quadratic.InOut).onUpdate(()=>g(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return g(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>Mt(g(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return g(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=L(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new Rt;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new Rt(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new Rt;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new Rt(d.x,d.y,0))}return Mt(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let f=new Bo(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(f),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return g(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,r=e/(o.x-n.x),h=i/(o.y-n.y),l=(r>h?e:i)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(l,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return g(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=Cn(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),Mt(new Promise(l=>{let p=this.pathTween=new Bo({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>g(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return g(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=xe(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new et(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ii(this.bmap.context,new Rt(e.x,e.y,.51),new Rt(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let e=this.getPathDirection2(),i=t;if(e!==null){let r=(360-e)%360,h=t-r;for(;h>180;)h-=360;for(;h<-180;)h+=360;let c=Math.abs(h);this.isStartPoiSnapped?c>40?(this.isStartPoiSnapped=!1,i=t):i=r:c<=30?(this.isStartPoiSnapped=!0,i=r):i=t}let o=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,n=(360-i-o)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=n),this.startPoi&&(this.startPoi.options.icon_rotate=n,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(n))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),Jt.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.isStartPoiSnapped=!1,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new ie,this.taskQueue=new Pe,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},om,i),this.positionNavigation=new Es(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Group as nm,Color as ca}from"three";var la=class extends N{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new ca((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.setVisible(!1);return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new ca((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.setVisible(!0),i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.floors=[],this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new nm,this.showStatus=!1,this.group.name="mul-floor-group"}};import{EventDispatcher as rm}from"three";import{merge as am}from"lodash";function zo(){return new Worker(new URL("./worker/path.worker-WHXPOQDZ.js",import.meta.url))}var pa={useWorker:!1,lift_priority:3},Ss=class extends rm{setLiftPriority(t){return g(this,null,function*(){var e;(e=this.roadNetwork)==null||e.setLiftPriority(t),this.worker&&(yield H(this.worker,"onSetLiftPriority",t))})}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return g(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),this.roadNetwork&&this.roadNetwork.initRoute(t,e),this.worker&&(yield H(this.worker,"set_road_info",{roadData:t,facilities:e})),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return g(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>g(this,null,function*(){yield this.loaded();function c(l){l?typeof l=="string"?h(l):r(l):h("no-path")}if(this.roadNetwork){let l=this.roadNetwork.getPath(t,e,i,s,o,n);c(l)}else if(this.worker){let l=yield H(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n});c(l)}else console.log("\u6CA1\u6709\u521D\u59CB\u5316\u8DEF\u7F51"),h("no-road-network")}))})}getDirectionPath(t){return g(this,null,function*(){return this.worker?H(this.worker,"get_direction_path",t):Sn(t)})}dispose(){return g(this,null,function*(){this.roadNetwork&&this.roadNetwork.clear(),this.worker&&(yield H(this.worker,"clear",""),this.worker.terminate())})}constructor(t=pa){super(),this.worker=null,this.initRoadStatus=!1,this.roadNetwork=null,this.options=am({},pa,t),this.options.useWorker?(this.worker=zo(),H(this.worker,"set_lift_priority",this.options.lift_priority)):this.roadNetwork=new we(this.options.lift_priority)}};import{EventDispatcher as hm}from"three";function Wo(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",import.meta.url))}var da=class extends hm{setRoadData(t){return g(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield H(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return g(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{H(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return H(this.worker,"get_direction_path",t)}dispose(){return g(this,null,function*(){H(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=Wo(),this.initRoadStatus=!1}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{Frustum as cm}from"three";var Cs=class extends dt{setEnable(t){super.setEnable(t),j(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=L(this.startPoint,e,i,s),n=L(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof Y&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=L(d,s,o,n);return te(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=L(h,s,o,n),p=L(c,s,o,n);return!(!te(l,e,i)||!te(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new cm,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);j(this.rect,n.x,n.y,r,h)}else j(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=gt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var lm={boxSelection:!1,elements:["graphic","poi"]},ua=class extends N{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let f=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;f&&(h.add(d.options.id),c.push(f))}})}(!this.options.boxSelection||!(re?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{ve(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{ve(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},lm,e),this.boxSelection=new Cs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.array.push.js";import{cloneDeep as pm,isNil as oe,throttle as ma}from"lodash";var B=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var dm={time:1e3,elements:[B.COMPASS,B.DEVICE_MOTION,B.ACCELERATION,B.GPS]},Ts=class extends st{start(){this.options.elements.some(t=>[B.DEVICE_MOTION,B.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(B.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(B.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:pm(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){ee?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:B.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return g(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return g(this,null,function*(){var t;if(!ee)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),ee?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),oe(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new K,this.dispatchTimer=null,this.addAcceleration=ma(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=ma(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if(oe(s)||oe(o)||oe(n))return;let r;ee?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(B.DEVICE_MOTION)&&this.addDataItem({type:B.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(B.COMPASS)&&this.addDataItem({type:B.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;oe(i)||oe(i.x)||oe(i.y)||oe(i.z)||this.addAcceleration({type:B.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},dm,t)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";function Ls(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function ri(a){return(a+360)%360}function fa(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function Fe(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var ks=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=ri(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=ri(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=ri(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=Ls(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=Fe(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Ls(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=Fe(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*Ls(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=Fe(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=ri(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";var As=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var um={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},Ds=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===B.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===B.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===B.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===B.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===B.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===B.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:fa(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=Fe(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},um,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new ks({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new As}};import{booleanPointInPolygon as mm,point as fm}from"@turf/turf";var Rs=class extends st{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&mm(fm([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===B.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new Ts(e.sensor),this.pdr=new Ds(e.pdr||{})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Object3D as ym,TextureLoader as vm,Color as xm,Vector2 as Uo,Vector3 as wm,NormalBlending as _m,RepeatWrapping as Pm,Box3 as Mm}from"three";import{ShaderLib as Os,ShaderMaterial as gm,UniformsLib as Fs,UniformsUtils as ya,Vector2 as ga}from"three";Fs["custom-line"]={linewidth:{value:1},resolution:{value:new ga(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new ga(1,1)},allDistance:{value:1}};Os["custom-line"]={uniforms:ya.merge([Fs.common,Fs.fog,Fs["custom-line"]]),vertexShader:`
631
+ `,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new tm(new em({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new Qu(Uint8Array.from(t.data),e[0],e[1],aa);return i.format=aa,i.magFilter=ra,i.minFilter=ra,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};Jt.canvas=document.createElement("canvas");Jt.ctx=Jt.canvas.getContext("2d",{willReadFrequently:!0});Jt.textureMap=new Map;var om={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},ha=class extends N{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(lt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new Jt(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(lt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new Ms(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new et(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ii(this.bmap.context,new Rt(e[0][0],e[0][1],.51),new Rt(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new et(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return _i(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=Vt(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new Rt(i[0]-e[0],i[1]-e[1],0).normalize(),o=new Rt(0,1,0).normalize(),n=s.angleTo(o),r=new Rt().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=Vt(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new sm(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return g(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return bt(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new Bo(h,this.tweenUtil.group).to(c,n).easing(im.Quadratic.InOut).onUpdate(()=>g(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return g(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>bt(g(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return g(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=L(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new Rt;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new Rt(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new Rt;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new Rt(d.x,d.y,0))}return bt(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let f=new Bo(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(f),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return g(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,r=e/(o.x-n.x),h=i/(o.y-n.y),l=(r>h?e:i)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(l,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return g(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=Cn(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),bt(new Promise(l=>{let p=this.pathTween=new Bo({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>g(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return g(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=xe(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new et(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ii(this.bmap.context,new Rt(e.x,e.y,.51),new Rt(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let e=this.getPathDirection2(),i=t;if(e!==null){let r=(360-e)%360,h=t-r;for(;h>180;)h-=360;for(;h<-180;)h+=360;let c=Math.abs(h);this.isStartPoiSnapped?c>40?(this.isStartPoiSnapped=!1,i=t):i=r:c<=30?(this.isStartPoiSnapped=!0,i=r):i=t}let o=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,n=(360-i-o)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=n),this.startPoi&&(this.startPoi.options.icon_rotate=n,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(n))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),Jt.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.isStartPoiSnapped=!1,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new ie,this.taskQueue=new Pe,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},om,i),this.positionNavigation=new Es(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Group as nm,Color as ca}from"three";var la=class extends N{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new ca((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.setVisible(!1);return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new ca((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.setVisible(!0),i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.floors=[],this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new nm,this.showStatus=!1,this.group.name="mul-floor-group"}};import{EventDispatcher as rm}from"three";import{merge as am}from"lodash";function zo(){return new Worker(new URL("./worker/path.worker-WHXPOQDZ.js",import.meta.url))}var pa={useWorker:!1,lift_priority:3},Ss=class extends rm{setLiftPriority(t){return g(this,null,function*(){var e;(e=this.roadNetwork)==null||e.setLiftPriority(t),this.worker&&(yield H(this.worker,"onSetLiftPriority",t))})}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return g(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),this.roadNetwork&&this.roadNetwork.initRoute(t,e),this.worker&&(yield H(this.worker,"set_road_info",{roadData:t,facilities:e})),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return g(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>g(this,null,function*(){yield this.loaded();function c(l){l?typeof l=="string"?h(l):r(l):h("no-path")}if(this.roadNetwork){let l=this.roadNetwork.getPath(t,e,i,s,o,n);c(l)}else if(this.worker){let l=yield H(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n});c(l)}else console.log("\u6CA1\u6709\u521D\u59CB\u5316\u8DEF\u7F51"),h("no-road-network")}))})}getDirectionPath(t){return g(this,null,function*(){return this.worker?H(this.worker,"get_direction_path",t):Sn(t)})}dispose(){return g(this,null,function*(){this.roadNetwork&&this.roadNetwork.clear(),this.worker&&(yield H(this.worker,"clear",""),this.worker.terminate())})}constructor(t=pa){super(),this.worker=null,this.initRoadStatus=!1,this.roadNetwork=null,this.options=am({},pa,t),this.options.useWorker?(this.worker=zo(),H(this.worker,"set_lift_priority",this.options.lift_priority)):this.roadNetwork=new we(this.options.lift_priority)}};import{EventDispatcher as hm}from"three";function Wo(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",import.meta.url))}var da=class extends hm{setRoadData(t){return g(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield H(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return g(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{H(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return H(this.worker,"get_direction_path",t)}dispose(){return g(this,null,function*(){H(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=Wo(),this.initRoadStatus=!1}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{Frustum as cm}from"three";var Cs=class extends dt{setEnable(t){super.setEnable(t),j(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=L(this.startPoint,e,i,s),n=L(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof Y&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=L(d,s,o,n);return te(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=L(h,s,o,n),p=L(c,s,o,n);return!(!te(l,e,i)||!te(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new cm,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);j(this.rect,n.x,n.y,r,h)}else j(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=gt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var lm={boxSelection:!1,elements:["graphic","poi"]},ua=class extends N{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let f=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;f&&(h.add(d.options.id),c.push(f))}})}(!this.options.boxSelection||!(re?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{ve(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{ve(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},lm,e),this.boxSelection=new Cs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.array.push.js";import{cloneDeep as pm,isNil as oe,throttle as ma}from"lodash";var B=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var dm={time:1e3,elements:[B.COMPASS,B.DEVICE_MOTION,B.ACCELERATION,B.GPS]},Ts=class extends st{start(){this.options.elements.some(t=>[B.DEVICE_MOTION,B.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(B.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(B.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:pm(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){ee?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:B.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return g(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return g(this,null,function*(){var t;if(!ee)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),ee?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),oe(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new K,this.dispatchTimer=null,this.addAcceleration=ma(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=ma(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if(oe(s)||oe(o)||oe(n))return;let r;ee?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(B.DEVICE_MOTION)&&this.addDataItem({type:B.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(B.COMPASS)&&this.addDataItem({type:B.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;oe(i)||oe(i.x)||oe(i.y)||oe(i.z)||this.addAcceleration({type:B.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},dm,t)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";function Ls(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function ri(a){return(a+360)%360}function fa(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function Fe(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var ks=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=ri(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=ri(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=ri(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=Ls(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=Fe(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Ls(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=Fe(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*Ls(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=Fe(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=ri(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";var As=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var um={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},Ds=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===B.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===B.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===B.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===B.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===B.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===B.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:fa(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=Fe(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},um,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new ks({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new As}};import{booleanPointInPolygon as mm,point as fm}from"@turf/turf";var Rs=class extends st{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&mm(fm([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===B.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new Ts(e.sensor),this.pdr=new Ds(e.pdr||{})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Object3D as ym,TextureLoader as vm,Color as xm,Vector2 as Uo,Vector3 as wm,NormalBlending as _m,RepeatWrapping as Pm,Box3 as bm}from"three";import{ShaderLib as Os,ShaderMaterial as gm,UniformsLib as Fs,UniformsUtils as ya,Vector2 as ga}from"three";Fs["custom-line"]={linewidth:{value:1},resolution:{value:new ga(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new ga(1,1)},allDistance:{value:1}};Os["custom-line"]={uniforms:ya.merge([Fs.common,Fs.fog,Fs["custom-line"]]),vertexShader:`
632
632
  #include <common>
633
633
  #include <color_pars_vertex>
634
634
  #include <fog_pars_vertex>
@@ -821,4 +821,4 @@ void main() {
821
821
  float uvx = prevUv + (vUv.y + 1.0) / 2.0 * vCustomUv;
822
822
  gl_FragColor = diffuseColor * texture2D(map, vec2(uvx, (vUv.x + 1.0) / 2.0) * repeat);
823
823
  }
824
- `};var Is=class extends gm{constructor(t){super({type:"ArrowLineMaterial",uniforms:Object.assign({},ya.clone(Os["custom-line"].uniforms),{map:{value:null}}),vertexShader:Os["custom-line"].vertexShader,fragmentShader:Os["custom-line"].fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(e){this.uniforms.map.value=e}},color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(e){this.uniforms.repeat.value.copy(e)}},allDistance:{enumerable:!0,get:function(){return this.uniforms.allDistance.value},set:function(e){this.uniforms.allDistance.value=e}}}),this.setValues(t),this.isLineMaterial=!0}};import{LineGeometry as bm}from"three/examples/jsm/lines/LineGeometry.js";import{Line2 as Em}from"three/examples/jsm/lines/Line2.js";var va={texture_url:Di,lineWidth:8,color:16777215},Gs=class extends ym{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:i,height:s}}}}}=this,o=t.map(r=>{let[h,c,l]=r;return L(new wm(h,c,l),e,i,s)}).map(r=>{let{x:h,y:c}=r;return[h,c]});return ft(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new Uo(t,1)}loadTexture(t){return new Promise((e,i)=>{new vm().load(t,e,void 0,i)})}transformPoints(t){let e=[];for(let i=0;i<t.length;i++)e.push(...t[i]);return e}updatePoints(t){if(this.points=t,this.mesh){var e,i;this.remove(this.mesh),(e=this.material)==null||e.dispose(),(i=this.geometry)==null||i.dispose()}this.geometry=new bm,this.geometry.setPositions(t.flat(2));let s=ft(t.map(r=>{let[h,c]=r;return[h,c]})),o=this.material=new Is({color:new xm(this.config.color),transparent:!0,resolution:new Uo(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,depthWrite:!0,linewidth:this.config.lineWidth,map:this.texture,blending:_m,repeat:new Uo(this.getRepeat(),1),allDistance:s}),n=this.mesh=new Em(this.geometry,o);return n.computeLineDistances(),n.renderOrder=9,this.add(n),n}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return g(this,null,function*(){if(!this.texture){let e=this.texture=yield this.loadTexture(this.config.texture_url);e.wrapS=e.wrapT=Pm}return this.updatePoints(t)})}getBoundingBox(){return this.mesh?(this.mesh.geometry.computeBoundingBox(),new Mm().copy(this.mesh.geometry.boundingBox).applyMatrix4(this.mesh.matrixWorld)):null}dispose(){var t,e,i;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.texture)==null||i.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=va,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let i=this.navigation.bmap.context.camera.zoom;i!==this.prevCameraZoom&&(this.prevCameraZoom=i,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:i,height:s}=this.navigation.bmap.context.clientSize;this.material.resolution.set(i,s)}},this.config=Object.assign({},va,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};import{Tween as Am}from"@tweenjs/tween.js";import{AnimationMixer as Sm,Box3 as Cm,Object3D as xa,Vector3 as Tm,Mesh as Lm,Euler as km}from"three";var Bs=class extends xa{meshSetMaterial(t){t instanceof Lm&&(t.material.emissiveIntensity=.5,t.material.shininess=0,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map,t.material.transparent=!0,t.material.depthTest=!1,t.renderOrder=1e6),t.children.forEach(i=>{this.meshSetMaterial(i)})}getBaseScale(t){let{clientSize:{height:e},camera:i}=this.bmap.context,o=(i.top-i.bottom)/i.zoom/e;return this.options.size*o/this.modelMaxLength}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}lookAtCamera(){if(this.model&&this.bmap&&this.bmap.context){let t=this.bmap.context.camera,e=new km;e.setFromQuaternion(t.quaternion,"ZYX"),this.group.rotation.copy(e)}}setClips(t){this.clearClips(),t.length&&(this.mixer=new Sm(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&F(this.model.scene),this.bmap=null}constructor(t,e,i={}){super(),this.bmap=t,this.group=new xa,this.mixer=null,this.previewTime=0,this.modelMaxLength=0,this.options={size:40},this._update=()=>{let s=Date.now();if(!this.previewTime)this.previewTime=s;else{var o;let n=s-this.previewTime;this.previewTime=s,(o=this.mixer)==null||o.update(n/1e3)}this.lookAtCamera()},this._onChangeZoom=s=>{let{zoom:o}=s;var n;if(!this.model)return;let r=this.getBaseScale(this.model.scene);(n=this.model)==null||n.scene.scale.set(r,r,r)},this.options=w({},this.options,i),this.add(this.group),pt.loadModel(e,!1).then(s=>{this.model=s;let n=new Cm().setFromObject(s.scene).getSize(new Tm),r=Math.max(n.x,n.y,n.z);this.modelMaxLength=r;let h=this.getBaseScale(s.scene);s.scene.scale.set(h,h,h),this.meshSetMaterial(s.scene),this.group.add(s.scene),this.setClips(s.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};import{Vector3 as Ho}from"three";var wa=class extends N{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(i=>w({},i,{points:this.translatePoints(i.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let i=()=>{this.bmap.removeEventListener("center-change",i),this.renderPath(e)};this.bmap.addEventListener("center-change",i)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){return g(this,null,function*(){if(!t.length)return this.clearPath();let e=[];t.forEach((i,s,o)=>{let n=this.mulFloor.floors.find(r=>r.name===i.floor);e.push(...i.points.map(r=>{let[h,c]=r;return[h,c,n.position.z+n.groundMaxHeight]}))}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new Gs(this),yield this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})})}catmullRomCurve3(t){return _i(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let i=Vt(t,e),s=t[i],o=t[i+1],n=new Ho(o[0]-s[0],o[1]-s[1],0).normalize(),r=new Ho(0,1,0).normalize(),h=n.angleTo(r),c=new Ho().crossVectors(r,n);return(Object.is(c.y,0)?-1:1)*h}startSimulation(t){return g(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:i}=this;if(!e.length)return;let s=e.reduce((n,r)=>n+r.distance,0);if(!s||i>=s)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=s/t;return this.startModel.startClips(),new Promise(n=>{let r=this.simulationTween=new Am({distance:this.movedDistance},this.tweenUtil.group).to({distance:s},o*1e3).onUpdate(h=>{var c;this.movedDistance=h.distance;let l=h.distance,p=0;for(let m=0;m<e.length;m++)if(e[m].distance>=l){p=m;break}else l-=e[m].distance;let d=xe(e[p].points,l);if(d===null)return;this.currentPathPosition=d;let u=this.translatePoints([d])[0],f=this.mulFloor.floors.find(m=>m.name===e[p].floor),x=f?f.position.z+f.groundMaxHeight:(c=this.startModel)==null?void 0:c.position.z;this.startModel&&this.startModel.position.set(u[0],u[1],x)}).onComplete(()=>{if(this.tweenUtil.remove(r),this.startModel.clearClips(),this.startModel){var h,c,l,p;let d=(l=e.slice(-1)[0])==null||(c=l.points)==null||(h=c.slice(-1))==null?void 0:h[0];if(!d)return;let u=this.mulFloor.floors.find(m=>{var y;return m.name===((y=e.slice(-1)[0])==null?void 0:y.floor)});if(!u)return;let f=u?u.position.z+u.groundMaxHeight:(p=this.startModel)==null?void 0:p.position.z,x=this.translatePoints([d])[0];this.startModel.position.set(x[0],x[1],f)}n(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-i)%360}}dispose(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent(),super.dispose()}constructor(t,e,i={}){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new ie,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Bs(t,lr,i.startModel),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Raycaster as Dm,Vector2 as Rm}from"three";var _a=class extends N{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose(),this.mulFloors=null,super.dispose()}constructor(t,e){super(t),this.mulFloors=e,this._click=i=>{let{e:s}=i;if(!this.mulFloors.showStatus)return;let o=new Rm,{offsetX:n,offsetY:r}=s,h=this.mulFloors.floors.map(d=>d.poiLayer2.getPoiByDeviceXy(n,r)).flat(2),{clientSize:c}=this.bmap.context;o.x=n/c.width*2-1,o.y=r/c.height*-2+1;let l=new Dm;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.floors.map(d=>d.graphicLayer.getGraphicByRaycaster(l).graphics).flat();this.dispatchEvent({type:"select",pois:h,graphics:p})},this.clickHelper=new Mi(this.bmap.context.container),this.registryEvent()}};import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.find-last-index.js";import"core-js/modules/es.array.find-last.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.sort.js";import{Vector2 as ai}from"three";function Ma(a){let t=a.length,e=0,i=0,s=0,o=0;a.forEach(c=>{e+=c[0],i+=c[1],s+=c[0]*c[1],o+=c[0]*c[0]});let n=t*o-e*e;if(n===0)return{m:0,b:0};let r=(t*s-e*i)/n,h=(i-r*e)/t;return{m:r,b:h}}function Om(a){let t=a.length,e=0,i=0,s=0,o=0;a.forEach(h=>{e+=h[0],i+=h[1],s+=h[0]*h[1],o+=h[0]*h[0]});let n=(t*s-e*i)/(t*o-e*e),r=(i-n*e)/t;return{m:n,b:r}}function Fm(a,t,e){let i=e[0][0],s=e.slice(-1)[0][0],o=a*i+t,n=a*s+t;return{start:[i,o],end:[s,n]}}function zs(a){if(a.length<2)return null;let t=a.filter((h,c)=>{let l=[...a];return l.splice(c,1),l.every(p=>p[0]!==h[0]&&p[1]!==h[1])});if(t.length<2)return null;let{m:e,b:i}=Om(t),{start:s,end:o}=Fm(e,i,t),r=(360-new ai().subVectors(new ai(o[0],o[1]),new ai(s[0],s[1])).angle()*180/Math.PI)%360;return Number.isNaN(r)?null:r}function NA(a){let t=[];for(let e=1;e<a.length;e++){let i=a[e-1],s=a[e],o=s.position[0]-i.position[0],n=s.position[1]-i.position[1],r=Math.sqrt(o**2+n**2),h=s.time-i.time;if(h>0){let c=r/h;console.log("speedDelta",i.type,s.type,No(c),r,h),t.push(c)}else t.push(0)}return t}function ZA(a,t){let e=a[0],i=a.slice(-1)[0],s=A(i.position,e.position),o=i.time-e.time;return o<100||s<3?null:s/o}function No(a){return a*60*60}function hi(a,t,e,i){let s=(e+90)%360*(Math.PI/180),o=t*i,n=new ai(a[0],a[1]),r=Math.cos(s),h=Math.sin(s),c=new ai(r,h);return n.add(c.normalize().multiplyScalar(o)),[n.x,n.y]}function jA(a){let t=[...a].sort((c,l)=>c-l),e=Pa(t,25),i=Pa(t,75),s=i-e,o=e-1.5*s,n=i+1.5*s,r=t.filter(c=>c>=o&&c<=n);return a.filter(c=>r.includes(c))}function Pa(a,t){let e=t/100*(a.length-1),i=Math.floor(e),s=Math.ceil(e);if(i===s)return a[i];let o=e-i;return a[i]*(1-o)+a[s]*o}import{isNil as Ws}from"lodash";var Us=class extends st{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),Ws(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(m=>["vision"].includes(m.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[t.length-1].time,i=5e3;if(t[t.length-1].clientTime<Date.now()-1e3)return this.speed;let s=t.filter(m=>e-m.time<=i);if(s.length<5)return this.speed;let o=[];for(let m=0;m<s.length;m++){if(m===0){o.push(s[m]);continue}let y=s[m-1],_=s[m];_.time-y.time<2e3&&o.push(_)}if(o.length<2)return this.speed;let n=o[0].time,r=o[0].position,h=o.map((m,y)=>{let _=m.time-n,P=A(m.position,r);return[_,P]}),{m:c}=Ma(h),l=Math.max(c,0),p=15/3600;l>p&&console.warn("\u901F\u5EA6\u8D85\u8FC715km/h:",{speed_m_ms:l,speed_km_h:l*3600,points:o.map((m,y)=>({index:y+1,type:m.type,time:m.time,clientTime:m.clientTime,position:m.position})),relativeTimesAndDistances:h,totalDistance:A(o[o.length-1].position,o[0].position),totalTime:o[o.length-1].time-o[0].time,pointPairs:o.slice(1).map((m,y)=>({prevIndex:y+1,prevType:o[y].type,currIndex:y+2,currType:m.type,timeDiff:m.time-o[y].time,distance:A(m.position,o[y].position)}))});let d=2/1e3,u=Date.now(),f=u-this._lastSpeedUpdateTime;if(this._lastSpeedUpdateTime=u,this.speed!==0&&l!==0){let m=d*f;Math.abs(l-this.speed)>m&&(l=l>this.speed?this.speed+m:this.speed-m)}let x=this.speedFilter.filter(l);this.speed=x}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=zs(t.map(i=>i.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,i){this.lastExternalPositionTime=Date.now();let s={position:t,time:e,clientTime:Date.now()-i,type:"vision"};if(this._setVisionHistoryForAngle(s),Ws(this.angle)||!this.speed){this.addHistory(s);return}let o=this.history.findLastIndex(r=>r.type==="vision"),n=this.history[o];if(n){if(n.time>e)return;let r=zs([this.history.slice(-1)[0].position,t]);if(r&&Math.abs(r-this.angle)<60){this.addHistory(s);return}let h=hi(t,this.speed,360-this.pathAngle,i);A(h,this.history.slice(-1)[0].position)>5?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(s),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=hi(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(i=>i.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(this.visionHistory.length<3){this.visionHistory.push(t);return}let e=zs([...this.visionHistory.slice(-3).map(i=>i.position),t.position]);if(e!==null&&this.angle!==null){let i=Math.abs(this.angle-e),s=Math.min(i,360-i);this.angle&&s>90?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))}if(this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63",e,this.angle,this.pathAngle),this.visionHistory=[t],this.angleExcessesCount=0;else{let i=A(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;i>5&&this.visionHistory.length>15;)this.visionHistory.shift(),i=A(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(r=>r.type==="vision"),i=e.length?Date.now()-e.slice(-1)[0].clientTime:0,s=A(this.history[0].position,this.history.slice(-1)[0].position),o=i>5e3?10:3,n=i>5e3?0:5;for(i>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>n&&s>o;)this.history.shift(),e=this.history.filter(r=>r.type==="vision"),s=A(this.history[0].position,this.history.slice(-1)[0].position);n===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,i){this.lastExternalPositionTime=Date.now();let s=Date.now()-i,o={position:t,time:e,clientTime:s,type:"beacon"},n=this.history.findLastIndex(l=>l.type!=="pdr"),r=this.history[n];if(!r){this.addHistory(o);return}if(Ws(this.pathAngle)||!this.speed){this.addHistory(o);return}if(r&&r.time>e)return;let h=hi(t,this.speed,360-this.pathAngle,i);A(h,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}stopPositionTimer(){this.positionTimer&&(this.timer.clearInterval(this.positionTimer),this.positionTimer=null)}changePosition(t){t===void 0&&(t="pdr");let e=Date.now()-this.lastExternalPositionTime;if(this.lastExternalPositionTime>0&&e>1e4){console.warn("\u8FDE\u7EED10s\u6CA1\u6709\u5916\u90E8\u5B9A\u4F4D\u7ED3\u679C\uFF0C\u505C\u6B62\u53D1\u9001\u60EF\u5BFC\u5B9A\u4F4D\u7ED3\u679C");return}let i=this.getPosition(t);i.success&&(this.history.push({position:i.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:w({},i)}):this.dispatchEvent({type:"change-pos",value:i}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if(Ws(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let i=e.clientTime,s=Date.now()-i;return{success:!0,pos:this.pathAngle?hi(e.position,this.speed,360-this.pathAngle,s):e.position,compass:this.pathAngle,speed:No(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new K,this.positionTimer=null,this.speedFilter=new Ei,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.lastExternalPositionTime=0,this._lastSpeedUpdateTime=0,this.startPositionTimer(),this._lastSpeedUpdateTime=Date.now()}};import"core-js/modules/es.json.stringify.js";function Zo(){return new Worker(new URL("./worker/recommend.worker-PJJHK4IP.js",import.meta.url))}import"core-js/modules/es.array.push.js";var Hs=class{setRoadData(t,e){this.roadNetwork.initRoute(t,e),this.roadReadyResolve(!0)}setRoadNetwork(t){this.roadNetwork=t}recommend(t,e,i,s,o){return g(this,null,function*(){yield this.roadReadyPromise;let n=e.reduce((l,p)=>(l[p.floor]?l[p.floor].push(p):l[p.floor]=[p],l),{}),r=this.roadNetwork.roadInfo.map(l=>l.floor),h=this.transformStart(t);if(!h)return null;let c=i?this.transformEnd(i):null;if(o){let l=e.filter(p=>{let d=this.roadNetwork.getParkingSpaceInfo(p.floor,p.lot_id);return d?d.parkingType===o:!1});if(l.length>0){let p=l.reduce((d,u)=>(d[u.floor]?d[u.floor].push(u):d[u.floor]=[u],d),{});if(c){let d=this.recommendByEnd(h,c,p,r,s);if(d)return d}else{let d=this.recommendByStart(h.floor,h.coord,h.routePointId,p,r,s);if(d)return d}}}return c?this.recommendByEnd(h,c,n,r,s):this.recommendByStart(h.floor,h.coord,h.routePointId,n,r,s)})}dispose(){this.roadNetwork.clear()}getFloorCarByDistance(t,e,i){let{floor:s,coord:o,routePointId:n}=t,r=null;return(e||[]).forEach(h=>{let c=this.roadNetwork.getPath({floor:s,coord:o,routePointId:n},{floor:h.floor,parkingSpace:h.lot_id},"forward",0,i);if(c==="near"){r={floor:h.floor,spaceNo:h.lot_id,distance:0};return}if(!c||typeof c=="string")return;let l={floor:h.floor,spaceNo:h.lot_id,distance:c[0].consume};r||(r=l),r.distance>l.distance&&(r=l)}),r}recommendByStart(t,e,i,s,o,n){let r=this.getFloorCarByDistance({floor:t,coord:e,routePointId:i},s[t],n);return r||this.recommendByStartNearFloor(t,e,i,s,o,n)}recommendByStartNearFloor(t,e,i,s,o,n){let r=o.indexOf(t);r===-1&&(r=o.length);let h=1,c=null;for(;h<=o.length;){if(o.filter((p,d)=>d===r-h||d===r+h).forEach(p=>{let d=this.getFloorCarByDistance({floor:t,coord:e,routePointId:i},s[p],n);c?d&&c.distance>d.distance&&(c=d):c=d}),c)return c;h++}return c}recommendByEnd(t,e,i,s,o){console.time("recommendByEnd");let n=this.recommendFloorCarByEndDistance(t,e,e.floor,i,o);if(n)return n;console.timeEnd("recommendByEnd"),console.time("recommendByStart");let r=this.recommendFloorCarByEndDistance(t,e,t.floor,i,o);return console.timeEnd("recommendByStart"),r||this.recommendByStartNearFloorAndEnd(t,e,t.floor,i,s,o)}recommendFloorCarByEndDistance(t,e,i,s,o){let n=s[i]||[];if(!n.length)return null;let r=null;return n.forEach(h=>{let c=this.roadNetwork.getParkingSpaceInfo(h.floor,h.lot_id);if(!c)return;console.time("path2");let l=this.roadNetwork.getPath({floor:h.floor,routePointId:c.id},e,"",0);if(console.timeEnd("path2"),l==="near"){r={floor:h.floor,spaceNo:h.lot_id,distance:0};return}if(!l||typeof l=="string")return;let p={floor:h.floor,spaceNo:h.lot_id,distance:l[0].consume},d={floor:h.floor,routePointId:c.id};if(r){if(r.distance>p.distance){console.count("forward");let u=this.roadNetwork.getPath(t,d,"forward",0,o);if(!u||typeof u=="string"&&u!=="near")return;r=p}}else{console.count("forward");let u=this.roadNetwork.getPath(t,d,"forward",0,o);if(!u||typeof u=="string"&&u!=="near")return;r=p}}),r}recommendByStartNearFloorAndEnd(t,e,i,s,o,n){let r=o.indexOf(i);r===-1&&(r=o.length);let h=1,c=null;for(;h<=o.length;){if(o.filter((p,d)=>d===r-h||d===r+h).forEach(p=>{let d=this.recommendFloorCarByEndDistance(t,e,p,s,n);c?d&&c.distance>d.distance&&(c=d):c=d}),c)return c;h++}return c}transformStart(t){if(t.routePointId)return{floor:t.floor,routePointId:t.routePointId};if(t.coord)return{floor:t.floor,coord:t.coord};if(t.nodeId){let e=this.roadNetwork.getNodeInfo(t.floor,t.nodeId);if(e)return{floor:e.floor,coord:e.cds}}return null}transformEnd(t){if(t.routePointId&&t.floor)return{floor:t.floor,routePointId:t.routePointId};if(t.coord)return{floor:t.floor,coord:t.coord};if(t.nodeId){let e=this.roadNetwork.getNodeInfo(t.floor,t.nodeId);if(e)return{floor:e.floor,coord:e.cds}}if(t.parkingSpace){let e=this.roadNetwork.getParkingSpaceInfo(t.floor,t.parkingSpace);if(e)return{floor:e.floor,coord:e.cds,routePointId:e.id}}return null}constructor(){this.roadNetwork=new we,this.roadReadyPromise=new Promise(t=>{this.roadReadyResolve=t})}};var Im={placeId:0,catLotStatusApi:"https://screen.aibee.cn/ai-map/car-park/car-lot-status",useWorker:!1},ba=class{setRoadData(t,e){return this.options.useWorker&&this.worker?H(this.worker,"set_road_info",{roadData:t,facilities:e}):(this.recommendCore&&this.recommendCore.setRoadData(t,e),Promise.resolve())}recommend(t){return g(this,null,function*(){let e=yield fetch(this.options.catLotStatusApi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({place_id:+this.options.placeId})}).then(i=>i.json()).then(i=>i.data.filter(s=>s.status===0)).then(i=>{var s;return i.filter((s=this.options.filterCarLotStatus)!=null?s:()=>!0)});return this.options.useWorker&&this.worker?H(this.worker,"recommend",w({},t,{carLotStatus:e})):this.recommendCore?this.recommendCore.recommend(t.start,e,t.end,t.travelDirection,t.parkingType):null})}dispose(){this.worker&&(this.worker.terminate(),this.worker=null),this.recommendCore&&(this.recommendCore.dispose(),this.recommendCore=null)}constructor(t={}){this.worker=null,this.recommendCore=null,this.options=w({},Im,t),this.options.useWorker?this.worker=Zo():this.recommendCore=new Hs}};import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.url-search-params.js";import"core-js/modules/web.url-search-params.delete.js";import"core-js/modules/web.url-search-params.has.js";import"core-js/modules/web.url-search-params.size.js";import"core-js/modules/es.json.stringify.js";var Gm={url:"",reconnect:!0,heartBeat:2e3,heartMsg:JSON.stringify({command:"PING"}),reconnectTime:3e3,reconnectMaxCount:1e6,noMessageTime:6e3},ci=class extends st{initWebsocket(){this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{this.alive=!0,this.startHeart(),this.startOnMessageTimer(),this.stopReconnect(),this.dispatchEvent({type:"open"})},this.ws.onerror=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect(),this.registryEvent()},this.ws.onclose=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect()},this.ws.onmessage=t=>{this.startOnMessageTimer(),this.dispatchEvent({type:"message",message:t})}}startHeart(){this.stopHeart(),this.heartTimer=this.timer.setInterval(()=>{this.send(this.options.heartMsg)&&this.dispatchEvent({type:"send-heart"})},this.options.heartBeat)}stopHeart(){this.heartTimer&&(this.timer.clearInterval(this.heartTimer),this.heartTimer=null)}startReconnect(t){t===void 0&&(t=this.options.reconnectTime),this.stopReconnect(),this.options.reconnect&&(this.options.reconnectMaxCount--,this.options.reconnectMaxCount>=0&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.initWebsocket()},t)))}stopReconnect(){this.reconnectTimer&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}startOnMessageTimer(){this.stopOnMessageTimer(),this.noMessageTimer=this.timer.setTimeout(()=>{var t;(t=this.ws)==null||t.close(),this.dispatchEvent({type:"no-message-timeout"})},this.options.noMessageTime)}stopOnMessageTimer(){this.noMessageTimer&&(this.timer.clearTimeout(this.noMessageTimer),this.noMessageTimer=null)}send(t){var e;let i=typeof t=="string"?t:JSON.stringify(t);return this.alive&&((e=this.ws)==null?void 0:e.readyState)===1?(this.ws.send(i),this.dispatchEvent({type:"send-success",msg:i}),!0):(this.dispatchEvent({type:"send-fail",msg:i}),!1)}registryEvent(){window.addEventListener("online",this.onOnline)}unRegistryEvent(){window.removeEventListener("online",this.onOnline)}close(){var t;this.unRegistryEvent(),this.options.reconnect=!1,this.alive=!1,this.stopHeart(),this.stopReconnect(),this.stopOnMessageTimer(),(t=this.ws)==null||t.close(),this.ws=null,this.dispatchEvent({type:"close"})}dispose(){this.close(),this.timer.dispose(),super.dispose()}constructor(t){super(),this.ws=null,this.alive=!1,this.timer=new K,this.heartTimer=null,this.reconnectTimer=null,this.noMessageTimer=null,this.onOnline=()=>{this.startReconnect()},this.options=w({},Gm,t||{}),this.options.url&&this.initWebsocket()}};import{isNil as Ea}from"lodash";var jo=a=>{let t=a.toString(2),e=""+Array(16-t.length+1).join("0")+t,i=parseInt(e.slice(0,4),2)*10,s=parseInt(e.slice(4,16),2);return[i,s]};var Sa=class extends st{initPositionWebSocket(){let t=w({},this.options.ext_position_params,{place_id:this.options.place_id,token:this.options.access_token}),e=Object.keys(t).filter(i=>!Ea(t[i])).map(i=>i+"="+t[i]).join("&");this.positionWebSocket=new ci({url:this.options.wss_position_url+"?"+e}),this.positionWebSocket.addEventListener("message",i=>{let{message:s}=i,o=(()=>{try{return JSON.parse(s.data)}catch(I){return s.data}})();if(this.dispatchEvent({type:"ws-message",data:o}),o.command==="POSITION_RESULT"&&o.data.success)if(["POSITION","FLOOR","PARK_POSITION","AOA"].includes(o.data.success_type)&&this.useGpsFloorTimer&&(this.positionFloor=o.data.floor,this.timer.clearTimeout(this.useGpsFloorTimer),this.useGpsFloorTimer=null),o.data.success_type==="AOA"){let{x:I,y:D,time:V,floor:Z,ts:Ot}=o.data,Ft=this.positionFloor!==Z;if(this.positionFloor=Z,this.dispatchEvent({type:"ws-position",floor:Z,x:I,y:D,time:V,_type:"aoa"}),this.options.upload_position){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:D,floor:Z,type:"aoa"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:Z,x:I,y:D,time:new Date(Ot).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var r;if(Ft){var h,c,l;(l=this.pdrPosition)==null||(c=l.pdr)==null||(h=c.particleFilter)==null||h.setPosInitFlag(!1)}(r=this.pdrPosition)==null||r.setBeaconPosition({x:I,y:D},new Date(Ot).getTime()-o.lag-o.duration)}else if(Ft){var p;if(this.resetPdr(),(p=this.carInertialPosition)==null||p.stopPositionTimer(),this.path){let Qt=this.path.findIndex(Ie=>Ie.floor===Z),Ut=this.path[Qt];if(Ut){var d;this.resetPdr(),(d=this.carInertialPosition)==null||d.setBeaconPosition(Ut.points[0],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var u;(u=this.carInertialPosition)==null||u.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var f;(f=this.carInertialPosition)==null||f.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var x;(x=this.carInertialPosition)==null||x.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="POSITION"){let{x:I,y:D,time:V,floor:Z,ts:Ot}=o.data,Ft=this.positionFloor!==Z;if(this.positionFloor=Z,this.dispatchEvent({type:"ws-position",floor:Z,x:I,y:D,time:V,_type:"beacon"}),console.log("positionFloor",Z,Ft),this.options.upload_position){var m;(m=this.positionWebSocket)==null||m.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:D,floor:Z,type:"originBeacon"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:Z,x:I,y:D,time:new Date(Ot).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var y;if(Ft){var _,P,S;(S=this.pdrPosition)==null||(P=S.pdr)==null||(_=P.particleFilter)==null||_.setPosInitFlag(!1)}(y=this.pdrPosition)==null||y.setBeaconPosition({x:I,y:D},new Date(Ot).getTime()-o.lag-o.duration)}else if(Ft){var E;if(this.resetPdr(),(E=this.carInertialPosition)==null||E.stopPositionTimer(),this.path){let Qt=this.path.findIndex(Ie=>Ie.floor===Z),Ut=this.path[Qt];if(Ut){var k;this.resetPdr(),(k=this.carInertialPosition)==null||k.setBeaconPosition(Ut.points[0],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var b;(b=this.carInertialPosition)==null||b.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var G;(G=this.carInertialPosition)==null||G.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var R;(R=this.carInertialPosition)==null||R.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="PARK_POSITION"&&o.data.success){if(this.options.type===1){let{x:I,y:D,time:V,floor:Z}=o.data,Ot=this.positionFloor!==Z;if(this.positionFloor=o.data.floor,this.dispatchEvent({type:"ws-position",floor:Z,x:I,y:D,time:V,_type:"vision"}),!this.options.use_pdr){this.dispatchEvent({type:"position",floor:Z,x:I,y:D,time:new Date(V).getTime()});return}if(Ot){var O;if(this.resetPdr(),(O=this.carInertialPosition)==null||O.stopPositionTimer(),this.path){let Ft=this.path.findIndex(Ut=>Ut.floor===Z),Qt=this.path[Ft];if(Qt){var $;this.resetPdr(),($=this.carInertialPosition)==null||$.setPosition(Qt.points[0],new Date(V).getTime(),o.duration)}else{var nt;(nt=this.carInertialPosition)==null||nt.setPosition([I,D],new Date(V).getTime(),o.duration)}}else{var W;(W=this.carInertialPosition)==null||W.setPosition([I,D],new Date(V).getTime(),o.duration)}}else{var J,z;if((J=this.carInertialPosition)==null||J.setPosition([I,D],new Date(V).getTime(),o.duration),!((z=this.carInertialPosition)!=null&&z.positionTimer)){var mt;(mt=this.carInertialPosition)==null||mt.startPositionTimer()}}if(this.options.upload_position){var Q;(Q=this.positionWebSocket)==null||Q.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:D,floor:Z,type:"vision"}),serverData:JSON.stringify(o)})}}}else this.dispatchEvent({type:"floor",floor:o.data.floor,time:o.data.time})})}initSensorWebSocket(){let t=w({},this.options.ext_sensor_params,{token:this.options.access_token,place_id:this.options.place_id,record_sensor:1}),e=Object.keys(t).filter(i=>!Ea(t[i])).map(i=>i+"="+t[i]).join("&");this.sensorWebSocket=new ci({url:this.options.wss_sensor_url+"?"+e})}initPdr(){this.options.type===1?(this.carInertialPosition=new Us,this.carInertialPosition.addEventListener("change-pos",t=>{let{value:e}=t,{pos:i,success:s,speed:o}=e;if(s&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:i[0],y:i[1],time:Date.now(),speed:o}),this.options.upload_position)){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:i[0],y:i[1],floor:this.positionFloor,type:"vision_pdr"})})}}),this.carInertialPosition.addEventListener("change-compass",t=>{let{value:e}=t;this.dispatchEvent({type:"compass",value:e})})):(this.pdrPosition=new Rs(this.bmap,{pdr:{using_gps:this.options.use_gps},sensor:{elements:[B.COMPASS,B.ACCELERATION,B.DEVICE_MOTION].concat(this.options.use_gps?[B.GPS]:[])}}),this.requestDeviceOrientationPermission(),this.options.upload_position&&this.pdrPosition.sensor.addEventListener("sensor-data",t=>{let{data:e}=t;var i;(i=this.positionWebSocket)==null||i.send({command:"UPLOAD_SENSOR",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify(e)})}),this.pdrPosition.sensor.addEventListener("add-data-item",t=>{t.item.type==="compass"&&this.dispatchEvent({type:"compass",value:t.item.res})}),this.pdrPosition.addEventListener("position",t=>{let{x:e,y:i,_type:s}=t;if(console.log("_type",s,e,i,this.positionFloor,this.gpsFloor),s==="gps"&&!this.useGpsFloorTimer){let n=()=>{this.useGpsFloorTimer=this.timer.setTimeout(()=>{this.gpsFloor?this.positionFloor=this.gpsFloor:n()},5e3)};n()}if(this.positionFloor&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:e,y:i,time:Date.now()}),this.options.upload_position)){var o;(o=this.positionWebSocket)==null||o.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:e,y:i,floor:this.positionFloor,type:s})})}}))}setSensor(t){this.pdrPosition&&this.pdrPosition.setSensor(t)}requestDeviceOrientationPermission(){return g(this,null,function*(){if(this.pdrPosition){let t=yield this.pdrPosition.checkSensor();return t.deviceOrientation?this.pdrPosition.start():(this.dispatchEvent(w({type:"check-sensor"},t)),!t.deviceOrientation&&this.options.use_default_permission),t}else return null})}getGpsFloor(){return g(this,null,function*(){if(this.options.use_gps&&this.options.get_gps_floor_url){let t=yield fetch(this.options.get_gps_floor_url+"/"+this.options.place_id).then(e=>e.json());t.code===200&&(this.gpsFloor=t.data.gps_floor)}})}pausePdr(){if(this.options.type===1){var t;(t=this.carInertialPosition)==null||t.stopPositionTimer()}else{var e;(e=this.pdrPosition)==null||e.pause()}}continuePdr(){if(this.options.type===1)this.carInertialPosition&&(this.carInertialPosition.positionTimer||this.carInertialPosition.startPositionTimer());else{var t;(t=this.pdrPosition)==null||t.continue()}}setPathAngle(t){if(this.options.type===1){var e;(e=this.carInertialPosition)==null||e.setPathAngle(t)}}getForwardAngle(){if(this.options.type===1){var t,e;return(e=(t=this.carInertialPosition)==null?void 0:t.angle)!=null?e:null}else return null}resetPdr(){this.carInertialPosition&&(this.carInertialPosition.history=[],this.carInertialPosition.setPathAngle(0),this.carInertialPosition.speed=0),this.pdrPosition&&this.pdrPosition.pdr.particleFilter.setPosInitFlag(!1)}setPath(t){this.path=t}sendBeacon(t){var e;let i=[];if(ee)i=t.map(o=>{let[n,r]=jo(o.major);return[o.uuid,r,o.minor,o.rssi,o.accuracy,n]}).filter(o=>o[3]!==0).sort((o,n)=>n[3]-o[3]);else{let o=t.reduce((n,r)=>{var h,c;let[l,p]=jo(r.major),d=""+p+r.minor;return(h=n)[c=d]||(h[c]=[]),n[d].push(w({},r,{battery:l,major:p})),n},{});Object.entries(o).forEach(n=>{let[r,h]=n,{uuid:c,major:l,minor:p,accuracy:d,battery:u}=h[0];if(h.length>1){let f=h.filter(m=>m.rssi<0),x=f.reduce((m,y)=>m+y.rssi,0);i.push([c,l,p,x/f.length,d,u])}else i.push([c,l,p,h[0].rssi,d,u])})}let s={command:"POSITION",index:this.uploadIndex++,ts:Date.now(),beacons:JSON.stringify([{type:"ibeacon",timestamp:Date.now()/1e3,res:i}]),ext_sensors:JSON.stringify({})};(e=this.sensorWebSocket)==null||e.send(s)}dispose(){var t,e,i,s;this.timer.dispose(),(t=this.positionWebSocket)==null||t.dispose(),this.positionWebSocket=null,(e=this.sensorWebSocket)==null||e.dispose(),this.sensorWebSocket=null,(i=this.pdrPosition)==null||i.dispose(),this.pdrPosition=null,(s=this.carInertialPosition)==null||s.dispose(),this.carInertialPosition=null,super.dispose()}constructor(t,e){super(),this.bmap=t,this.positionWebSocket=null,this.sensorWebSocket=null,this.pdrPosition=null,this.carInertialPosition=null,this.gpsFloor="",this.positionFloor="",this.useGpsFloorTimer=null,this.uploadIndex=0,this.path=null,this.timer=new K;let i=location.href.indexOf("?"),s=i!==-1?location.href.slice(i):location.search,o=new URLSearchParams(s),n=o.get("server_env")||"prod",r={test:"nav-test.aibee.cn",prod:"nav.aibee.cn"},h="wss://"+r[n]+"/aether-walker/indoor/position",c="wss://"+r[n]+"/aether-walker/indoor/sensor";this.options=w({place_id:o.get("place_id"),access_token:o.get("access_token"),env:n,wss_position_url:h,wss_sensor_url:c,get_gps_floor_url:"https://"+r[n]+"/aether-walker/indoor/conf",use_sensor:!1,type:-1,use_gps:!0,use_pdr:!0,upload_position:!0,use_default_permission:!0,ext_position_params:{},ext_sensor_params:{}},e),this.initPositionWebSocket(),this.options.use_sensor&&this.initSensorWebSocket(),this.options.use_pdr&&this.initPdr(),this.options.use_gps&&this.getGpsFloor()}};import"core-js/modules/web.dom-collections.iterator.js";var Ca=class extends N{showMyPosition(t,e){var i;let s=(i=this.bmap.context.currentFloor)==null?void 0:i.getGraphicPosition(t);if(s){let o=new Ee(this.bmap.context,{autoUpdate:!0,appendToBody:!1});o.div.appendChild(e),o.position.copy(this.bmap.mercatorToWorld(s)),this.myPositionOverlay=o,console.log("graphicPos",s,this)}else console.warn("[showMyPosition] \u6CA1\u6709\u627E\u5230\u56FE\u5143\u6240\u5728\u7684\u4F4D\u7F6E")}hideMyPosition(){this.myPositionOverlay&&(this.myPositionOverlay.dispose(),this.myPositionOverlay=null)}dispose(){this.hideMyPosition()}constructor(...t){super(...t),this.myPositionOverlay=null}};var Ta=class extends N{highlightPoi(t,e){e===void 0&&(e={icon_size:[40,40],collision_enable:!1}),t.map(s=>this.bmap.getPoiById(s)).filter(s=>!!s).forEach(s=>{var o;(o=s.userData).restore||(o.restore={});for(let h in e)if(h in s.options){var n,r;(n=s.userData.restore)[r=h]||(n[r]=s.options[h]),s.options[h]=e[h]}})}restorePoi(t){t.map(i=>this.bmap.getPoiById(i)).filter(i=>!!i).forEach(i=>{console.log("poi.userData.restore",i.userData.restore);for(let s in i.userData.restore)s in i.options&&(i.options[s]=i.userData.restore[s]);i.userData.restore={}})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";var La=class extends N{sortByDistance(t,e,i){return g(this,null,function*(){i===void 0&&(i=!1);let s=[...e];if(i||e.length<20)return yield Promise.all(s.map(o=>g(this,null,function*(){o.distance=yield this._getDistance(t,{floor:o.floor,x:o.center_x,y:o.center_y})}))),s.sort((o,n)=>o.distance-n.distance);{let o=s.sort((r,h)=>{let c=Math.sqrt((r.center_x-t.x)**2+(r.center_y-t.y)**2)+(t.floor===r.floor?0:100),l=Math.sqrt((h.center_x-t.x)**2+(h.center_y-t.y)**2)+(t.floor===h.floor?0:100);return c-l});return[...(yield Promise.all(o.slice(0,20).map(r=>g(this,null,function*(){return r.distance=yield this._getDistance(t,{floor:r.floor,x:r.center_x,y:r.center_y}),r})))).sort((r,h)=>r.distance-h.distance),...o.slice(20)]}})}_getDistance(t,e){return g(this,null,function*(){return this.navPath.getPath({floor:t.floor,coord:[t.x,t.y]},{floor:e.floor,coord:[e.x,e.y]},"",0).then(i=>i.reduce((s,o,n)=>{if(s+=o.distance,n!==i.length-1)switch(o.endType){case"escalator":case"straightLadder":case"staircase":case"ramp":s+=100;break}return s},0)).catch(i=>i==="near"?0:1/0)})}dispose(){super.dispose(),this.needDisposeNavPath&&this.navPath.dispose()}constructor(t,e){if(super(t),this.needDisposeNavPath=!1,e)this.navPath=e;else{this.navPath=new Ss;let i=new Oe(t);this.needDisposeNavPath=!0,i.load(t.config.apiPath.loadPlaceInfo+"?place_id="+t.config.placeId+"&env=prod").then(s=>g(this,null,function*(){let[o,n]=yield Promise.all([i.getRoadNetworkData(),i.getFacilitiesData()]);this.navPath.setRoadData(o,n.infrastructures)}))}}};var Bm="https://robot-vr-public.bj.bcebos.com/v1/static_resource/satellite_tiles",zm={base_url:Bm},ka=class extends N{setVisible(t){this.tileLayer.setVisibility(t)}dispose(){this.bmap.context.scene.remove(this.tileLayer),this.tileLayer.dispose(),super.dispose()}constructor(t,e){super(t),this.options=w({},zm,e),this.tileLayer=new ue(t.context,this.options),this.tileLayer.position.z=-1,this.bmap.context.scene.add(this.tileLayer)}};import{Box3 as Wm,Group as Um}from"three";var Aa=class extends N{addHeatmap(t,e){this.heatmap||(this.heatmap=new Yi(this.bmap.context),this.group.add(this.heatmap)),this.heatmap.loadData(t);let i=new Wm().setFromObject(e.graphicLayer);return this.heatmap.position.setZ(i.max.z+.1),this.heatmap}removeHeatMap(){this.heatmap&&(this.group.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=null)}dispose(){this.removeHeatMap(),this.bmap.context.scene.remove(this.group)}constructor(t){super(t),this.heatmap=null,this.group=new Um,this.bmap.context.scene.add(this.group)}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.reverse.js";import{Group as Hm,Vector3 as li,Raycaster as Nm,Vector2 as Zm,Plane as jm,Box3 as Vm}from"three";import"core-js/modules/es.array.push.js";var Ns=class extends dt{updateRectPreview(t,e,i){i===void 0&&(i=!1);let s=Math.min(t.x,e.x),o=Math.min(t.y,e.y),n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);this.previewElement||(this.previewElement=gt(this.options.strokeColor,"none"),this.previewElement.setAttribute("stroke-opacity",""+this.options.strokeOpacity),this.svg.appendChild(this.previewElement)),j(this.previewElement,s,o,n,r),i&&this.updateRectPreviewFill(s,o,n,r)}updateRectPreviewFill(t,e,i,s){this.previewFillElement||(this.previewFillElement=document.createElementNS("http://www.w3.org/2000/svg","rect"),this.previewFillElement.setAttribute("fill",this.options.fillColor),this.previewFillElement.setAttribute("fill-opacity",""+this.options.fillOpacity),this.svg.insertBefore(this.previewFillElement,this.svg.firstChild)),j(this.previewFillElement,t,e,i,s)}updateCirclePreview(t,e){this.previewElement||(this.previewElement=Gt(String(e),"none"),this.previewElement.setAttribute("stroke",this.options.strokeColor),this.previewElement.setAttribute("stroke-opacity",""+this.options.strokeOpacity),this.svg.appendChild(this.previewElement)),yt(this.previewElement,t.x,t.y),this.previewElement.setAttribute("r",""+e)}updateCirclePreviewFill(t,e){this.previewFillElement||(this.previewFillElement=document.createElementNS("http://www.w3.org/2000/svg","circle"),this.previewFillElement.setAttribute("fill",this.options.fillColor),this.previewFillElement.setAttribute("fill-opacity",""+this.options.fillOpacity),this.previewFillElement.setAttribute("stroke","none"),this.svg.insertBefore(this.previewFillElement,this.svg.firstChild)),yt(this.previewFillElement,t.x,t.y),this.previewFillElement.setAttribute("r",""+e)}addPolygonPoint(t){this.points.push(t);let e=Gt(String(this.options.pointRadius),this.options.pointColor);if(yt(e,t.x,t.y),this.controlPoints.push(e),this.svg.appendChild(e),this.points.length>1){let i=this.points[this.points.length-2],s=Kt(this.options.strokeColor);s.setAttribute("stroke-opacity",""+this.options.strokeOpacity),rt(s,i,t),this.svg.appendChild(s),this.lines.push(s)}this.lastLine&&this.lastLine.parentNode&&this.svg.removeChild(this.lastLine),this.lastLine=Kt(this.options.strokeColor),this.lastLine.setAttribute("stroke-opacity",""+this.options.strokeOpacity),rt(this.lastLine,t,t),this.svg.appendChild(this.lastLine),this.updatePolygonFill()}updatePolygonPreview(t){if(this.points.length===0)return;this.currentMousePoint=t;let e=this.points[this.points.length-1];this.lastLine&&rt(this.lastLine,e,t),this.updatePolygonFill(t)}checkAdsorb(t){if(this.points.length<2)return!1;let e=this.points[0],i=t.x-e.x,s=t.y-e.y;return Math.sqrt(i*i+s*s)<=this.adsorbRadius}updatePolygonFill(t){if(this.points.length<2)return;this.polygonFillElement||(this.polygonFillElement=document.createElementNS("http://www.w3.org/2000/svg","polygon"),this.polygonFillElement.setAttribute("fill",this.options.fillColor),this.polygonFillElement.setAttribute("fill-opacity",""+this.options.fillOpacity),this.polygonFillElement.setAttribute("stroke","none"),this.svg.insertBefore(this.polygonFillElement,this.svg.firstChild));let e=[];for(let i=0;i<this.points.length;i++){let s=this.points[i];!isNaN(s.x)&&!isNaN(s.y)&&e.push(s.x+","+s.y)}t&&!isNaN(t.x)&&!isNaN(t.y)&&e.push(t.x+","+t.y),e.length>=3&&this.polygonFillElement.setAttribute("points",e.join(" "))}clear(){this.points=[],this.currentMousePoint=void 0,this.controlPoints.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.controlPoints=[],this.lines.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.lines=[],this.previewElement&&(this.previewElement.parentNode&&this.svg.removeChild(this.previewElement),this.previewElement=null),this.previewFillElement&&(this.previewFillElement.parentNode&&this.svg.removeChild(this.previewFillElement),this.previewFillElement=null),this.lastLine&&(this.lastLine.parentNode&&this.svg.removeChild(this.lastLine),this.lastLine=null),this.polygonFillElement&&(this.polygonFillElement.parentNode&&this.svg.removeChild(this.polygonFillElement),this.polygonFillElement=null)}getLastPoint(){return this.points[this.points.length-1]}getFirstPoint(){return this.points[0]}dispose(){this.clear(),super.dispose()}constructor(t,e){super(t),this.previewElement=null,this.previewFillElement=null,this.controlPoints=[],this.lines=[],this.lastLine=null,this.points=[],this.polygonFillElement=null,this.currentMousePoint=void 0,this.adsorbRadius=8,this.options=e,e.adsorbRadius!==void 0&&(this.adsorbRadius=e.adsorbRadius)}};import"core-js/modules/es.array.push.js";import{Box3 as Da}from"three";var Zs=class extends dt{initElements(){this.svg.style.pointerEvents="auto",this.outline=gt(this.STROKE_COLOR,"transparent"),this.outline.setAttribute("stroke-dasharray","5,5"),this.outline.setAttribute("stroke-width","1"),this.svg.appendChild(this.outline),this.moveArea=gt(this.STROKE_COLOR,"transparent"),this.moveArea.style.cursor="move",this.svg.appendChild(this.moveArea);for(let t=0;t<4;t++){let e=Kt(this.STROKE_COLOR);e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","5,5"),this.outlineLines.push(e),this.svg.appendChild(e)}for(let t=0;t<8;t++){let e=gt(this.STROKE_COLOR,this.FILL_COLOR);e.style.cursor=this.getCursorForPoint(t),this.scalePoints.push(e),this.svg.appendChild(e)}this.rotateHandle=Gt(String(this.ROTATE_HANDLE_RADIUS),this.FILL_COLOR),this.rotateHandle.setAttribute("stroke",this.STROKE_COLOR),this.rotateHandle.setAttribute("stroke-width","1"),this.rotateHandle.style.cursor="crosshair",this.svg.appendChild(this.rotateHandle)}getCursorForPoint(t){return["nw-resize","n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize"][t]}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerleave",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerleave",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}getBoundingBoxInfo(){if(!this.selectedGraphic)return null;let t=new Da().setFromObject(this.selectedGraphic),{min:e,max:i}=t,{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,r=this.getSvgCoordinate(e),h=this.getSvgCoordinate(i);return{min:{x:r.x,y:r.y},max:{x:h.x,y:h.y},width:Math.abs(h.x-r.x),height:Math.abs(h.y-r.y),centerX:(r.x+h.x)/2,centerY:(r.y+h.y)/2}}show(t){this.selectedGraphic=t,this.svg.style.display="block",this.svg.style.pointerEvents="auto",this.updatePosition()}hide(){this.selectedGraphic=null,this.svg.style.display="none",this.svg.style.pointerEvents="none",this.clearControlPoints()}updatePosition(){if(this.boundingBox=this.getBoundingBoxInfo(),!this.boundingBox){this.clearControlPoints();return}let{min:t,max:e,width:i,height:s,centerX:o,centerY:n}=this.boundingBox,r=this.SCALE_POINT_SIZE/2,h=i/2,c=s/2;j(this.moveArea,t.x,e.y,i,s),j(this.outline,t.x,e.y,i,s),[{x1:t.x,y1:e.y,x2:e.x,y2:e.y},{x1:e.x,y1:e.y,x2:e.x,y2:t.y},{x1:e.x,y1:t.y,x2:t.x,y2:t.y},{x1:t.x,y1:t.y,x2:t.x,y2:e.y}].forEach((f,x)=>{rt(this.outlineLines[x],{x:f.x1,y:f.y1},{x:f.x2,y:f.y2})}),[{x:t.x-r,y:e.y-r},{x:o-r,y:e.y-r},{x:e.x-r,y:e.y-r},{x:e.x-r,y:n-r},{x:e.x-r,y:t.y-r},{x:o-r,y:t.y-r},{x:t.x-r,y:t.y-r},{x:t.x-r,y:n-r}].forEach((f,x)=>{j(this.scalePoints[x],f.x,f.y,this.SCALE_POINT_SIZE,this.SCALE_POINT_SIZE)});let d=o,u=e.y-this.ROTATE_HANDLE_OFFSET;yt(this.rotateHandle,d,u)}clearControlPoints(){j(this.moveArea,0,0,0,0),j(this.outline,0,0,0,0),this.outlineLines.forEach(e=>{rt(e,{x:0,y:0},{x:0,y:0})}),this.scalePoints.forEach(e=>{j(e,0,0,0,0)}),yt(this.rotateHandle,0,0)}getBoundingBox(){return this.selectedGraphic?new Da().setFromObject(this.selectedGraphic):null}getActionFromTarget(t){if(!t)return null;let e=t;if(e===this.rotateHandle)return{action:"rotate",point:this.rotateHandle};if(e===this.moveArea)return{action:"move",point:this.moveArea};let i=this.scalePoints.indexOf(e);return i!==-1?{action:["scale-left-top","scale-top","scale-right-top","scale-right","scale-right-bottom","scale-bottom","scale-left-bottom","scale-left"][i],point:this.scalePoints[i]}:null}getContainerPoint(t){let e=this.context.container.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}dispose(){this.unRegistryEvent(),this.moveArea&&this.moveArea.parentNode&&this.svg.removeChild(this.moveArea),this.outline&&this.outline.parentNode&&this.svg.removeChild(this.outline),this.outlineLines.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.scalePoints.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.rotateHandle&&this.rotateHandle.parentNode&&this.svg.removeChild(this.rotateHandle),this.scalePoints=[],this.outlineLines=[],this.selectedGraphic=null,this.currentAction=null,this.startPoint=null,this.boundingBox=null,super.dispose()}constructor(t){super(t),this.scalePoints=[],this.outlineLines=[],this.isTransforming=!1,this.selectedGraphic=null,this.currentAction=null,this.startPoint=null,this.boundingBox=null,this.SCALE_POINT_SIZE=8,this.ROTATE_HANDLE_RADIUS=6,this.ROTATE_HANDLE_OFFSET=30,this.STROKE_COLOR="#1CADFF",this.FILL_COLOR="#ffffff",this.onUpdate=()=>{this.selectedGraphic&&this.updatePosition()},this.onPointerDown=e=>{if(!this.selectedGraphic)return;let i=this.getActionFromTarget(e.target);e.preventDefault(),e.stopPropagation(),i&&(this.currentAction=i.action,this.startPoint=this.getContainerPoint(e),this.isTransforming=!0,this.dispatchEvent({type:"transform-start",action:this.currentAction,point:this.startPoint}))},this.onPointerMove=e=>{if(!this.currentAction||!this.startPoint)return;let i=this.getContainerPoint(e),s={x:i.x-this.startPoint.x,y:i.y-this.startPoint.y};this.startPoint=i,this.dispatchEvent({type:"transform",action:this.currentAction,delta:s,currentPoint:i})},this.onPointerUp=()=>{this.currentAction&&(this.dispatchEvent({type:"transform-end",action:this.currentAction}),this.currentAction=null,this.startPoint=null,this.isTransforming=!1)},this.initElements(),this.registryEvent()}};var Vo={strokeColor:"#1CADFF",strokeOpacity:1,strokeWidth:1,fillColor:"rgb(28, 173, 255)",fillOpacity:.3,pointColor:"#1CADFF",pointOpacity:1,pointRadius:5,height:.1,circleSegments:64,adsorbRadius:8,autoSelect:!0};function Km(a,t,e){let i=[];for(let s=0;s<=e;s++){let o=s/e*Math.PI*2;i.push([a.x+t*Math.cos(o),a.y+t*Math.sin(o)])}return i.push([a.x+t,a.y]),[i]}function Xm(a,t){let e=Math.min(a.x,t.x),i=Math.max(a.x,t.x),s=Math.min(a.y,t.y),o=Math.max(a.y,t.y);return[[[e,s],[i,s],[i,o],[e,o],[e,s]]]}function Ra(a,t,e){let i=Math.cos(e),s=Math.sin(e),o=a[0]-t[0],n=a[1]-t[1];return[t[0]+o*i-n*s,t[1]+o*s+n*i]}var Ko=class extends N{getState(){return this.state}startDrawPolygon(){this.state!=="idle"&&this.cancel(),this.deselectGraphic(),this.state="polygon",this.enter2DMode(),this.svgDrawer.clear(),this.disableControls(),this.dispatchEvent({type:"start",drawType:"polygon"})}startDrawRect(){this.state!=="idle"&&this.cancel(),this.deselectGraphic(),this.state="rect",this.enter2DMode(),this.startPoint=null,this.disableControls(),this.dispatchEvent({type:"start",drawType:"rect"})}startDrawCircle(){this.state!=="idle"&&this.cancel(),this.deselectGraphic(),this.state="circle",this.enter2DMode(),this.circleCenter=null,this.circleRadius=0,this.disableControls(),this.dispatchEvent({type:"start",drawType:"circle"})}cancel(){this.state==="idle"&&!this.selectedGraphic||(this.selectedGraphic&&this.deselectGraphic(),this.state!=="idle"&&(this.svgDrawer.clear(),this.state="idle",this.enableControls(),this.exit2DMode(),this.dispatchEvent({type:"cancel"})))}selectGraphic(t){let e=this.graphics.get(t);if(e){this.selectedGraphic&&this.deselectGraphic(),this.selectedGraphic=e,this.enter2DMode();var i,s;this.originalStyle={fillOpacity:(i=e.options.fillOpacity)!=null?i:.3,strokeOpacity:(s=e.options.strokeOpacity)!=null?s:1},e.options.fillOpacity=Math.min(this.originalStyle.fillOpacity,.5),e.options.strokeOpacity=Math.min(this.originalStyle.strokeOpacity,1),this.transformBox.show(e),this.dispatchEvent({type:"select",graphic:e})}}deselectGraphic(){if(!this.selectedGraphic)return;this.originalStyle&&(this.selectedGraphic.options.fillOpacity=this.originalStyle.fillOpacity,this.selectedGraphic.options.strokeOpacity=this.originalStyle.strokeOpacity,this.originalStyle=null);let t=this.selectedGraphic;this.selectedGraphic=null,this.transformBox.hide(),this.exit2DMode(),this.dispatchEvent({type:"deselect",graphic:t})}getSelectedGraphic(){return this.selectedGraphic}setRotation(t,e){let i=this.graphics.get(t);if(!i)return;let s=i.options.geometry.coords[0],o=[i.getCenter().x,i.getCenter().y],n=s.map(r=>Ra(r,o,e));i.options.geometry.coords[0]=n,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"rotate",graphic:i,id:t})}setWidth(t,e){let i=this.graphics.get(t);if(!i)return;let s=i.getSize(),o=e/s.x,n=i.options.geometry.coords[0],r=[i.getCenter().x,i.getCenter().y],h=n.map(c=>[r[0]+(c[0]-r[0])*o,c[1]]);i.options.geometry.coords[0]=h,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"resize",graphic:i,id:t})}setHeight(t,e){let i=this.graphics.get(t);if(!i)return;let s=i.getSize(),o=e/s.y,n=i.options.geometry.coords[0],r=[i.getCenter().x,i.getCenter().y],h=n.map(c=>[c[0],r[1]+(c[1]-r[1])*o]);i.options.geometry.coords[0]=h,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"resize",graphic:i,id:t})}setCoordinates(t,e){let i=this.graphics.get(t);i&&(i.options.geometry.coords=e,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"update",graphic:i,id:t}))}loadGraphics(t){t.forEach(e=>{e.id?vt.registerKey(e.id):e.id=vt.genUniqueKey(),e.visible=!0,this.createGraphic(e)}),this.dispatchEvent({type:"change",action:"add"})}getGraphics(){return Array.from(this.graphics.values())}removeGraphic(t){var e;let i=this.graphics.get(t);i&&(((e=this.selectedGraphic)==null?void 0:e.options.id)===t&&this.deselectGraphic(),this.graphicsGroup.remove(i),i.dispose(),this.graphics.delete(t),vt.removeKey(t),this.dispatchEvent({type:"change",action:"remove",id:t}))}clearGraphics(){this.selectedGraphic&&this.deselectGraphic(),this.graphics.forEach((t,e)=>{this.graphicsGroup.remove(t),t.dispose(),vt.removeKey(e)}),this.graphics.clear(),this.dispatchEvent({type:"change",action:"remove"})}getScreenPoint(t){let e=this.bmap.context.container.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}screenToWorld(t){let{camera:e,container:i}=this.bmap.context,s=new Zm;s.x=t.x/i.clientWidth*2-1,s.y=-(t.y/i.clientHeight)*2+1,this.raycaster.setFromCamera(s,e);let o=new jm(new li(0,0,1),0),n=new li;return this.raycaster.ray.intersectPlane(o,n)?n:null}screenCoordsToWorld(t){return t.map(e=>{let i=this.screenToWorld(e);return i?[i.x,i.y]:[0,0]})}pixelsToWorldDistance(t,e){let i=this.screenToWorld(e);if(!i)return 0;let s={x:e.x+t,y:e.y},o=this.screenToWorld(s);return o?Math.sqrt((o.x-i.x)**2+(o.y-i.y)**2):0}registryEvents(){this.bmap.context.container.addEventListener("contextmenu",this.onContextMenu),this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointermove",this.onPointerMove),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp)}unRegistryEvents(){this.bmap.context.container.removeEventListener("contextmenu",this.onContextMenu),this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointermove",this.onPointerMove),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp)}registryTransformEvents(){this.transformBox.addEventListener("transform-start",this.onTransformStart),this.transformBox.addEventListener("transform",this.onTransform),this.transformBox.addEventListener("transform-end",this.onTransformEnd)}unRegistryTransformEvents(){this.transformBox.removeEventListener("transform-start",this.onTransformStart),this.transformBox.removeEventListener("transform",this.onTransform),this.transformBox.removeEventListener("transform-end",this.onTransformEnd)}enter2DMode(){this.prevMapType===void 0&&(this.prevMapType=this.bmap.type,this.bmap.changeMapType("2d",0))}exit2DMode(){this.prevMapType!==void 0&&(this.bmap.changeMapType(this.prevMapType,0),this.prevMapType=void 0)}disableControls(){this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1}enableControls(){this.prevPanStatus!==void 0&&(this.bmap.context.control.enablePan=this.prevPanStatus),this.prevRotateStatus!==void 0&&(this.bmap.context.control.enableRotate=this.prevRotateStatus)}hitTestGraphic(t){let e=Array.from(this.graphics.values()).reverse();for(let i of e){let s=new Vm().setFromObject(i);if(t.x>=s.min.x&&t.x<=s.max.x&&t.y>=s.min.y&&t.y<=s.max.y)return i}return null}finishPolygon(){let t=this.svgDrawer.points;if(t.length<3)return;let e=[this.screenCoordsToWorld(t)],i=this.buildGraphicOptions(e),s=this.createGraphic(i);this.svgDrawer.clear(),this.state="idle",this.enableControls(),this.dispatchEvent({type:"finish",graphic:s,drawType:"polygon"}),this.options.autoSelect?this.selectGraphic(s.options.id):this.exit2DMode()}finishRect(){if(!this.startPoint)return;let t=this.currentMousePoint;if(!t)return;let e=this.screenToWorld(this.startPoint),i=this.screenToWorld(t);if(!e||!i)return;let s=Xm(e,i),o=this.buildGraphicOptions(s),n=this.createGraphic(o);this.svgDrawer.clear(),this.startPoint=null,this.state="idle",this.enableControls(),this.dispatchEvent({type:"finish",graphic:n,drawType:"rect"}),this.options.autoSelect?this.selectGraphic(n.options.id):this.exit2DMode()}finishCircle(){if(!this.circleCenter||this.circleRadius<5)return;let t=this.screenToWorld(this.circleCenter);if(!t)return;let e=this.pixelsToWorldDistance(this.circleRadius,this.circleCenter),i=Km(t,e,this.options.circleSegments),s=this.buildGraphicOptions(i),o=this.createGraphic(s);this.svgDrawer.clear(),this.circleCenter=null,this.circleRadius=0,this.state="idle",this.enableControls(),this.dispatchEvent({type:"finish",graphic:o,drawType:"circle"}),this.options.autoSelect?this.selectGraphic(o.options.id):this.exit2DMode()}buildGraphicOptions(t){let e=t[0],i=0,s=0;for(let l=0;l<e.length-1;l++)i+=e[l][0],s+=e[l][1];let o=i/(e.length-1),n=s/(e.length-1),[r,h]=this.bmap.coordinateTransform.worldToMercator(new li(o,n,0)),c=t.map(l=>l.map(p=>{let[d,u]=p;return this.bmap.coordinateTransform.worldToMercator(new li(d,u,0))}));return w({},At,{id:vt.genUniqueKey(),geometry:{type:"polygon",cds:c,coords:t,curveCpt:[],curveIndex:[]},center_coord_x:o,center_coord_y:n,center_x:r,center_y:h,fillColor:this.options.fillColor,strokeColor:this.options.strokeColor,fillOpacity:this.options.fillOpacity,strokeOpacity:this.options.strokeOpacity,strokeWidth:this.options.strokeWidth,height:this.options.height,visible:!0})}createGraphic(t){let e=new Y(this.bmap.context,t);return this.graphics.set(t.id,e),this.graphicsGroup.add(e),e}dispose(){this.exit2DMode(),this.unRegistryEvents(),this.unRegistryTransformEvents(),this.svgDrawer.dispose(),this.transformBox.dispose(),this.clearGraphics(),this.bmap.context.scene.remove(this.graphicsGroup),super.dispose()}constructor(t,e={}){super(t),this.state="idle",this.graphics=new Map,this.selectedGraphic=null,this.startPoint=null,this.circleCenter=null,this.circleRadius=0,this.originalStyle=null,this.initialRotateAngle=0,this.rotationCenter=[0,0],this.raycaster=new Nm,this.currentMousePoint=null,this.onContextMenu=i=>{(this.state!=="idle"||this.selectedGraphic)&&(i.preventDefault(),this.cancel())},this.onPointerDown=i=>{if(i.button!==0)return;let s=this.getScreenPoint(i);if(this.state==="polygon")this.svgDrawer.checkAdsorb(s)&&this.svgDrawer.points.length>=2?this.finishPolygon():this.svgDrawer.addPolygonPoint(s);else if(this.state==="rect")if(!this.startPoint)this.startPoint=s;else{this.currentMousePoint=s;let o=Math.abs(s.x-this.startPoint.x),n=Math.abs(s.y-this.startPoint.y);o>2||n>2?this.finishRect():this.startPoint=null}else if(this.state==="circle")this.circleCenter?(this.currentMousePoint=s,this.circleRadius>5?this.finishCircle():(this.circleCenter=null,this.circleRadius=0,this.svgDrawer.clear())):this.circleCenter=s;else if(this.state==="idle"){if(this.transformBox.isTransforming)return;let o=this.screenToWorld(s);if(!o)return;let n=this.hitTestGraphic(o);if(this.dispatchEvent({type:"graphic-click",graphic:n}),n){if(this.selectedGraphic&&n.options.id===this.selectedGraphic.options.id)return;this.options.autoSelect&&this.selectGraphic(n.options.id)}else this.selectedGraphic&&this.deselectGraphic()}},this.onPointerMove=i=>{let s=this.getScreenPoint(i);if(this.currentMousePoint=s,this.state==="polygon")this.svgDrawer.updatePolygonPreview(s);else if(this.state==="rect"&&this.startPoint)this.svgDrawer.updateRectPreview(this.startPoint,s,!0);else if(this.state==="circle"&&this.circleCenter){let o=s.x-this.circleCenter.x,n=s.y-this.circleCenter.y,r=Math.sqrt(o*o+n*n);this.circleRadius=r,this.svgDrawer.updateCirclePreview(this.circleCenter,r),this.svgDrawer.updateCirclePreviewFill(this.circleCenter,r)}},this.onPointerUp=i=>{},this.onTransformStart=i=>{if(i.action==="rotate"&&this.selectedGraphic){let s=this.selectedGraphic.getCenter();this.rotationCenter=[s.x,s.y];let o=this.transformBox.getSvgCoordinate(s);o&&(this.initialRotateAngle=Math.atan2(i.point.y-o.y,i.point.x-o.x))}},this.onTransform=i=>{if(!this.selectedGraphic)return;let{action:s,delta:o,currentPoint:n}=i,r=this.selectedGraphic;if(s==="move"){let h={x:n.x-o.x,y:n.y-o.y},c=this.screenToWorld(h),l=this.screenToWorld(n);if(!c||!l)return;let p={x:l.x-c.x,y:l.y-c.y},u=r.options.geometry.coords[0].map(f=>[f[0]+p.x,f[1]+p.y]);r.options.geometry.coords[0]=u}else if(s.startsWith("scale")){let h=this.transformBox.getBoundingBoxInfo();if(!h)return;let c=r.options.geometry.coords[0],l=o.x,p=o.y;(s==="scale-top"||s==="scale-bottom")&&(l=0),(s==="scale-left"||s==="scale-right")&&(p=0);let d={x:h.min.x,y:h.min.y},u={x:h.max.x,y:h.max.y},f={x:d.x+(s.includes("left")?l:0),y:d.y+(s.includes("bottom")?p:0)},x={x:u.x+(s.includes("right")?l:0),y:u.y+(s.includes("top")?p:0)},m=this.screenToWorld(d),y=this.screenToWorld(u),_=this.screenToWorld(f),P=this.screenToWorld(x);if(!m||!y||!_||!P)return;let S=y.x-m.x,E=y.y-m.y,k=P.x-_.x,b=P.y-_.y,G=c.map(R=>{let O=S!==0?(R[0]-m.x)/S:.5,$=E!==0?(R[1]-m.y)/E:.5;return[_.x+O*k,_.y+$*b]});r.options.geometry.coords[0]=G}else if(s==="rotate"){let h=this.transformBox.getSvgCoordinate(new li(this.rotationCenter[0],this.rotationCenter[1],0));if(!h)return;let c=Math.atan2(n.y-h.y,n.x-h.x),l=c-this.initialRotateAngle;this.initialRotateAngle=c;let d=r.options.geometry.coords[0].map(u=>Ra(u,this.rotationCenter,l));r.options.geometry.coords[0]=d}r.dispose(),r.init(),r.visible=!0},this.onTransformEnd=i=>{this.selectedGraphic&&this.dispatchEvent({type:"change",action:"move",graphic:this.selectedGraphic,id:this.selectedGraphic.options.id})},this.options=w({},Vo,e),this.graphicsGroup=new Hm,this.graphicsGroup.name="GraphicDrawGroup",this.bmap.context.scene.add(this.graphicsGroup),this.svgDrawer=new Ns(this.bmap.context,{strokeColor:this.options.strokeColor,strokeOpacity:this.options.strokeOpacity,fillColor:this.options.fillColor,fillOpacity:this.options.fillOpacity,pointColor:this.options.pointColor,pointRadius:this.options.pointRadius,adsorbRadius:this.options.adsorbRadius}),this.transformBox=new Zs(this.bmap.context),this.transformBox.hide(),this.registryEvents(),this.registryTransformEvents()}};export{Oe as AibeeLoader,Oo as BMap,ua as BMapSelect,dt as BaseSvg,Us as CarInertialPosition,Mi as ClickHelper,ws as Context,vs as ContextCamera,ys as ContextScene,fs as Control,Si as CoordinateTransform,ta as CrLoader,da as CrNavPath,ea as Equipment,st as EventDispatcher,un as Events,zt as Floor,kr as GlbModel,Y as Graphic,Ko as GraphicDraw,Gi as GraphicLayer,le as GroundTexture,Aa as Heatmap,Yi as HeatmapElement,Ta as HighlightPoi,lt as HooksName,cs as HoverHelper,Se as InstancedGraphic,Zi as InstancedModel,Qe as InstancedParkingSpace,rs as InstancedWall,Ei as KalmanFilter,ts as Lane,q as Layer,ii as LineElement,hT as MapTypePolar,ei as MergeAttributeGraphic,pe as MergeAttributeGroundTexture,os as MergeAttributeLane,is as MergeAttributeWall,Or as MergeGraphic,de as MergedAttributeGraphicLine,Vi as MergedGraphicLayer,Ni as MergedModelLayer,Ii as Model,wa as MulFloorNavigation,_a as MulFloorSelect,la as MulFloors,Ss as NavPath,ha as Navigation,Ee as Overlay,Hi as ParkingLayer,pT as ParkingType,Yt as PathDirection,Rs as PdrPosition,ce as Poi,et as Poi2,Bi as PoiLayer,Ui as PoiLayer2,Sa as Position,Kg as ProofType,_s as RENDER_VERSION,ba as RecommendParkingSpace,gs as Renderer,Hn as RoadNetwork,we as RoadNetwork2,xi as SDF_REFERENCE_FONT_SIZE,B as SENSOR_TYPE,ka as SatelliteTile,Tr as SelectBox,hs as Selection,Ts as Sensor,Fi as Shadow,ci as Socket,La as SortByDistance,qi as SvgLine,$i as SvgPolygon,Pe as TaskQueue,es as TextTexture,ue as TileLayer,Ki as TileLoader,K as Timer,ie as TweenUtil,dn as UA,Ca as UseMyPosition,Ji as Wall,bi as WorkerPool,Df as addAlphaToHexColor,Sh as assignGraphicDepthLevel,Ue as buildSdfTextGeometry,ge as calc_angle,Js as calc_direction,NA as calculateInstantaneousSpeed,zs as calculateLineDirection,mn as convertToSnakeCase,Gt as createCircle,Kt as createLine,gt as createRect,cn as createSvg,yi as createSvgElement,py as createThreeBox,ly as createThreeLine,Xt as darkenColor,pu as defaultConfig,Vo as defaultGraphicDrawOptions,At as defaultGraphicOptions,Eo as defaultOptions,jp as defaultTextTextureOptions,yf as deviceToVector3,F as dispose,En as distancePointToSegment,ae as generatorKeyByObj,lh as getAngle,no as getBorderPoints,gi as getCenter,Xr as getConfig,Sn as getDirectPath,Qs as getDirectionByAngle,Cn as getDistanceByPathPos,A as getLength,vf as getLongestSideDir,xf as getMinEdgeSquare,ft as getPathLength,Vt as getPointEdgeIndex,xe as getPosByPathDistance,an as hasChinese,Rf as hexToRgb,rn as initDirectionalLight,nn as initLight,ui as initShape,Pv as instancedGeometiesAttributes,If as isAndroid,te as isContain,ve as isControl,vi as isIOS,ee as isIphone,re as isMac,hn as isPointInPolygon,Mv as isRectangle,wi as layoutSdfText,Ma as linearFitForSpeed,Jr as loadBuildingGround,G1 as loadExternalStreet,Qr as loadGraphics,_v as mergeGraphicGeometries,Wh as mergeGraphicLineGeometries,vg as moveOnRoute,hi as predictFuturePosition,ZA as predictFutureSpeed,ye as proxyOptions,jA as removeOutliers,dh as removeWeightPath,yt as setCirclePosition,rt as setLineStartEnd,j as setRectPosition,_i as simplifyPath,pn as sleepByRf,ln as sleepOnePromise,qs as sleepOneRf,bn as smoothPath,fn as splitStrByBracket,yn as splitTextByMeasure,Af as strToNumber,Mt as timeoutPromise,ry as toWebWorker,Pi as transformGraphicData,No as transformSpeed,_e as translatePosToCenter,H as triggerWorker,L as vector3ToDevice,lg as xhrGet};
824
+ `};var Is=class extends gm{constructor(t){super({type:"ArrowLineMaterial",uniforms:Object.assign({},ya.clone(Os["custom-line"].uniforms),{map:{value:null}}),vertexShader:Os["custom-line"].vertexShader,fragmentShader:Os["custom-line"].fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(e){this.uniforms.map.value=e}},color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(e){this.uniforms.repeat.value.copy(e)}},allDistance:{enumerable:!0,get:function(){return this.uniforms.allDistance.value},set:function(e){this.uniforms.allDistance.value=e}}}),this.setValues(t),this.isLineMaterial=!0}};import{LineGeometry as Mm}from"three/examples/jsm/lines/LineGeometry.js";import{Line2 as Em}from"three/examples/jsm/lines/Line2.js";var va={texture_url:Di,lineWidth:8,color:16777215},Gs=class extends ym{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:i,height:s}}}}}=this,o=t.map(r=>{let[h,c,l]=r;return L(new wm(h,c,l),e,i,s)}).map(r=>{let{x:h,y:c}=r;return[h,c]});return ft(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new Uo(t,1)}loadTexture(t){return new Promise((e,i)=>{new vm().load(t,e,void 0,i)})}transformPoints(t){let e=[];for(let i=0;i<t.length;i++)e.push(...t[i]);return e}updatePoints(t){if(this.points=t,this.mesh){var e,i;this.remove(this.mesh),(e=this.material)==null||e.dispose(),(i=this.geometry)==null||i.dispose()}this.geometry=new Mm,this.geometry.setPositions(t.flat(2));let s=ft(t.map(r=>{let[h,c]=r;return[h,c]})),o=this.material=new Is({color:new xm(this.config.color),transparent:!0,resolution:new Uo(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,depthWrite:!0,linewidth:this.config.lineWidth,map:this.texture,blending:_m,repeat:new Uo(this.getRepeat(),1),allDistance:s}),n=this.mesh=new Em(this.geometry,o);return n.computeLineDistances(),n.renderOrder=9,this.add(n),n}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return g(this,null,function*(){if(!this.texture){let e=this.texture=yield this.loadTexture(this.config.texture_url);e.wrapS=e.wrapT=Pm}return this.updatePoints(t)})}getBoundingBox(){return this.mesh?(this.mesh.geometry.computeBoundingBox(),new bm().copy(this.mesh.geometry.boundingBox).applyMatrix4(this.mesh.matrixWorld)):null}dispose(){var t,e,i;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.texture)==null||i.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=va,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let i=this.navigation.bmap.context.camera.zoom;i!==this.prevCameraZoom&&(this.prevCameraZoom=i,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:i,height:s}=this.navigation.bmap.context.clientSize;this.material.resolution.set(i,s)}},this.config=Object.assign({},va,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};import{Tween as Am}from"@tweenjs/tween.js";import{AnimationMixer as Sm,Box3 as Cm,Object3D as xa,Vector3 as Tm,Mesh as Lm,Euler as km}from"three";var Bs=class extends xa{meshSetMaterial(t){t instanceof Lm&&(t.material.emissiveIntensity=.5,t.material.shininess=0,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map,t.material.transparent=!0,t.material.depthTest=!1,t.renderOrder=1e6),t.children.forEach(i=>{this.meshSetMaterial(i)})}getBaseScale(t){let{clientSize:{height:e},camera:i}=this.bmap.context,o=(i.top-i.bottom)/i.zoom/e;return this.options.size*o/this.modelMaxLength}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}lookAtCamera(){if(this.model&&this.bmap&&this.bmap.context){let t=this.bmap.context.camera,e=new km;e.setFromQuaternion(t.quaternion,"ZYX"),this.group.rotation.copy(e)}}setClips(t){this.clearClips(),t.length&&(this.mixer=new Sm(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&F(this.model.scene),this.bmap=null}constructor(t,e,i={}){super(),this.bmap=t,this.group=new xa,this.mixer=null,this.previewTime=0,this.modelMaxLength=0,this.options={size:40},this._update=()=>{let s=Date.now();if(!this.previewTime)this.previewTime=s;else{var o;let n=s-this.previewTime;this.previewTime=s,(o=this.mixer)==null||o.update(n/1e3)}this.lookAtCamera()},this._onChangeZoom=s=>{let{zoom:o}=s;var n;if(!this.model)return;let r=this.getBaseScale(this.model.scene);(n=this.model)==null||n.scene.scale.set(r,r,r)},this.options=w({},this.options,i),this.add(this.group),pt.loadModel(e,!1).then(s=>{this.model=s;let n=new Cm().setFromObject(s.scene).getSize(new Tm),r=Math.max(n.x,n.y,n.z);this.modelMaxLength=r;let h=this.getBaseScale(s.scene);s.scene.scale.set(h,h,h),this.meshSetMaterial(s.scene),this.group.add(s.scene),this.setClips(s.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};import{Vector3 as Ho}from"three";var wa=class extends N{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(i=>w({},i,{points:this.translatePoints(i.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let i=()=>{this.bmap.removeEventListener("center-change",i),this.renderPath(e)};this.bmap.addEventListener("center-change",i)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){return g(this,null,function*(){if(!t.length)return this.clearPath();let e=[];t.forEach((i,s,o)=>{let n=this.mulFloor.floors.find(r=>r.name===i.floor);e.push(...i.points.map(r=>{let[h,c]=r;return[h,c,n.position.z+n.groundMaxHeight]}))}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new Gs(this),yield this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})})}catmullRomCurve3(t){return _i(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let i=Vt(t,e),s=t[i],o=t[i+1],n=new Ho(o[0]-s[0],o[1]-s[1],0).normalize(),r=new Ho(0,1,0).normalize(),h=n.angleTo(r),c=new Ho().crossVectors(r,n);return(Object.is(c.y,0)?-1:1)*h}startSimulation(t){return g(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:i}=this;if(!e.length)return;let s=e.reduce((n,r)=>n+r.distance,0);if(!s||i>=s)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=s/t;return this.startModel.startClips(),new Promise(n=>{let r=this.simulationTween=new Am({distance:this.movedDistance},this.tweenUtil.group).to({distance:s},o*1e3).onUpdate(h=>{var c;this.movedDistance=h.distance;let l=h.distance,p=0;for(let m=0;m<e.length;m++)if(e[m].distance>=l){p=m;break}else l-=e[m].distance;let d=xe(e[p].points,l);if(d===null)return;this.currentPathPosition=d;let u=this.translatePoints([d])[0],f=this.mulFloor.floors.find(m=>m.name===e[p].floor),x=f?f.position.z+f.groundMaxHeight:(c=this.startModel)==null?void 0:c.position.z;this.startModel&&this.startModel.position.set(u[0],u[1],x)}).onComplete(()=>{if(this.tweenUtil.remove(r),this.startModel.clearClips(),this.startModel){var h,c,l,p;let d=(l=e.slice(-1)[0])==null||(c=l.points)==null||(h=c.slice(-1))==null?void 0:h[0];if(!d)return;let u=this.mulFloor.floors.find(m=>{var y;return m.name===((y=e.slice(-1)[0])==null?void 0:y.floor)});if(!u)return;let f=u?u.position.z+u.groundMaxHeight:(p=this.startModel)==null?void 0:p.position.z,x=this.translatePoints([d])[0];this.startModel.position.set(x[0],x[1],f)}n(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-i)%360}}dispose(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent(),super.dispose()}constructor(t,e,i={}){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new ie,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Bs(t,lr,i.startModel),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Raycaster as Dm,Vector2 as Rm}from"three";var _a=class extends N{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose(),this.mulFloors=null,super.dispose()}constructor(t,e){super(t),this.mulFloors=e,this._click=i=>{let{e:s}=i;if(!this.mulFloors.showStatus)return;let o=new Rm,{offsetX:n,offsetY:r}=s,h=this.mulFloors.floors.map(d=>d.poiLayer2.getPoiByDeviceXy(n,r)).flat(2),{clientSize:c}=this.bmap.context;o.x=n/c.width*2-1,o.y=r/c.height*-2+1;let l=new Dm;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.floors.map(d=>d.graphicLayer.getGraphicByRaycaster(l).graphics).flat();this.dispatchEvent({type:"select",pois:h,graphics:p})},this.clickHelper=new bi(this.bmap.context.container),this.registryEvent()}};import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.find-last-index.js";import"core-js/modules/es.array.find-last.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.sort.js";import{Vector2 as ai}from"three";function ba(a){let t=a.length,e=0,i=0,s=0,o=0;a.forEach(c=>{e+=c[0],i+=c[1],s+=c[0]*c[1],o+=c[0]*c[0]});let n=t*o-e*e;if(n===0)return{m:0,b:0};let r=(t*s-e*i)/n,h=(i-r*e)/t;return{m:r,b:h}}function Om(a){let t=a.length,e=0,i=0,s=0,o=0;a.forEach(h=>{e+=h[0],i+=h[1],s+=h[0]*h[1],o+=h[0]*h[0]});let n=(t*s-e*i)/(t*o-e*e),r=(i-n*e)/t;return{m:n,b:r}}function Fm(a,t,e){let i=e[0][0],s=e.slice(-1)[0][0],o=a*i+t,n=a*s+t;return{start:[i,o],end:[s,n]}}function zs(a){if(a.length<2)return null;let t=a.filter((h,c)=>{let l=[...a];return l.splice(c,1),l.every(p=>p[0]!==h[0]&&p[1]!==h[1])});if(t.length<2)return null;let{m:e,b:i}=Om(t),{start:s,end:o}=Fm(e,i,t),r=(360-new ai().subVectors(new ai(o[0],o[1]),new ai(s[0],s[1])).angle()*180/Math.PI)%360;return Number.isNaN(r)?null:r}function qA(a){let t=[];for(let e=1;e<a.length;e++){let i=a[e-1],s=a[e],o=s.position[0]-i.position[0],n=s.position[1]-i.position[1],r=Math.sqrt(o**2+n**2),h=s.time-i.time;if(h>0){let c=r/h;console.log("speedDelta",i.type,s.type,No(c),r,h),t.push(c)}else t.push(0)}return t}function $A(a,t){let e=a[0],i=a.slice(-1)[0],s=A(i.position,e.position),o=i.time-e.time;return o<100||s<3?null:s/o}function No(a){return a*60*60}function hi(a,t,e,i){let s=(e+90)%360*(Math.PI/180),o=t*i,n=new ai(a[0],a[1]),r=Math.cos(s),h=Math.sin(s),c=new ai(r,h);return n.add(c.normalize().multiplyScalar(o)),[n.x,n.y]}function JA(a){let t=[...a].sort((c,l)=>c-l),e=Pa(t,25),i=Pa(t,75),s=i-e,o=e-1.5*s,n=i+1.5*s,r=t.filter(c=>c>=o&&c<=n);return a.filter(c=>r.includes(c))}function Pa(a,t){let e=t/100*(a.length-1),i=Math.floor(e),s=Math.ceil(e);if(i===s)return a[i];let o=e-i;return a[i]*(1-o)+a[s]*o}import{isNil as Ws}from"lodash";var Us=class extends st{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),Ws(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(m=>["vision"].includes(m.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[t.length-1].time,i=5e3;if(t[t.length-1].clientTime<Date.now()-1e3)return this.speed;let s=t.filter(m=>e-m.time<=i);if(s.length<5)return this.speed;let o=[];for(let m=0;m<s.length;m++){if(m===0){o.push(s[m]);continue}let y=s[m-1],_=s[m];_.time-y.time<2e3&&o.push(_)}if(o.length<2)return this.speed;let n=o[0].time,r=o[0].position,h=o.map((m,y)=>{let _=m.time-n,P=A(m.position,r);return[_,P]}),{m:c}=ba(h),l=Math.max(c,0),p=15/3600;l>p&&console.warn("\u901F\u5EA6\u8D85\u8FC715km/h:",{speed_m_ms:l,speed_km_h:l*3600,points:o.map((m,y)=>({index:y+1,type:m.type,time:m.time,clientTime:m.clientTime,position:m.position})),relativeTimesAndDistances:h,totalDistance:A(o[o.length-1].position,o[0].position),totalTime:o[o.length-1].time-o[0].time,pointPairs:o.slice(1).map((m,y)=>({prevIndex:y+1,prevType:o[y].type,currIndex:y+2,currType:m.type,timeDiff:m.time-o[y].time,distance:A(m.position,o[y].position)}))});let d=2/1e3,u=Date.now(),f=u-this._lastSpeedUpdateTime;if(this._lastSpeedUpdateTime=u,this.speed!==0&&l!==0){let m=d*f;Math.abs(l-this.speed)>m&&(l=l>this.speed?this.speed+m:this.speed-m)}let x=this.speedFilter.filter(l);this.speed=x}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=zs(t.map(i=>i.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,i){this.lastExternalPositionTime=Date.now();let s={position:t,time:e,clientTime:Date.now()-i,type:"vision"};if(this._setVisionHistoryForAngle(s),Ws(this.angle)||!this.speed){this.addHistory(s);return}let o=this.history.findLastIndex(r=>r.type==="vision"),n=this.history[o];if(n){if(n.time>e)return;let r=zs([this.history.slice(-1)[0].position,t]);if(r&&Math.abs(r-this.angle)<60){this.addHistory(s);return}let h=hi(t,this.speed,360-this.pathAngle,i);A(h,this.history.slice(-1)[0].position)>5?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(s),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=hi(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(i=>i.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(this.visionHistory.length<3){this.visionHistory.push(t);return}let e=zs([...this.visionHistory.slice(-3).map(i=>i.position),t.position]);if(e!==null&&this.angle!==null){let i=Math.abs(this.angle-e),s=Math.min(i,360-i);this.angle&&s>90?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))}if(this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63",e,this.angle,this.pathAngle),this.visionHistory=[t],this.angleExcessesCount=0;else{let i=A(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;i>5&&this.visionHistory.length>15;)this.visionHistory.shift(),i=A(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(r=>r.type==="vision"),i=e.length?Date.now()-e.slice(-1)[0].clientTime:0,s=A(this.history[0].position,this.history.slice(-1)[0].position),o=i>5e3?10:3,n=i>5e3?0:5;for(i>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>n&&s>o;)this.history.shift(),e=this.history.filter(r=>r.type==="vision"),s=A(this.history[0].position,this.history.slice(-1)[0].position);n===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,i){this.lastExternalPositionTime=Date.now();let s=Date.now()-i,o={position:t,time:e,clientTime:s,type:"beacon"},n=this.history.findLastIndex(l=>l.type!=="pdr"),r=this.history[n];if(!r){this.addHistory(o);return}if(Ws(this.pathAngle)||!this.speed){this.addHistory(o);return}if(r&&r.time>e)return;let h=hi(t,this.speed,360-this.pathAngle,i);A(h,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}stopPositionTimer(){this.positionTimer&&(this.timer.clearInterval(this.positionTimer),this.positionTimer=null)}changePosition(t){t===void 0&&(t="pdr");let e=Date.now()-this.lastExternalPositionTime;if(this.lastExternalPositionTime>0&&e>1e4){console.warn("\u8FDE\u7EED10s\u6CA1\u6709\u5916\u90E8\u5B9A\u4F4D\u7ED3\u679C\uFF0C\u505C\u6B62\u53D1\u9001\u60EF\u5BFC\u5B9A\u4F4D\u7ED3\u679C");return}let i=this.getPosition(t);i.success&&(this.history.push({position:i.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:w({},i)}):this.dispatchEvent({type:"change-pos",value:i}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if(Ws(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let i=e.clientTime,s=Date.now()-i;return{success:!0,pos:this.pathAngle?hi(e.position,this.speed,360-this.pathAngle,s):e.position,compass:this.pathAngle,speed:No(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new K,this.positionTimer=null,this.speedFilter=new Ei,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.lastExternalPositionTime=0,this._lastSpeedUpdateTime=0,this.startPositionTimer(),this._lastSpeedUpdateTime=Date.now()}};import"core-js/modules/es.json.stringify.js";function Zo(){return new Worker(new URL("./worker/recommend.worker-PJJHK4IP.js",import.meta.url))}import"core-js/modules/es.array.push.js";var Hs=class{setRoadData(t,e){this.roadNetwork.initRoute(t,e),this.roadReadyResolve(!0)}setRoadNetwork(t){this.roadNetwork=t}recommend(t,e,i,s,o){return g(this,null,function*(){yield this.roadReadyPromise;let n=e.reduce((l,p)=>(l[p.floor]?l[p.floor].push(p):l[p.floor]=[p],l),{}),r=this.roadNetwork.roadInfo.map(l=>l.floor),h=this.transformStart(t);if(!h)return null;let c=i?this.transformEnd(i):null;if(o){let l=e.filter(p=>{let d=this.roadNetwork.getParkingSpaceInfo(p.floor,p.lot_id);return d?d.parkingType===o:!1});if(l.length>0){let p=l.reduce((d,u)=>(d[u.floor]?d[u.floor].push(u):d[u.floor]=[u],d),{});if(c){let d=this.recommendByEnd(h,c,p,r,s);if(d)return d}else{let d=this.recommendByStart(h.floor,h.coord,h.routePointId,p,r,s);if(d)return d}}}return c?this.recommendByEnd(h,c,n,r,s):this.recommendByStart(h.floor,h.coord,h.routePointId,n,r,s)})}dispose(){this.roadNetwork.clear()}getFloorCarByDistance(t,e,i){let{floor:s,coord:o,routePointId:n}=t,r=null;return(e||[]).forEach(h=>{let c=this.roadNetwork.getPath({floor:s,coord:o,routePointId:n},{floor:h.floor,parkingSpace:h.lot_id},"forward",0,i);if(c==="near"){r={floor:h.floor,spaceNo:h.lot_id,distance:0};return}if(!c||typeof c=="string")return;let l={floor:h.floor,spaceNo:h.lot_id,distance:c[0].consume};r||(r=l),r.distance>l.distance&&(r=l)}),r}recommendByStart(t,e,i,s,o,n){let r=this.getFloorCarByDistance({floor:t,coord:e,routePointId:i},s[t],n);return r||this.recommendByStartNearFloor(t,e,i,s,o,n)}recommendByStartNearFloor(t,e,i,s,o,n){let r=o.indexOf(t);r===-1&&(r=o.length);let h=1,c=null;for(;h<=o.length;){if(o.filter((p,d)=>d===r-h||d===r+h).forEach(p=>{let d=this.getFloorCarByDistance({floor:t,coord:e,routePointId:i},s[p],n);c?d&&c.distance>d.distance&&(c=d):c=d}),c)return c;h++}return c}recommendByEnd(t,e,i,s,o){console.time("recommendByEnd");let n=this.recommendFloorCarByEndDistance(t,e,e.floor,i,o);if(n)return n;console.timeEnd("recommendByEnd"),console.time("recommendByStart");let r=this.recommendFloorCarByEndDistance(t,e,t.floor,i,o);return console.timeEnd("recommendByStart"),r||this.recommendByStartNearFloorAndEnd(t,e,t.floor,i,s,o)}recommendFloorCarByEndDistance(t,e,i,s,o){let n=s[i]||[];if(!n.length)return null;let r=null;return n.forEach(h=>{let c=this.roadNetwork.getParkingSpaceInfo(h.floor,h.lot_id);if(!c)return;console.time("path2");let l=this.roadNetwork.getPath({floor:h.floor,routePointId:c.id},e,"",0);if(console.timeEnd("path2"),l==="near"){r={floor:h.floor,spaceNo:h.lot_id,distance:0};return}if(!l||typeof l=="string")return;let p={floor:h.floor,spaceNo:h.lot_id,distance:l[0].consume},d={floor:h.floor,routePointId:c.id};if(r){if(r.distance>p.distance){console.count("forward");let u=this.roadNetwork.getPath(t,d,"forward",0,o);if(!u||typeof u=="string"&&u!=="near")return;r=p}}else{console.count("forward");let u=this.roadNetwork.getPath(t,d,"forward",0,o);if(!u||typeof u=="string"&&u!=="near")return;r=p}}),r}recommendByStartNearFloorAndEnd(t,e,i,s,o,n){let r=o.indexOf(i);r===-1&&(r=o.length);let h=1,c=null;for(;h<=o.length;){if(o.filter((p,d)=>d===r-h||d===r+h).forEach(p=>{let d=this.recommendFloorCarByEndDistance(t,e,p,s,n);c?d&&c.distance>d.distance&&(c=d):c=d}),c)return c;h++}return c}transformStart(t){if(t.routePointId)return{floor:t.floor,routePointId:t.routePointId};if(t.coord)return{floor:t.floor,coord:t.coord};if(t.nodeId){let e=this.roadNetwork.getNodeInfo(t.floor,t.nodeId);if(e)return{floor:e.floor,coord:e.cds}}return null}transformEnd(t){if(t.routePointId&&t.floor)return{floor:t.floor,routePointId:t.routePointId};if(t.coord)return{floor:t.floor,coord:t.coord};if(t.nodeId){let e=this.roadNetwork.getNodeInfo(t.floor,t.nodeId);if(e)return{floor:e.floor,coord:e.cds}}if(t.parkingSpace){let e=this.roadNetwork.getParkingSpaceInfo(t.floor,t.parkingSpace);if(e)return{floor:e.floor,coord:e.cds,routePointId:e.id}}return null}constructor(){this.roadNetwork=new we,this.roadReadyPromise=new Promise(t=>{this.roadReadyResolve=t})}};var Im={placeId:0,catLotStatusApi:"https://screen.aibee.cn/ai-map/car-park/car-lot-status",useWorker:!1},Ma=class{setRoadData(t,e){return this.options.useWorker&&this.worker?H(this.worker,"set_road_info",{roadData:t,facilities:e}):(this.recommendCore&&this.recommendCore.setRoadData(t,e),Promise.resolve())}recommend(t){return g(this,null,function*(){let e=yield fetch(this.options.catLotStatusApi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({place_id:+this.options.placeId})}).then(i=>i.json()).then(i=>i.data.filter(s=>s.status===0)).then(i=>{var s;return i.filter((s=this.options.filterCarLotStatus)!=null?s:()=>!0)});return this.options.useWorker&&this.worker?H(this.worker,"recommend",w({},t,{carLotStatus:e})):this.recommendCore?this.recommendCore.recommend(t.start,e,t.end,t.travelDirection,t.parkingType):null})}dispose(){this.worker&&(this.worker.terminate(),this.worker=null),this.recommendCore&&(this.recommendCore.dispose(),this.recommendCore=null)}constructor(t={}){this.worker=null,this.recommendCore=null,this.options=w({},Im,t),this.options.useWorker?this.worker=Zo():this.recommendCore=new Hs}};import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.url-search-params.js";import"core-js/modules/web.url-search-params.delete.js";import"core-js/modules/web.url-search-params.has.js";import"core-js/modules/web.url-search-params.size.js";import"core-js/modules/es.json.stringify.js";var Gm={url:"",reconnect:!0,heartBeat:2e3,heartMsg:JSON.stringify({command:"PING"}),reconnectTime:3e3,reconnectMaxCount:1e6,noMessageTime:6e3},ci=class extends st{initWebsocket(){this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{this.alive=!0,this.startHeart(),this.startOnMessageTimer(),this.stopReconnect(),this.dispatchEvent({type:"open"})},this.ws.onerror=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect(),this.registryEvent()},this.ws.onclose=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect()},this.ws.onmessage=t=>{this.startOnMessageTimer(),this.dispatchEvent({type:"message",message:t})}}startHeart(){this.stopHeart(),this.heartTimer=this.timer.setInterval(()=>{this.send(this.options.heartMsg)&&this.dispatchEvent({type:"send-heart"})},this.options.heartBeat)}stopHeart(){this.heartTimer&&(this.timer.clearInterval(this.heartTimer),this.heartTimer=null)}startReconnect(t){t===void 0&&(t=this.options.reconnectTime),this.stopReconnect(),this.options.reconnect&&(this.options.reconnectMaxCount--,this.options.reconnectMaxCount>=0&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.initWebsocket()},t)))}stopReconnect(){this.reconnectTimer&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}startOnMessageTimer(){this.stopOnMessageTimer(),this.noMessageTimer=this.timer.setTimeout(()=>{var t;(t=this.ws)==null||t.close(),this.dispatchEvent({type:"no-message-timeout"})},this.options.noMessageTime)}stopOnMessageTimer(){this.noMessageTimer&&(this.timer.clearTimeout(this.noMessageTimer),this.noMessageTimer=null)}send(t){var e;let i=typeof t=="string"?t:JSON.stringify(t);return this.alive&&((e=this.ws)==null?void 0:e.readyState)===1?(this.ws.send(i),this.dispatchEvent({type:"send-success",msg:i}),!0):(this.dispatchEvent({type:"send-fail",msg:i}),!1)}registryEvent(){window.addEventListener("online",this.onOnline)}unRegistryEvent(){window.removeEventListener("online",this.onOnline)}close(){var t;this.unRegistryEvent(),this.options.reconnect=!1,this.alive=!1,this.stopHeart(),this.stopReconnect(),this.stopOnMessageTimer(),(t=this.ws)==null||t.close(),this.ws=null,this.dispatchEvent({type:"close"})}dispose(){this.close(),this.timer.dispose(),super.dispose()}constructor(t){super(),this.ws=null,this.alive=!1,this.timer=new K,this.heartTimer=null,this.reconnectTimer=null,this.noMessageTimer=null,this.onOnline=()=>{this.startReconnect()},this.options=w({},Gm,t||{}),this.options.url&&this.initWebsocket()}};import{isNil as Ea}from"lodash";var jo=a=>{let t=a.toString(2),e=""+Array(16-t.length+1).join("0")+t,i=parseInt(e.slice(0,4),2)*10,s=parseInt(e.slice(4,16),2);return[i,s]};var Sa=class extends st{initPositionWebSocket(){let t=w({},this.options.ext_position_params,{place_id:this.options.place_id,token:this.options.access_token}),e=Object.keys(t).filter(i=>!Ea(t[i])).map(i=>i+"="+t[i]).join("&");this.positionWebSocket=new ci({url:this.options.wss_position_url+"?"+e}),this.positionWebSocket.addEventListener("message",i=>{let{message:s}=i,o=(()=>{try{return JSON.parse(s.data)}catch(I){return s.data}})();if(this.dispatchEvent({type:"ws-message",data:o}),o.command==="POSITION_RESULT"&&o.data.success)if(["POSITION","FLOOR","PARK_POSITION","AOA"].includes(o.data.success_type)&&this.useGpsFloorTimer&&(this.positionFloor=o.data.floor,this.timer.clearTimeout(this.useGpsFloorTimer),this.useGpsFloorTimer=null),o.data.success_type==="AOA"){let{x:I,y:D,time:V,floor:Z,ts:Ot}=o.data,Ft=this.positionFloor!==Z;if(this.positionFloor=Z,this.dispatchEvent({type:"ws-position",floor:Z,x:I,y:D,time:V,_type:"aoa"}),this.options.upload_position){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:D,floor:Z,type:"aoa"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:Z,x:I,y:D,time:new Date(Ot).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var r;if(Ft){var h,c,l;(l=this.pdrPosition)==null||(c=l.pdr)==null||(h=c.particleFilter)==null||h.setPosInitFlag(!1)}(r=this.pdrPosition)==null||r.setBeaconPosition({x:I,y:D},new Date(Ot).getTime()-o.lag-o.duration)}else if(Ft){var p;if(this.resetPdr(),(p=this.carInertialPosition)==null||p.stopPositionTimer(),this.path){let Qt=this.path.findIndex(Ie=>Ie.floor===Z),Ut=this.path[Qt];if(Ut){var d;this.resetPdr(),(d=this.carInertialPosition)==null||d.setBeaconPosition(Ut.points[0],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var u;(u=this.carInertialPosition)==null||u.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var f;(f=this.carInertialPosition)==null||f.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var x;(x=this.carInertialPosition)==null||x.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="POSITION"){let{x:I,y:D,time:V,floor:Z,ts:Ot}=o.data,Ft=this.positionFloor!==Z;if(this.positionFloor=Z,this.dispatchEvent({type:"ws-position",floor:Z,x:I,y:D,time:V,_type:"beacon"}),console.log("positionFloor",Z,Ft),this.options.upload_position){var m;(m=this.positionWebSocket)==null||m.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:D,floor:Z,type:"originBeacon"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:Z,x:I,y:D,time:new Date(Ot).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var y;if(Ft){var _,P,S;(S=this.pdrPosition)==null||(P=S.pdr)==null||(_=P.particleFilter)==null||_.setPosInitFlag(!1)}(y=this.pdrPosition)==null||y.setBeaconPosition({x:I,y:D},new Date(Ot).getTime()-o.lag-o.duration)}else if(Ft){var E;if(this.resetPdr(),(E=this.carInertialPosition)==null||E.stopPositionTimer(),this.path){let Qt=this.path.findIndex(Ie=>Ie.floor===Z),Ut=this.path[Qt];if(Ut){var k;this.resetPdr(),(k=this.carInertialPosition)==null||k.setBeaconPosition(Ut.points[0],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var M;(M=this.carInertialPosition)==null||M.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var G;(G=this.carInertialPosition)==null||G.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var R;(R=this.carInertialPosition)==null||R.setBeaconPosition([I,D],new Date(V).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="PARK_POSITION"&&o.data.success){if(this.options.type===1){let{x:I,y:D,time:V,floor:Z}=o.data,Ot=this.positionFloor!==Z;if(this.positionFloor=o.data.floor,this.dispatchEvent({type:"ws-position",floor:Z,x:I,y:D,time:V,_type:"vision"}),!this.options.use_pdr){this.dispatchEvent({type:"position",floor:Z,x:I,y:D,time:new Date(V).getTime()});return}if(Ot){var O;if(this.resetPdr(),(O=this.carInertialPosition)==null||O.stopPositionTimer(),this.path){let Ft=this.path.findIndex(Ut=>Ut.floor===Z),Qt=this.path[Ft];if(Qt){var $;this.resetPdr(),($=this.carInertialPosition)==null||$.setPosition(Qt.points[0],new Date(V).getTime(),o.duration)}else{var nt;(nt=this.carInertialPosition)==null||nt.setPosition([I,D],new Date(V).getTime(),o.duration)}}else{var W;(W=this.carInertialPosition)==null||W.setPosition([I,D],new Date(V).getTime(),o.duration)}}else{var J,z;if((J=this.carInertialPosition)==null||J.setPosition([I,D],new Date(V).getTime(),o.duration),!((z=this.carInertialPosition)!=null&&z.positionTimer)){var mt;(mt=this.carInertialPosition)==null||mt.startPositionTimer()}}if(this.options.upload_position){var Q;(Q=this.positionWebSocket)==null||Q.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:D,floor:Z,type:"vision"}),serverData:JSON.stringify(o)})}}}else this.dispatchEvent({type:"floor",floor:o.data.floor,time:o.data.time})})}initSensorWebSocket(){let t=w({},this.options.ext_sensor_params,{token:this.options.access_token,place_id:this.options.place_id,record_sensor:1}),e=Object.keys(t).filter(i=>!Ea(t[i])).map(i=>i+"="+t[i]).join("&");this.sensorWebSocket=new ci({url:this.options.wss_sensor_url+"?"+e})}initPdr(){this.options.type===1?(this.carInertialPosition=new Us,this.carInertialPosition.addEventListener("change-pos",t=>{let{value:e}=t,{pos:i,success:s,speed:o}=e;if(s&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:i[0],y:i[1],time:Date.now(),speed:o}),this.options.upload_position)){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:i[0],y:i[1],floor:this.positionFloor,type:"vision_pdr"})})}}),this.carInertialPosition.addEventListener("change-compass",t=>{let{value:e}=t;this.dispatchEvent({type:"compass",value:e})})):(this.pdrPosition=new Rs(this.bmap,{pdr:{using_gps:this.options.use_gps},sensor:{elements:[B.COMPASS,B.ACCELERATION,B.DEVICE_MOTION].concat(this.options.use_gps?[B.GPS]:[])}}),this.requestDeviceOrientationPermission(),this.options.upload_position&&this.pdrPosition.sensor.addEventListener("sensor-data",t=>{let{data:e}=t;var i;(i=this.positionWebSocket)==null||i.send({command:"UPLOAD_SENSOR",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify(e)})}),this.pdrPosition.sensor.addEventListener("add-data-item",t=>{t.item.type==="compass"&&this.dispatchEvent({type:"compass",value:t.item.res})}),this.pdrPosition.addEventListener("position",t=>{let{x:e,y:i,_type:s}=t;if(console.log("_type",s,e,i,this.positionFloor,this.gpsFloor),s==="gps"&&!this.useGpsFloorTimer){let n=()=>{this.useGpsFloorTimer=this.timer.setTimeout(()=>{this.gpsFloor?this.positionFloor=this.gpsFloor:n()},5e3)};n()}if(this.positionFloor&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:e,y:i,time:Date.now()}),this.options.upload_position)){var o;(o=this.positionWebSocket)==null||o.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:e,y:i,floor:this.positionFloor,type:s})})}}))}setSensor(t){this.pdrPosition&&this.pdrPosition.setSensor(t)}requestDeviceOrientationPermission(){return g(this,null,function*(){if(this.pdrPosition){let t=yield this.pdrPosition.checkSensor();return t.deviceOrientation?this.pdrPosition.start():(this.dispatchEvent(w({type:"check-sensor"},t)),!t.deviceOrientation&&this.options.use_default_permission),t}else return null})}getGpsFloor(){return g(this,null,function*(){if(this.options.use_gps&&this.options.get_gps_floor_url){let t=yield fetch(this.options.get_gps_floor_url+"/"+this.options.place_id).then(e=>e.json());t.code===200&&(this.gpsFloor=t.data.gps_floor)}})}pausePdr(){if(this.options.type===1){var t;(t=this.carInertialPosition)==null||t.stopPositionTimer()}else{var e;(e=this.pdrPosition)==null||e.pause()}}continuePdr(){if(this.options.type===1)this.carInertialPosition&&(this.carInertialPosition.positionTimer||this.carInertialPosition.startPositionTimer());else{var t;(t=this.pdrPosition)==null||t.continue()}}setPathAngle(t){if(this.options.type===1){var e;(e=this.carInertialPosition)==null||e.setPathAngle(t)}}getForwardAngle(){if(this.options.type===1){var t,e;return(e=(t=this.carInertialPosition)==null?void 0:t.angle)!=null?e:null}else return null}resetPdr(){this.carInertialPosition&&(this.carInertialPosition.history=[],this.carInertialPosition.setPathAngle(0),this.carInertialPosition.speed=0),this.pdrPosition&&this.pdrPosition.pdr.particleFilter.setPosInitFlag(!1)}setPath(t){this.path=t}sendBeacon(t){var e;let i=[];if(ee)i=t.map(o=>{let[n,r]=jo(o.major);return[o.uuid,r,o.minor,o.rssi,o.accuracy,n]}).filter(o=>o[3]!==0).sort((o,n)=>n[3]-o[3]);else{let o=t.reduce((n,r)=>{var h,c;let[l,p]=jo(r.major),d=""+p+r.minor;return(h=n)[c=d]||(h[c]=[]),n[d].push(w({},r,{battery:l,major:p})),n},{});Object.entries(o).forEach(n=>{let[r,h]=n,{uuid:c,major:l,minor:p,accuracy:d,battery:u}=h[0];if(h.length>1){let f=h.filter(m=>m.rssi<0),x=f.reduce((m,y)=>m+y.rssi,0);i.push([c,l,p,x/f.length,d,u])}else i.push([c,l,p,h[0].rssi,d,u])})}let s={command:"POSITION",index:this.uploadIndex++,ts:Date.now(),beacons:JSON.stringify([{type:"ibeacon",timestamp:Date.now()/1e3,res:i}]),ext_sensors:JSON.stringify({})};(e=this.sensorWebSocket)==null||e.send(s)}dispose(){var t,e,i,s;this.timer.dispose(),(t=this.positionWebSocket)==null||t.dispose(),this.positionWebSocket=null,(e=this.sensorWebSocket)==null||e.dispose(),this.sensorWebSocket=null,(i=this.pdrPosition)==null||i.dispose(),this.pdrPosition=null,(s=this.carInertialPosition)==null||s.dispose(),this.carInertialPosition=null,super.dispose()}constructor(t,e){super(),this.bmap=t,this.positionWebSocket=null,this.sensorWebSocket=null,this.pdrPosition=null,this.carInertialPosition=null,this.gpsFloor="",this.positionFloor="",this.useGpsFloorTimer=null,this.uploadIndex=0,this.path=null,this.timer=new K;let i=location.href.indexOf("?"),s=i!==-1?location.href.slice(i):location.search,o=new URLSearchParams(s),n=o.get("server_env")||"prod",r={test:"nav-test.aibee.cn",prod:"nav.aibee.cn"},h="wss://"+r[n]+"/aether-walker/indoor/position",c="wss://"+r[n]+"/aether-walker/indoor/sensor";this.options=w({place_id:o.get("place_id"),access_token:o.get("access_token"),env:n,wss_position_url:h,wss_sensor_url:c,get_gps_floor_url:"https://"+r[n]+"/aether-walker/indoor/conf",use_sensor:!1,type:-1,use_gps:!0,use_pdr:!0,upload_position:!0,use_default_permission:!0,ext_position_params:{},ext_sensor_params:{}},e),this.initPositionWebSocket(),this.options.use_sensor&&this.initSensorWebSocket(),this.options.use_pdr&&this.initPdr(),this.options.use_gps&&this.getGpsFloor()}};import"core-js/modules/web.dom-collections.iterator.js";var Ca=class extends N{showMyPosition(t,e){var i;let s=(i=this.bmap.context.currentFloor)==null?void 0:i.getGraphicPosition(t);if(s){let o=new Ee(this.bmap.context,{autoUpdate:!0,appendToBody:!1});o.div.appendChild(e),o.position.copy(this.bmap.mercatorToWorld(s)),this.myPositionOverlay=o,console.log("graphicPos",s,this)}else console.warn("[showMyPosition] \u6CA1\u6709\u627E\u5230\u56FE\u5143\u6240\u5728\u7684\u4F4D\u7F6E")}hideMyPosition(){this.myPositionOverlay&&(this.myPositionOverlay.dispose(),this.myPositionOverlay=null)}dispose(){this.hideMyPosition()}constructor(...t){super(...t),this.myPositionOverlay=null}};var Ta=class extends N{highlightPoi(t,e){e===void 0&&(e={icon_size:[40,40],collision_enable:!1}),t.map(s=>this.bmap.getPoiById(s)).filter(s=>!!s).forEach(s=>{var o;(o=s.userData).restore||(o.restore={});for(let h in e)if(h in s.options){var n,r;(n=s.userData.restore)[r=h]||(n[r]=s.options[h]),s.options[h]=e[h]}})}restorePoi(t){t.map(i=>this.bmap.getPoiById(i)).filter(i=>!!i).forEach(i=>{console.log("poi.userData.restore",i.userData.restore);for(let s in i.userData.restore)s in i.options&&(i.options[s]=i.userData.restore[s]);i.userData.restore={}})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";var La=class extends N{sortByDistance(t,e,i){return g(this,null,function*(){i===void 0&&(i=!1);let s=[...e];if(i||e.length<20)return yield Promise.all(s.map(o=>g(this,null,function*(){o.distance=yield this._getDistance(t,{floor:o.floor,x:o.center_x,y:o.center_y})}))),s.sort((o,n)=>o.distance-n.distance);{let o=s.sort((r,h)=>{let c=Math.sqrt((r.center_x-t.x)**2+(r.center_y-t.y)**2)+(t.floor===r.floor?0:100),l=Math.sqrt((h.center_x-t.x)**2+(h.center_y-t.y)**2)+(t.floor===h.floor?0:100);return c-l});return[...(yield Promise.all(o.slice(0,20).map(r=>g(this,null,function*(){return r.distance=yield this._getDistance(t,{floor:r.floor,x:r.center_x,y:r.center_y}),r})))).sort((r,h)=>r.distance-h.distance),...o.slice(20)]}})}_getDistance(t,e){return g(this,null,function*(){return this.navPath.getPath({floor:t.floor,coord:[t.x,t.y]},{floor:e.floor,coord:[e.x,e.y]},"",0).then(i=>i.reduce((s,o,n)=>{if(s+=o.distance,n!==i.length-1)switch(o.endType){case"escalator":case"straightLadder":case"staircase":case"ramp":s+=100;break}return s},0)).catch(i=>i==="near"?0:1/0)})}dispose(){super.dispose(),this.needDisposeNavPath&&this.navPath.dispose()}constructor(t,e){if(super(t),this.needDisposeNavPath=!1,e)this.navPath=e;else{this.navPath=new Ss;let i=new Oe(t);this.needDisposeNavPath=!0,i.load(t.config.apiPath.loadPlaceInfo+"?place_id="+t.config.placeId+"&env=prod").then(s=>g(this,null,function*(){let[o,n]=yield Promise.all([i.getRoadNetworkData(),i.getFacilitiesData()]);this.navPath.setRoadData(o,n.infrastructures)}))}}};var Bm="https://robot-vr-public.bj.bcebos.com/v1/static_resource/satellite_tiles",zm={base_url:Bm},ka=class extends N{setVisible(t){this.tileLayer.setVisibility(t)}dispose(){this.bmap.context.scene.remove(this.tileLayer),this.tileLayer.dispose(),super.dispose()}constructor(t,e){super(t),this.options=w({},zm,e),this.tileLayer=new ue(t.context,this.options),this.tileLayer.position.z=-1,this.bmap.context.scene.add(this.tileLayer)}};import{Box3 as Wm,Group as Um}from"three";var Aa=class extends N{addHeatmap(t,e){this.heatmap||(this.heatmap=new Yi(this.bmap.context),this.group.add(this.heatmap)),this.heatmap.loadData(t);let i=new Wm().setFromObject(e.graphicLayer);return this.heatmap.position.setZ(i.max.z+.1),this.heatmap}removeHeatMap(){this.heatmap&&(this.group.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=null)}dispose(){this.removeHeatMap(),this.bmap.context.scene.remove(this.group)}constructor(t){super(t),this.heatmap=null,this.group=new Um,this.bmap.context.scene.add(this.group)}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.reverse.js";import{Group as Hm,Vector3 as li,Raycaster as Nm,Vector2 as Zm,Plane as jm,Box3 as Vm}from"three";import"core-js/modules/es.array.push.js";var Ns=class extends dt{updateRectPreview(t,e,i){i===void 0&&(i=!1);let s=Math.min(t.x,e.x),o=Math.min(t.y,e.y),n=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);this.previewElement||(this.previewElement=gt(this.options.strokeColor,"none"),this.previewElement.setAttribute("stroke-opacity",""+this.options.strokeOpacity),this.svg.appendChild(this.previewElement)),j(this.previewElement,s,o,n,r),i&&this.updateRectPreviewFill(s,o,n,r)}updateRectPreviewFill(t,e,i,s){this.previewFillElement||(this.previewFillElement=document.createElementNS("http://www.w3.org/2000/svg","rect"),this.previewFillElement.setAttribute("fill",this.options.fillColor),this.previewFillElement.setAttribute("fill-opacity",""+this.options.fillOpacity),this.svg.insertBefore(this.previewFillElement,this.svg.firstChild)),j(this.previewFillElement,t,e,i,s)}updateCirclePreview(t,e){this.previewElement||(this.previewElement=Gt(String(e),"none"),this.previewElement.setAttribute("stroke",this.options.strokeColor),this.previewElement.setAttribute("stroke-opacity",""+this.options.strokeOpacity),this.svg.appendChild(this.previewElement)),yt(this.previewElement,t.x,t.y),this.previewElement.setAttribute("r",""+e)}updateCirclePreviewFill(t,e){this.previewFillElement||(this.previewFillElement=document.createElementNS("http://www.w3.org/2000/svg","circle"),this.previewFillElement.setAttribute("fill",this.options.fillColor),this.previewFillElement.setAttribute("fill-opacity",""+this.options.fillOpacity),this.previewFillElement.setAttribute("stroke","none"),this.svg.insertBefore(this.previewFillElement,this.svg.firstChild)),yt(this.previewFillElement,t.x,t.y),this.previewFillElement.setAttribute("r",""+e)}addPolygonPoint(t){this.points.push(t);let e=Gt(String(this.options.pointRadius),this.options.pointColor);if(yt(e,t.x,t.y),this.controlPoints.push(e),this.svg.appendChild(e),this.points.length>1){let i=this.points[this.points.length-2],s=Kt(this.options.strokeColor);s.setAttribute("stroke-opacity",""+this.options.strokeOpacity),rt(s,i,t),this.svg.appendChild(s),this.lines.push(s)}this.lastLine&&this.lastLine.parentNode&&this.svg.removeChild(this.lastLine),this.lastLine=Kt(this.options.strokeColor),this.lastLine.setAttribute("stroke-opacity",""+this.options.strokeOpacity),rt(this.lastLine,t,t),this.svg.appendChild(this.lastLine),this.updatePolygonFill()}updatePolygonPreview(t){if(this.points.length===0)return;this.currentMousePoint=t;let e=this.points[this.points.length-1];this.lastLine&&rt(this.lastLine,e,t),this.updatePolygonFill(t)}checkAdsorb(t){if(this.points.length<2)return!1;let e=this.points[0],i=t.x-e.x,s=t.y-e.y;return Math.sqrt(i*i+s*s)<=this.adsorbRadius}updatePolygonFill(t){if(this.points.length<2)return;this.polygonFillElement||(this.polygonFillElement=document.createElementNS("http://www.w3.org/2000/svg","polygon"),this.polygonFillElement.setAttribute("fill",this.options.fillColor),this.polygonFillElement.setAttribute("fill-opacity",""+this.options.fillOpacity),this.polygonFillElement.setAttribute("stroke","none"),this.svg.insertBefore(this.polygonFillElement,this.svg.firstChild));let e=[];for(let i=0;i<this.points.length;i++){let s=this.points[i];!isNaN(s.x)&&!isNaN(s.y)&&e.push(s.x+","+s.y)}t&&!isNaN(t.x)&&!isNaN(t.y)&&e.push(t.x+","+t.y),e.length>=3&&this.polygonFillElement.setAttribute("points",e.join(" "))}clear(){this.points=[],this.currentMousePoint=void 0,this.controlPoints.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.controlPoints=[],this.lines.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.lines=[],this.previewElement&&(this.previewElement.parentNode&&this.svg.removeChild(this.previewElement),this.previewElement=null),this.previewFillElement&&(this.previewFillElement.parentNode&&this.svg.removeChild(this.previewFillElement),this.previewFillElement=null),this.lastLine&&(this.lastLine.parentNode&&this.svg.removeChild(this.lastLine),this.lastLine=null),this.polygonFillElement&&(this.polygonFillElement.parentNode&&this.svg.removeChild(this.polygonFillElement),this.polygonFillElement=null)}getLastPoint(){return this.points[this.points.length-1]}getFirstPoint(){return this.points[0]}dispose(){this.clear(),super.dispose()}constructor(t,e){super(t),this.previewElement=null,this.previewFillElement=null,this.controlPoints=[],this.lines=[],this.lastLine=null,this.points=[],this.polygonFillElement=null,this.currentMousePoint=void 0,this.adsorbRadius=8,this.options=e,e.adsorbRadius!==void 0&&(this.adsorbRadius=e.adsorbRadius)}};import"core-js/modules/es.array.push.js";import{Box3 as Da}from"three";var Zs=class extends dt{initElements(){this.svg.style.pointerEvents="auto",this.outline=gt(this.STROKE_COLOR,"transparent"),this.outline.setAttribute("stroke-dasharray","5,5"),this.outline.setAttribute("stroke-width","1"),this.svg.appendChild(this.outline),this.moveArea=gt(this.STROKE_COLOR,"transparent"),this.moveArea.style.cursor="move",this.svg.appendChild(this.moveArea);for(let t=0;t<4;t++){let e=Kt(this.STROKE_COLOR);e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","5,5"),this.outlineLines.push(e),this.svg.appendChild(e)}for(let t=0;t<8;t++){let e=gt(this.STROKE_COLOR,this.FILL_COLOR);e.style.cursor=this.getCursorForPoint(t),this.scalePoints.push(e),this.svg.appendChild(e)}this.rotateHandle=Gt(String(this.ROTATE_HANDLE_RADIUS),this.FILL_COLOR),this.rotateHandle.setAttribute("stroke",this.STROKE_COLOR),this.rotateHandle.setAttribute("stroke-width","1"),this.rotateHandle.style.cursor="crosshair",this.svg.appendChild(this.rotateHandle)}getCursorForPoint(t){return["nw-resize","n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize"][t]}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerleave",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerleave",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}getBoundingBoxInfo(){if(!this.selectedGraphic)return null;let t=new Da().setFromObject(this.selectedGraphic),{min:e,max:i}=t,{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,r=this.getSvgCoordinate(e),h=this.getSvgCoordinate(i);return{min:{x:r.x,y:r.y},max:{x:h.x,y:h.y},width:Math.abs(h.x-r.x),height:Math.abs(h.y-r.y),centerX:(r.x+h.x)/2,centerY:(r.y+h.y)/2}}show(t){this.selectedGraphic=t,this.svg.style.display="block",this.svg.style.pointerEvents="auto",this.updatePosition()}hide(){this.selectedGraphic=null,this.svg.style.display="none",this.svg.style.pointerEvents="none",this.clearControlPoints()}updatePosition(){if(this.boundingBox=this.getBoundingBoxInfo(),!this.boundingBox){this.clearControlPoints();return}let{min:t,max:e,width:i,height:s,centerX:o,centerY:n}=this.boundingBox,r=this.SCALE_POINT_SIZE/2,h=i/2,c=s/2;j(this.moveArea,t.x,e.y,i,s),j(this.outline,t.x,e.y,i,s),[{x1:t.x,y1:e.y,x2:e.x,y2:e.y},{x1:e.x,y1:e.y,x2:e.x,y2:t.y},{x1:e.x,y1:t.y,x2:t.x,y2:t.y},{x1:t.x,y1:t.y,x2:t.x,y2:e.y}].forEach((f,x)=>{rt(this.outlineLines[x],{x:f.x1,y:f.y1},{x:f.x2,y:f.y2})}),[{x:t.x-r,y:e.y-r},{x:o-r,y:e.y-r},{x:e.x-r,y:e.y-r},{x:e.x-r,y:n-r},{x:e.x-r,y:t.y-r},{x:o-r,y:t.y-r},{x:t.x-r,y:t.y-r},{x:t.x-r,y:n-r}].forEach((f,x)=>{j(this.scalePoints[x],f.x,f.y,this.SCALE_POINT_SIZE,this.SCALE_POINT_SIZE)});let d=o,u=e.y-this.ROTATE_HANDLE_OFFSET;yt(this.rotateHandle,d,u)}clearControlPoints(){j(this.moveArea,0,0,0,0),j(this.outline,0,0,0,0),this.outlineLines.forEach(e=>{rt(e,{x:0,y:0},{x:0,y:0})}),this.scalePoints.forEach(e=>{j(e,0,0,0,0)}),yt(this.rotateHandle,0,0)}getBoundingBox(){return this.selectedGraphic?new Da().setFromObject(this.selectedGraphic):null}getActionFromTarget(t){if(!t)return null;let e=t;if(e===this.rotateHandle)return{action:"rotate",point:this.rotateHandle};if(e===this.moveArea)return{action:"move",point:this.moveArea};let i=this.scalePoints.indexOf(e);return i!==-1?{action:["scale-left-top","scale-top","scale-right-top","scale-right","scale-right-bottom","scale-bottom","scale-left-bottom","scale-left"][i],point:this.scalePoints[i]}:null}getContainerPoint(t){let e=this.context.container.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}dispose(){this.unRegistryEvent(),this.moveArea&&this.moveArea.parentNode&&this.svg.removeChild(this.moveArea),this.outline&&this.outline.parentNode&&this.svg.removeChild(this.outline),this.outlineLines.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.scalePoints.forEach(t=>{t.parentNode&&this.svg.removeChild(t)}),this.rotateHandle&&this.rotateHandle.parentNode&&this.svg.removeChild(this.rotateHandle),this.scalePoints=[],this.outlineLines=[],this.selectedGraphic=null,this.currentAction=null,this.startPoint=null,this.boundingBox=null,super.dispose()}constructor(t){super(t),this.scalePoints=[],this.outlineLines=[],this.isTransforming=!1,this.selectedGraphic=null,this.currentAction=null,this.startPoint=null,this.boundingBox=null,this.SCALE_POINT_SIZE=8,this.ROTATE_HANDLE_RADIUS=6,this.ROTATE_HANDLE_OFFSET=30,this.STROKE_COLOR="#1CADFF",this.FILL_COLOR="#ffffff",this.onUpdate=()=>{this.selectedGraphic&&this.updatePosition()},this.onPointerDown=e=>{if(!this.selectedGraphic)return;let i=this.getActionFromTarget(e.target);e.preventDefault(),e.stopPropagation(),i&&(this.currentAction=i.action,this.startPoint=this.getContainerPoint(e),this.isTransforming=!0,this.dispatchEvent({type:"transform-start",action:this.currentAction,point:this.startPoint}))},this.onPointerMove=e=>{if(!this.currentAction||!this.startPoint)return;let i=this.getContainerPoint(e),s={x:i.x-this.startPoint.x,y:i.y-this.startPoint.y};this.startPoint=i,this.dispatchEvent({type:"transform",action:this.currentAction,delta:s,currentPoint:i})},this.onPointerUp=()=>{this.currentAction&&(this.dispatchEvent({type:"transform-end",action:this.currentAction}),this.currentAction=null,this.startPoint=null,this.isTransforming=!1)},this.initElements(),this.registryEvent()}};var Vo={strokeColor:"#1CADFF",strokeOpacity:1,strokeWidth:1,fillColor:"rgb(28, 173, 255)",fillOpacity:.3,pointColor:"#1CADFF",pointOpacity:1,pointRadius:5,height:.1,circleSegments:64,adsorbRadius:8,autoSelect:!0};function Km(a,t,e){let i=[];for(let s=0;s<=e;s++){let o=s/e*Math.PI*2;i.push([a.x+t*Math.cos(o),a.y+t*Math.sin(o)])}return i.push([a.x+t,a.y]),[i]}function Xm(a,t){let e=Math.min(a.x,t.x),i=Math.max(a.x,t.x),s=Math.min(a.y,t.y),o=Math.max(a.y,t.y);return[[[e,s],[i,s],[i,o],[e,o],[e,s]]]}function Ra(a,t,e){let i=Math.cos(e),s=Math.sin(e),o=a[0]-t[0],n=a[1]-t[1];return[t[0]+o*i-n*s,t[1]+o*s+n*i]}var Ko=class extends N{getState(){return this.state}startDrawPolygon(){this.state!=="idle"&&this.cancel(),this.deselectGraphic(),this.state="polygon",this.enter2DMode(),this.svgDrawer.clear(),this.disableControls(),this.dispatchEvent({type:"start",drawType:"polygon"})}startDrawRect(){this.state!=="idle"&&this.cancel(),this.deselectGraphic(),this.state="rect",this.enter2DMode(),this.startPoint=null,this.disableControls(),this.dispatchEvent({type:"start",drawType:"rect"})}startDrawCircle(){this.state!=="idle"&&this.cancel(),this.deselectGraphic(),this.state="circle",this.enter2DMode(),this.circleCenter=null,this.circleRadius=0,this.disableControls(),this.dispatchEvent({type:"start",drawType:"circle"})}cancel(){this.state==="idle"&&!this.selectedGraphic||(this.selectedGraphic&&this.deselectGraphic(),this.state!=="idle"&&(this.svgDrawer.clear(),this.state="idle",this.enableControls(),this.exit2DMode(),this.dispatchEvent({type:"cancel"})))}selectGraphic(t){let e=this.graphics.get(t);if(e){this.selectedGraphic&&this.deselectGraphic(),this.selectedGraphic=e,this.enter2DMode();var i,s;this.originalStyle={fillOpacity:(i=e.options.fillOpacity)!=null?i:.3,strokeOpacity:(s=e.options.strokeOpacity)!=null?s:1},e.options.fillOpacity=Math.min(this.originalStyle.fillOpacity,.5),e.options.strokeOpacity=Math.min(this.originalStyle.strokeOpacity,1),this.transformBox.show(e),this.dispatchEvent({type:"select",graphic:e})}}deselectGraphic(){if(!this.selectedGraphic)return;this.originalStyle&&(this.selectedGraphic.options.fillOpacity=this.originalStyle.fillOpacity,this.selectedGraphic.options.strokeOpacity=this.originalStyle.strokeOpacity,this.originalStyle=null);let t=this.selectedGraphic;this.selectedGraphic=null,this.transformBox.hide(),this.exit2DMode(),this.dispatchEvent({type:"deselect",graphic:t})}getSelectedGraphic(){return this.selectedGraphic}setRotation(t,e){let i=this.graphics.get(t);if(!i)return;let s=i.options.geometry.coords[0],o=[i.getCenter().x,i.getCenter().y],n=s.map(r=>Ra(r,o,e));i.options.geometry.coords[0]=n,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"rotate",graphic:i,id:t})}setWidth(t,e){let i=this.graphics.get(t);if(!i)return;let s=i.getSize(),o=e/s.x,n=i.options.geometry.coords[0],r=[i.getCenter().x,i.getCenter().y],h=n.map(c=>[r[0]+(c[0]-r[0])*o,c[1]]);i.options.geometry.coords[0]=h,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"resize",graphic:i,id:t})}setHeight(t,e){let i=this.graphics.get(t);if(!i)return;let s=i.getSize(),o=e/s.y,n=i.options.geometry.coords[0],r=[i.getCenter().x,i.getCenter().y],h=n.map(c=>[c[0],r[1]+(c[1]-r[1])*o]);i.options.geometry.coords[0]=h,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"resize",graphic:i,id:t})}setCoordinates(t,e){let i=this.graphics.get(t);i&&(i.options.geometry.coords=e,i.dispose(),i.init(),i.visible=!0,this.dispatchEvent({type:"change",action:"update",graphic:i,id:t}))}loadGraphics(t){t.forEach(e=>{e.id?vt.registerKey(e.id):e.id=vt.genUniqueKey(),e.visible=!0,this.createGraphic(e)}),this.dispatchEvent({type:"change",action:"add"})}getGraphics(){return Array.from(this.graphics.values())}removeGraphic(t){var e;let i=this.graphics.get(t);i&&(((e=this.selectedGraphic)==null?void 0:e.options.id)===t&&this.deselectGraphic(),this.graphicsGroup.remove(i),i.dispose(),this.graphics.delete(t),vt.removeKey(t),this.dispatchEvent({type:"change",action:"remove",id:t}))}clearGraphics(){this.selectedGraphic&&this.deselectGraphic(),this.graphics.forEach((t,e)=>{this.graphicsGroup.remove(t),t.dispose(),vt.removeKey(e)}),this.graphics.clear(),this.dispatchEvent({type:"change",action:"remove"})}getScreenPoint(t){let e=this.bmap.context.container.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}screenToWorld(t){let{camera:e,container:i}=this.bmap.context,s=new Zm;s.x=t.x/i.clientWidth*2-1,s.y=-(t.y/i.clientHeight)*2+1,this.raycaster.setFromCamera(s,e);let o=new jm(new li(0,0,1),0),n=new li;return this.raycaster.ray.intersectPlane(o,n)?n:null}screenCoordsToWorld(t){return t.map(e=>{let i=this.screenToWorld(e);return i?[i.x,i.y]:[0,0]})}pixelsToWorldDistance(t,e){let i=this.screenToWorld(e);if(!i)return 0;let s={x:e.x+t,y:e.y},o=this.screenToWorld(s);return o?Math.sqrt((o.x-i.x)**2+(o.y-i.y)**2):0}registryEvents(){this.bmap.context.container.addEventListener("contextmenu",this.onContextMenu),this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointermove",this.onPointerMove),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp)}unRegistryEvents(){this.bmap.context.container.removeEventListener("contextmenu",this.onContextMenu),this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointermove",this.onPointerMove),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp)}registryTransformEvents(){this.transformBox.addEventListener("transform-start",this.onTransformStart),this.transformBox.addEventListener("transform",this.onTransform),this.transformBox.addEventListener("transform-end",this.onTransformEnd)}unRegistryTransformEvents(){this.transformBox.removeEventListener("transform-start",this.onTransformStart),this.transformBox.removeEventListener("transform",this.onTransform),this.transformBox.removeEventListener("transform-end",this.onTransformEnd)}enter2DMode(){this.prevMapType===void 0&&(this.prevMapType=this.bmap.type,this.bmap.changeMapType("2d",0))}exit2DMode(){this.prevMapType!==void 0&&(this.bmap.changeMapType(this.prevMapType,0),this.prevMapType=void 0)}disableControls(){this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1}enableControls(){this.prevPanStatus!==void 0&&(this.bmap.context.control.enablePan=this.prevPanStatus),this.prevRotateStatus!==void 0&&(this.bmap.context.control.enableRotate=this.prevRotateStatus)}hitTestGraphic(t){let e=Array.from(this.graphics.values()).reverse();for(let i of e){let s=new Vm().setFromObject(i);if(t.x>=s.min.x&&t.x<=s.max.x&&t.y>=s.min.y&&t.y<=s.max.y)return i}return null}finishPolygon(){let t=this.svgDrawer.points;if(t.length<3)return;let e=[this.screenCoordsToWorld(t)],i=this.buildGraphicOptions(e),s=this.createGraphic(i);this.svgDrawer.clear(),this.state="idle",this.enableControls(),this.dispatchEvent({type:"finish",graphic:s,drawType:"polygon"}),this.options.autoSelect?this.selectGraphic(s.options.id):this.exit2DMode()}finishRect(){if(!this.startPoint)return;let t=this.currentMousePoint;if(!t)return;let e=this.screenToWorld(this.startPoint),i=this.screenToWorld(t);if(!e||!i)return;let s=Xm(e,i),o=this.buildGraphicOptions(s),n=this.createGraphic(o);this.svgDrawer.clear(),this.startPoint=null,this.state="idle",this.enableControls(),this.dispatchEvent({type:"finish",graphic:n,drawType:"rect"}),this.options.autoSelect?this.selectGraphic(n.options.id):this.exit2DMode()}finishCircle(){if(!this.circleCenter||this.circleRadius<5)return;let t=this.screenToWorld(this.circleCenter);if(!t)return;let e=this.pixelsToWorldDistance(this.circleRadius,this.circleCenter),i=Km(t,e,this.options.circleSegments),s=this.buildGraphicOptions(i),o=this.createGraphic(s);this.svgDrawer.clear(),this.circleCenter=null,this.circleRadius=0,this.state="idle",this.enableControls(),this.dispatchEvent({type:"finish",graphic:o,drawType:"circle"}),this.options.autoSelect?this.selectGraphic(o.options.id):this.exit2DMode()}buildGraphicOptions(t){let e=t[0],i=0,s=0;for(let l=0;l<e.length-1;l++)i+=e[l][0],s+=e[l][1];let o=i/(e.length-1),n=s/(e.length-1),[r,h]=this.bmap.coordinateTransform.worldToMercator(new li(o,n,0)),c=t.map(l=>l.map(p=>{let[d,u]=p;return this.bmap.coordinateTransform.worldToMercator(new li(d,u,0))}));return w({},At,{id:vt.genUniqueKey(),geometry:{type:"polygon",cds:c,coords:t,curveCpt:[],curveIndex:[]},center_coord_x:o,center_coord_y:n,center_x:r,center_y:h,fillColor:this.options.fillColor,strokeColor:this.options.strokeColor,fillOpacity:this.options.fillOpacity,strokeOpacity:this.options.strokeOpacity,strokeWidth:this.options.strokeWidth,height:this.options.height,visible:!0})}createGraphic(t){let e=new Y(this.bmap.context,t);return this.graphics.set(t.id,e),this.graphicsGroup.add(e),e}dispose(){this.exit2DMode(),this.unRegistryEvents(),this.unRegistryTransformEvents(),this.svgDrawer.dispose(),this.transformBox.dispose(),this.clearGraphics(),this.bmap.context.scene.remove(this.graphicsGroup),super.dispose()}constructor(t,e={}){super(t),this.state="idle",this.graphics=new Map,this.selectedGraphic=null,this.startPoint=null,this.circleCenter=null,this.circleRadius=0,this.originalStyle=null,this.initialRotateAngle=0,this.rotationCenter=[0,0],this.raycaster=new Nm,this.currentMousePoint=null,this.onContextMenu=i=>{(this.state!=="idle"||this.selectedGraphic)&&(i.preventDefault(),this.cancel())},this.onPointerDown=i=>{if(i.button!==0)return;let s=this.getScreenPoint(i);if(this.state==="polygon")this.svgDrawer.checkAdsorb(s)&&this.svgDrawer.points.length>=2?this.finishPolygon():this.svgDrawer.addPolygonPoint(s);else if(this.state==="rect")if(!this.startPoint)this.startPoint=s;else{this.currentMousePoint=s;let o=Math.abs(s.x-this.startPoint.x),n=Math.abs(s.y-this.startPoint.y);o>2||n>2?this.finishRect():this.startPoint=null}else if(this.state==="circle")this.circleCenter?(this.currentMousePoint=s,this.circleRadius>5?this.finishCircle():(this.circleCenter=null,this.circleRadius=0,this.svgDrawer.clear())):this.circleCenter=s;else if(this.state==="idle"){if(this.transformBox.isTransforming)return;let o=this.screenToWorld(s);if(!o)return;let n=this.hitTestGraphic(o);if(this.dispatchEvent({type:"graphic-click",graphic:n}),n){if(this.selectedGraphic&&n.options.id===this.selectedGraphic.options.id)return;this.options.autoSelect&&this.selectGraphic(n.options.id)}else this.selectedGraphic&&this.deselectGraphic()}},this.onPointerMove=i=>{let s=this.getScreenPoint(i);if(this.currentMousePoint=s,this.state==="polygon")this.svgDrawer.updatePolygonPreview(s);else if(this.state==="rect"&&this.startPoint)this.svgDrawer.updateRectPreview(this.startPoint,s,!0);else if(this.state==="circle"&&this.circleCenter){let o=s.x-this.circleCenter.x,n=s.y-this.circleCenter.y,r=Math.sqrt(o*o+n*n);this.circleRadius=r,this.svgDrawer.updateCirclePreview(this.circleCenter,r),this.svgDrawer.updateCirclePreviewFill(this.circleCenter,r)}},this.onPointerUp=i=>{},this.onTransformStart=i=>{if(i.action==="rotate"&&this.selectedGraphic){let s=this.selectedGraphic.getCenter();this.rotationCenter=[s.x,s.y];let o=this.transformBox.getSvgCoordinate(s);o&&(this.initialRotateAngle=Math.atan2(i.point.y-o.y,i.point.x-o.x))}},this.onTransform=i=>{if(!this.selectedGraphic)return;let{action:s,delta:o,currentPoint:n}=i,r=this.selectedGraphic;if(s==="move"){let h={x:n.x-o.x,y:n.y-o.y},c=this.screenToWorld(h),l=this.screenToWorld(n);if(!c||!l)return;let p={x:l.x-c.x,y:l.y-c.y},u=r.options.geometry.coords[0].map(f=>[f[0]+p.x,f[1]+p.y]);r.options.geometry.coords[0]=u}else if(s.startsWith("scale")){let h=this.transformBox.getBoundingBoxInfo();if(!h)return;let c=r.options.geometry.coords[0],l=o.x,p=o.y;(s==="scale-top"||s==="scale-bottom")&&(l=0),(s==="scale-left"||s==="scale-right")&&(p=0);let d={x:h.min.x,y:h.min.y},u={x:h.max.x,y:h.max.y},f={x:d.x+(s.includes("left")?l:0),y:d.y+(s.includes("bottom")?p:0)},x={x:u.x+(s.includes("right")?l:0),y:u.y+(s.includes("top")?p:0)},m=this.screenToWorld(d),y=this.screenToWorld(u),_=this.screenToWorld(f),P=this.screenToWorld(x);if(!m||!y||!_||!P)return;let S=y.x-m.x,E=y.y-m.y,k=P.x-_.x,M=P.y-_.y,G=c.map(R=>{let O=S!==0?(R[0]-m.x)/S:.5,$=E!==0?(R[1]-m.y)/E:.5;return[_.x+O*k,_.y+$*M]});r.options.geometry.coords[0]=G}else if(s==="rotate"){let h=this.transformBox.getSvgCoordinate(new li(this.rotationCenter[0],this.rotationCenter[1],0));if(!h)return;let c=Math.atan2(n.y-h.y,n.x-h.x),l=c-this.initialRotateAngle;this.initialRotateAngle=c;let d=r.options.geometry.coords[0].map(u=>Ra(u,this.rotationCenter,l));r.options.geometry.coords[0]=d}r.dispose(),r.init(),r.visible=!0},this.onTransformEnd=i=>{this.selectedGraphic&&this.dispatchEvent({type:"change",action:"move",graphic:this.selectedGraphic,id:this.selectedGraphic.options.id})},this.options=w({},Vo,e),this.graphicsGroup=new Hm,this.graphicsGroup.name="GraphicDrawGroup",this.bmap.context.scene.add(this.graphicsGroup),this.svgDrawer=new Ns(this.bmap.context,{strokeColor:this.options.strokeColor,strokeOpacity:this.options.strokeOpacity,fillColor:this.options.fillColor,fillOpacity:this.options.fillOpacity,pointColor:this.options.pointColor,pointRadius:this.options.pointRadius,adsorbRadius:this.options.adsorbRadius}),this.transformBox=new Zs(this.bmap.context),this.transformBox.hide(),this.registryEvents(),this.registryTransformEvents()}};export{Oe as AibeeLoader,Oo as BMap,ua as BMapSelect,dt as BaseSvg,Us as CarInertialPosition,bi as ClickHelper,ws as Context,vs as ContextCamera,ys as ContextScene,fs as Control,Si as CoordinateTransform,ta as CrLoader,da as CrNavPath,ea as Equipment,st as EventDispatcher,un as Events,zt as Floor,kr as GlbModel,Y as Graphic,Ko as GraphicDraw,Gi as GraphicLayer,le as GroundTexture,Aa as Heatmap,Yi as HeatmapElement,Ta as HighlightPoi,lt as HooksName,cs as HoverHelper,Se as InstancedGraphic,Zi as InstancedModel,Qe as InstancedParkingSpace,rs as InstancedWall,Ei as KalmanFilter,ts as Lane,q as Layer,ii as LineElement,fT as MapTypePolar,ei as MergeAttributeGraphic,pe as MergeAttributeGroundTexture,os as MergeAttributeLane,is as MergeAttributeWall,Or as MergeGraphic,de as MergedAttributeGraphicLine,Vi as MergedGraphicLayer,Ni as MergedModelLayer,Ii as Model,wa as MulFloorNavigation,_a as MulFloorSelect,la as MulFloors,Ss as NavPath,ha as Navigation,Ee as Overlay,Hi as ParkingLayer,vT as ParkingType,Yt as PathDirection,Rs as PdrPosition,ce as Poi,et as Poi2,Bi as PoiLayer,Ui as PoiLayer2,Sa as Position,Kg as ProofType,_s as RENDER_VERSION,Ma as RecommendParkingSpace,gs as Renderer,Hn as RoadNetwork,we as RoadNetwork2,xi as SDF_REFERENCE_FONT_SIZE,B as SENSOR_TYPE,ka as SatelliteTile,Tr as SelectBox,hs as Selection,Ts as Sensor,Fi as Shadow,ci as Socket,La as SortByDistance,qi as SvgLine,$i as SvgPolygon,Pe as TaskQueue,es as TextTexture,ue as TileLayer,Ki as TileLoader,K as Timer,ie as TweenUtil,dn as UA,Ca as UseMyPosition,Ji as Wall,Mi as WorkerPool,Df as addAlphaToHexColor,Sh as assignGraphicDepthLevel,Ue as buildSdfTextGeometry,ge as calc_angle,Js as calc_direction,qA as calculateInstantaneousSpeed,zs as calculateLineDirection,mn as convertToSnakeCase,Gt as createCircle,Kt as createLine,gt as createRect,cn as createSvg,yi as createSvgElement,py as createThreeBox,ly as createThreeLine,Xt as darkenColor,pu as defaultConfig,Vo as defaultGraphicDrawOptions,At as defaultGraphicOptions,Eo as defaultOptions,jp as defaultTextTextureOptions,yf as deviceToVector3,F as dispose,En as distancePointToSegment,ae as generatorKeyByObj,lh as getAngle,no as getBorderPoints,gi as getCenter,Xr as getConfig,Sn as getDirectPath,Qs as getDirectionByAngle,Cn as getDistanceByPathPos,A as getLength,vf as getLongestSideDir,xf as getMinEdgeSquare,ft as getPathLength,Vt as getPointEdgeIndex,xe as getPosByPathDistance,an as hasChinese,Rf as hexToRgb,rn as initDirectionalLight,nn as initLight,ui as initShape,Pv as instancedGeometiesAttributes,If as isAndroid,te as isContain,ve as isControl,vi as isIOS,ee as isIphone,re as isMac,hn as isPointInPolygon,bv as isRectangle,wi as layoutSdfText,ba as linearFitForSpeed,Jr as loadBuildingGround,Z1 as loadExternalStreet,Qr as loadGraphics,_v as mergeGraphicGeometries,Wh as mergeGraphicLineGeometries,vg as moveOnRoute,hi as predictFuturePosition,$A as predictFutureSpeed,ye as proxyOptions,JA as removeOutliers,dh as removeWeightPath,yt as setCirclePosition,rt as setLineStartEnd,j as setRectPosition,_i as simplifyPath,pn as sleepByRf,ln as sleepOnePromise,qs as sleepOneRf,Mn as smoothPath,fn as splitStrByBracket,yn as splitTextByMeasure,Af as strToNumber,bt as timeoutPromise,ry as toWebWorker,Pi as transformGraphicData,No as transformSpeed,_e as translatePosToCenter,H as triggerWorker,L as vector3ToDevice,lg as xhrGet};