@mappedin/mappedin-js 6.30.0 → 6.32.0

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,1222 +0,0 @@
1
- import{$a as Pd,$b as ru,Aa as Sd,Ac as gu,B as _c,Ba as Md,Bb as zd,Bc as yu,C as yt,Ca as xr,Cb as Qo,Cc as bu,D as la,Da as Cd,Db as Ud,E as Bc,Ea as wd,Eb as Bn,Ec as vu,F as Oo,Fa as ba,Fb as Hd,Fc as xu,G as gr,Ga as va,Gb as Wd,Gc as Su,H as Ht,Ha as nt,Hb as ei,Hc as Mu,I as ca,Ia as Q,Ib as Vd,Ic as Cu,Ja as jr,Jb as jd,Jc as Et,Ka as An,Kb as Zd,Kc as wu,La as Rn,Lb as Xd,Lc as Ce,Mb as Yd,Mc as Eu,N as yr,Na as ye,Nb as $d,Nc as ii,O as da,Oa as Ve,Ob as qd,Oc as Dt,P as Gc,Pa as bt,Pb as Jd,Pc as Du,Q as kc,Qa as xa,Qb as Mr,Qc as $r,R as Lo,Ra as Ft,Rb as wa,Rc as Ba,Sa as Zo,Sb as Ea,Sc as ue,Ta as Xo,Tb as Da,Tc as Fe,U as ua,Ua as Yo,Ub as ti,Uc as he,Va as Ed,Vb as je,Wa as Dd,Wb as Kd,Xa as Sr,Xb as Qd,Y as ha,Ya as Td,Yb as eu,Za as Zr,Zb as Ta,_ as pa,_a as Fn,_b as tu,ac as Pa,ba as Wt,bb as Id,bc as Ia,c as Ac,ca as Nc,cb as Xr,cc as ri,da as Ot,db as Sa,dc as nu,e as R,eb as $o,ec as ou,f as _r,fb as Od,fc as Oa,g as wn,ga as pd,gb as Ld,gc as iu,h as zt,ha as md,hb as Ad,hc as su,i as Do,ia as fd,ib as Rd,ic as au,j as q,jb as Ma,jc as La,ka as Ln,kb as Fd,kc as lu,la as gd,lb as _d,lc as Cr,m as oa,mb as Yr,mc as ni,n as To,nb as Bd,nc as Aa,o as ia,ob as qo,oc as cu,p as Po,pb as Ca,pc as du,q as fr,qa as Wo,qb as Gd,qc as Ra,r as Rc,rb as Jo,rc as uu,sb as kd,sc as Gn,ta as Vo,tb as _n,tc as Fa,u as Fc,ua as qt,ub as _t,uc as oi,v as sa,va as yd,vb as Ko,vc as hu,w as Io,wa as jo,wb as Jt,wc as _a,xa as bd,xb as Kt,xc as pu,y as aa,ya as vd,yb as Nd,yc as mu,z as Ut,za as xd,zc as fu}from"./chunk-NO3DWTOG.js";import{a as Ke}from"./chunk-Q7BEUNXA.js";import{$ as Pn,Aa as ed,B as Zc,Ba as Nr,Ca as No,Da as zr,E as br,Fa as Xt,G as Xc,H as Me,I as Bo,J as vr,K as Go,Ka as td,L as Br,La as rd,M as Gr,Ma as zo,Na as nd,O as Yc,Oa as od,P as W,Pa as Ur,Q as V,Qa as Hr,R as kr,Ra as Wr,S as O,Sa as We,Ta as Vr,Ua as id,Va as On,Xa as Yt,Y as $c,Ya as sd,Z as Tn,_ as de,a as y,aa as qc,b as E,ba as K,c as Ao,ca as Lt,d as Ro,da as Je,e as zc,ea as z,f as Vt,fa as Jc,fb as Uo,g as Uc,ga as Be,h as Hc,ha as De,i as En,ia as At,ib as ya,j as ma,ja as jt,jb as Ho,ka as X,kb as ad,l as fa,la as Zt,mb as ld,na as lt,o as Dn,oa as Kc,ob as cd,pa as ga,qa as ko,qb as $t,r as Fo,ra as Rt,s as Wc,sb as dd,t as Vc,tb as ud,u as _o,v as jc,vb as hd,wa as Qc,ya as In,za as re}from"./chunk-UHBPXUGN.js";import{b as wt,c as yf,d as Cn}from"./chunk-PWEV3AFA.js";var Rh=wt((xl,Sl)=>{y();(function(o,e){typeof xl=="object"&&typeof Sl<"u"?Sl.exports=e():typeof define=="function"&&define.amd?define(e):(o=o||self).RBush=e()})(xl,function(){"use strict";function o(p,m,g,b,x){(function S(C,D,w,P,T){for(;P>w;){if(P-w>600){var I=P-w+1,L=D-w+1,A=Math.log(I),F=.5*Math.exp(2*A/3),k=.5*Math.sqrt(A*F*(I-F)/I)*(L-I/2<0?-1:1),_=Math.max(w,Math.floor(D-L*F/I+k)),j=Math.min(P,Math.floor(D+(I-L)*F/I+k));S(C,D,_,j,T)}var G=C[D],Z=w,se=P;for(e(C,w,D),T(C[P],G)>0&&e(C,w,P);Z<se;){for(e(C,Z,se),Z++,se--;T(C[Z],G)<0;)Z++;for(;T(C[se],G)>0;)se--}T(C[w],G)===0?e(C,w,se):e(C,++se,P),se<=D&&(w=se+1),D<=se&&(P=se-1)}})(p,m,g||0,b||p.length-1,x||t)}function e(p,m,g){var b=p[m];p[m]=p[g],p[g]=b}function t(p,m){return p<m?-1:p>m?1:0}var r=function(p){p===void 0&&(p=9),this._maxEntries=Math.max(4,p),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function n(p,m,g){if(!g)return m.indexOf(p);for(var b=0;b<m.length;b++)if(g(p,m[b]))return b;return-1}function i(p,m){s(p,0,p.children.length,m,p)}function s(p,m,g,b,x){x||(x=f(null)),x.minX=1/0,x.minY=1/0,x.maxX=-1/0,x.maxY=-1/0;for(var S=m;S<g;S++){var C=p.children[S];a(x,p.leaf?b(C):C)}return x}function a(p,m){return p.minX=Math.min(p.minX,m.minX),p.minY=Math.min(p.minY,m.minY),p.maxX=Math.max(p.maxX,m.maxX),p.maxY=Math.max(p.maxY,m.maxY),p}function l(p,m){return p.minX-m.minX}function c(p,m){return p.minY-m.minY}function d(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function u(p){return p.maxX-p.minX+(p.maxY-p.minY)}function h(p,m){return p.minX<=m.minX&&p.minY<=m.minY&&m.maxX<=p.maxX&&m.maxY<=p.maxY}function v(p,m){return m.minX<=p.maxX&&m.minY<=p.maxY&&m.maxX>=p.minX&&m.maxY>=p.minY}function f(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function M(p,m,g,b,x){for(var S=[m,g];S.length;)if(!((g=S.pop())-(m=S.pop())<=b)){var C=m+Math.ceil((g-m)/b/2)*b;o(p,C,m,g,x),S.push(m,C,C,g)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(p){var m=this.data,g=[];if(!v(p,m))return g;for(var b=this.toBBox,x=[];m;){for(var S=0;S<m.children.length;S++){var C=m.children[S],D=m.leaf?b(C):C;v(p,D)&&(m.leaf?g.push(C):h(p,D)?this._all(C,g):x.push(C))}m=x.pop()}return g},r.prototype.collides=function(p){var m=this.data;if(!v(p,m))return!1;for(var g=[];m;){for(var b=0;b<m.children.length;b++){var x=m.children[b],S=m.leaf?this.toBBox(x):x;if(v(p,S)){if(m.leaf||h(p,S))return!0;g.push(x)}}m=g.pop()}return!1},r.prototype.load=function(p){if(!p||!p.length)return this;if(p.length<this._minEntries){for(var m=0;m<p.length;m++)this.insert(p[m]);return this}var g=this._build(p.slice(),0,p.length-1,0);if(this.data.children.length)if(this.data.height===g.height)this._splitRoot(this.data,g);else{if(this.data.height<g.height){var b=this.data;this.data=g,g=b}this._insert(g,this.data.height-g.height-1,!0)}else this.data=g;return this},r.prototype.insert=function(p){return p&&this._insert(p,this.data.height-1),this},r.prototype.clear=function(){return this.data=f([]),this},r.prototype.remove=function(p,m){if(!p)return this;for(var g,b,x,S=this.data,C=this.toBBox(p),D=[],w=[];S||D.length;){if(S||(S=D.pop(),b=D[D.length-1],g=w.pop(),x=!0),S.leaf){var P=n(p,S.children,m);if(P!==-1)return S.children.splice(P,1),D.push(S),this._condense(D),this}x||S.leaf||!h(S,C)?b?(g++,S=b.children[g],x=!1):S=null:(D.push(S),w.push(g),g=0,b=S,S=S.children[0])}return this},r.prototype.toBBox=function(p){return p},r.prototype.compareMinX=function(p,m){return p.minX-m.minX},r.prototype.compareMinY=function(p,m){return p.minY-m.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(p){return this.data=p,this},r.prototype._all=function(p,m){for(var g=[];p;)p.leaf?m.push.apply(m,p.children):g.push.apply(g,p.children),p=g.pop();return m},r.prototype._build=function(p,m,g,b){var x,S=g-m+1,C=this._maxEntries;if(S<=C)return i(x=f(p.slice(m,g+1)),this.toBBox),x;b||(b=Math.ceil(Math.log(S)/Math.log(C)),C=Math.ceil(S/Math.pow(C,b-1))),(x=f([])).leaf=!1,x.height=b;var D=Math.ceil(S/C),w=D*Math.ceil(Math.sqrt(C));M(p,m,g,w,this.compareMinX);for(var P=m;P<=g;P+=w){var T=Math.min(P+w-1,g);M(p,P,T,D,this.compareMinY);for(var I=P;I<=T;I+=D){var L=Math.min(I+D-1,T);x.children.push(this._build(p,I,L,b-1))}}return i(x,this.toBBox),x},r.prototype._chooseSubtree=function(p,m,g,b){for(;b.push(m),!m.leaf&&b.length-1!==g;){for(var x=1/0,S=1/0,C=void 0,D=0;D<m.children.length;D++){var w=m.children[D],P=d(w),T=(I=p,L=w,(Math.max(L.maxX,I.maxX)-Math.min(L.minX,I.minX))*(Math.max(L.maxY,I.maxY)-Math.min(L.minY,I.minY))-P);T<S?(S=T,x=P<x?P:x,C=w):T===S&&P<x&&(x=P,C=w)}m=C||m.children[0]}var I,L;return m},r.prototype._insert=function(p,m,g){var b=g?p:this.toBBox(p),x=[],S=this._chooseSubtree(b,this.data,m,x);for(S.children.push(p),a(S,b);m>=0&&x[m].children.length>this._maxEntries;)this._split(x,m),m--;this._adjustParentBBoxes(b,x,m)},r.prototype._split=function(p,m){var g=p[m],b=g.children.length,x=this._minEntries;this._chooseSplitAxis(g,x,b);var S=this._chooseSplitIndex(g,x,b),C=f(g.children.splice(S,g.children.length-S));C.height=g.height,C.leaf=g.leaf,i(g,this.toBBox),i(C,this.toBBox),m?p[m-1].children.push(C):this._splitRoot(g,C)},r.prototype._splitRoot=function(p,m){this.data=f([p,m]),this.data.height=p.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(p,m,g){for(var b,x,S,C,D,w,P,T=1/0,I=1/0,L=m;L<=g-m;L++){var A=s(p,0,L,this.toBBox),F=s(p,L,g,this.toBBox),k=(x=A,S=F,C=void 0,D=void 0,w=void 0,P=void 0,C=Math.max(x.minX,S.minX),D=Math.max(x.minY,S.minY),w=Math.min(x.maxX,S.maxX),P=Math.min(x.maxY,S.maxY),Math.max(0,w-C)*Math.max(0,P-D)),_=d(A)+d(F);k<T?(T=k,b=L,I=_<I?_:I):k===T&&_<I&&(I=_,b=L)}return b||g-m},r.prototype._chooseSplitAxis=function(p,m,g){var b=p.leaf?this.compareMinX:l,x=p.leaf?this.compareMinY:c;this._allDistMargin(p,m,g,b)<this._allDistMargin(p,m,g,x)&&p.children.sort(b)},r.prototype._allDistMargin=function(p,m,g,b){p.children.sort(b);for(var x=this.toBBox,S=s(p,0,m,x),C=s(p,g-m,g,x),D=u(S)+u(C),w=m;w<g-m;w++){var P=p.children[w];a(S,p.leaf?x(P):P),D+=u(S)}for(var T=g-m-1;T>=m;T--){var I=p.children[T];a(C,p.leaf?x(I):I),D+=u(C)}return D},r.prototype._adjustParentBBoxes=function(p,m,g){for(var b=g;b>=0;b--)a(m[b],p)},r.prototype._condense=function(p){for(var m=p.length-1,g=void 0;m>=0;m--)p[m].children.length===0?m>0?(g=p[m-1].children).splice(g.indexOf(p[m]),1):this.clear():i(p[m],this.toBBox)},r})});var Dl=wt(N=>{"use strict";y();Object.defineProperty(N,"__esModule",{value:!0});N.earthRadius=63710088e-1;N.factors={centimeters:N.earthRadius*100,centimetres:N.earthRadius*100,degrees:N.earthRadius/111325,feet:N.earthRadius*3.28084,inches:N.earthRadius*39.37,kilometers:N.earthRadius/1e3,kilometres:N.earthRadius/1e3,meters:N.earthRadius,metres:N.earthRadius,miles:N.earthRadius/1609.344,millimeters:N.earthRadius*1e3,millimetres:N.earthRadius*1e3,nauticalmiles:N.earthRadius/1852,radians:1,yards:N.earthRadius*1.0936};N.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/N.earthRadius,yards:1.0936133};N.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function tr(o,e,t){t===void 0&&(t={});var r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}N.feature=tr;function ny(o,e,t){switch(t===void 0&&(t={}),o){case"Point":return Ml(e).geometry;case"LineString":return wl(e).geometry;case"Polygon":return Cl(e).geometry;case"MultiPoint":return _h(e).geometry;case"MultiLineString":return Fh(e).geometry;case"MultiPolygon":return Bh(e).geometry;default:throw new Error(o+" is invalid")}}N.geometry=ny;function Ml(o,e,t){if(t===void 0&&(t={}),!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Hi(o[0])||!Hi(o[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:o};return tr(r,e,t)}N.point=Ml;function oy(o,e,t){return t===void 0&&(t={}),Wi(o.map(function(r){return Ml(r,e)}),t)}N.points=oy;function Cl(o,e,t){t===void 0&&(t={});for(var r=0,n=o;r<n.length;r++){var i=n[r];if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<i[i.length-1].length;s++)if(i[i.length-1][s]!==i[0][s])throw new Error("First and last Position are not equivalent.")}var a={type:"Polygon",coordinates:o};return tr(a,e,t)}N.polygon=Cl;function iy(o,e,t){return t===void 0&&(t={}),Wi(o.map(function(r){return Cl(r,e)}),t)}N.polygons=iy;function wl(o,e,t){if(t===void 0&&(t={}),o.length<2)throw new Error("coordinates must be an array of two or more positions");var r={type:"LineString",coordinates:o};return tr(r,e,t)}N.lineString=wl;function sy(o,e,t){return t===void 0&&(t={}),Wi(o.map(function(r){return wl(r,e)}),t)}N.lineStrings=sy;function Wi(o,e){e===void 0&&(e={});var t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}N.featureCollection=Wi;function Fh(o,e,t){t===void 0&&(t={});var r={type:"MultiLineString",coordinates:o};return tr(r,e,t)}N.multiLineString=Fh;function _h(o,e,t){t===void 0&&(t={});var r={type:"MultiPoint",coordinates:o};return tr(r,e,t)}N.multiPoint=_h;function Bh(o,e,t){t===void 0&&(t={});var r={type:"MultiPolygon",coordinates:o};return tr(r,e,t)}N.multiPolygon=Bh;function ay(o,e,t){t===void 0&&(t={});var r={type:"GeometryCollection",geometries:o};return tr(r,e,t)}N.geometryCollection=ay;function ly(o,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var t=Math.pow(10,e||0);return Math.round(o*t)/t}N.round=ly;function Gh(o,e){e===void 0&&(e="kilometers");var t=N.factors[e];if(!t)throw new Error(e+" units is invalid");return o*t}N.radiansToLength=Gh;function El(o,e){e===void 0&&(e="kilometers");var t=N.factors[e];if(!t)throw new Error(e+" units is invalid");return o/t}N.lengthToRadians=El;function cy(o,e){return kh(El(o,e))}N.lengthToDegrees=cy;function dy(o){var e=o%360;return e<0&&(e+=360),e}N.bearingToAzimuth=dy;function kh(o){var e=o%(2*Math.PI);return e*180/Math.PI}N.radiansToDegrees=kh;function uy(o){var e=o%360;return e*Math.PI/180}N.degreesToRadians=uy;function hy(o,e,t){if(e===void 0&&(e="kilometers"),t===void 0&&(t="kilometers"),!(o>=0))throw new Error("length must be a positive number");return Gh(El(o,e),t)}N.convertLength=hy;function py(o,e,t){if(e===void 0&&(e="meters"),t===void 0&&(t="kilometers"),!(o>=0))throw new Error("area must be a positive number");var r=N.areaFactors[e];if(!r)throw new Error("invalid original units");var n=N.areaFactors[t];if(!n)throw new Error("invalid final units");return o/r*n}N.convertArea=py;function Hi(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}N.isNumber=Hi;function my(o){return!!o&&o.constructor===Object}N.isObject=my;function fy(o){if(!o)throw new Error("bbox is required");if(!Array.isArray(o))throw new Error("bbox must be an Array");if(o.length!==4&&o.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");o.forEach(function(e){if(!Hi(e))throw new Error("bbox must only contain numbers")})}N.validateBBox=fy;function gy(o){if(!o)throw new Error("id is required");if(["string","number"].indexOf(typeof o)===-1)throw new Error("id must be a number or a string")}N.validateId=gy});var Wh=wt(we=>{"use strict";y();Object.defineProperty(we,"__esModule",{value:!0});var Ge=Dl();function eo(o,e,t){if(o!==null)for(var r,n,i,s,a,l,c,d=0,u=0,h,v=o.type,f=v==="FeatureCollection",M=v==="Feature",p=f?o.features.length:1,m=0;m<p;m++){c=f?o.features[m].geometry:M?o.geometry:o,h=c?c.type==="GeometryCollection":!1,a=h?c.geometries.length:1;for(var g=0;g<a;g++){var b=0,x=0;if(s=h?c.geometries[g]:c,s!==null){l=s.coordinates;var S=s.type;switch(d=t&&(S==="Polygon"||S==="MultiPolygon")?1:0,S){case null:break;case"Point":if(e(l,u,m,b,x)===!1)return!1;u++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(e(l[r],u,m,b,x)===!1)return!1;u++,S==="MultiPoint"&&b++}S==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-d;n++){if(e(l[r][n],u,m,b,x)===!1)return!1;u++}S==="MultiLineString"&&b++,S==="Polygon"&&x++}S==="Polygon"&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(x=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-d;i++){if(e(l[r][n][i],u,m,b,x)===!1)return!1;u++}x++}b++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(eo(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function yy(o,e,t,r){var n=t;return eo(o,function(i,s,a,l,c){s===0&&t===void 0?n=i:n=e(n,i,s,a,l,c)},r),n}function Nh(o,e){var t;switch(o.type){case"FeatureCollection":for(t=0;t<o.features.length&&e(o.features[t].properties,t)!==!1;t++);break;case"Feature":e(o.properties,0);break}}function by(o,e,t){var r=t;return Nh(o,function(n,i){i===0&&t===void 0?r=n:r=e(r,n,i)}),r}function zh(o,e){if(o.type==="Feature")e(o,0);else if(o.type==="FeatureCollection")for(var t=0;t<o.features.length&&e(o.features[t],t)!==!1;t++);}function vy(o,e,t){var r=t;return zh(o,function(n,i){i===0&&t===void 0?r=n:r=e(r,n,i)}),r}function xy(o){var e=[];return eo(o,function(t){e.push(t)}),e}function Tl(o,e){var t,r,n,i,s,a,l,c,d,u,h=0,v=o.type==="FeatureCollection",f=o.type==="Feature",M=v?o.features.length:1;for(t=0;t<M;t++){for(a=v?o.features[t].geometry:f?o.geometry:o,c=v?o.features[t].properties:f?o.properties:{},d=v?o.features[t].bbox:f?o.bbox:void 0,u=v?o.features[t].id:f?o.id:void 0,l=a?a.type==="GeometryCollection":!1,s=l?a.geometries.length:1,n=0;n<s;n++){if(i=l?a.geometries[n]:a,i===null){if(e(null,h,c,d,u)===!1)return!1;continue}switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(i,h,c,d,u)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<i.geometries.length;r++)if(e(i.geometries[r],h,c,d,u)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}h++}}function Sy(o,e,t){var r=t;return Tl(o,function(n,i,s,a,l){i===0&&t===void 0?r=n:r=e(r,n,i,s,a,l)}),r}function Vi(o,e){Tl(o,function(t,r,n,i,s){var a=t===null?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return e(Ge.feature(t,n,{bbox:i,id:s}),r,0)===!1?!1:void 0}var l;switch(a){case"MultiPoint":l="Point";break;case"MultiLineString":l="LineString";break;case"MultiPolygon":l="Polygon";break}for(var c=0;c<t.coordinates.length;c++){var d=t.coordinates[c],u={type:l,coordinates:d};if(e(Ge.feature(u,n),r,c)===!1)return!1}})}function My(o,e,t){var r=t;return Vi(o,function(n,i,s){i===0&&s===0&&t===void 0?r=n:r=e(r,n,i,s)}),r}function Uh(o,e){Vi(o,function(t,r,n){var i=0;if(t.geometry){var s=t.geometry.type;if(!(s==="Point"||s==="MultiPoint")){var a,l=0,c=0,d=0;if(eo(t,function(u,h,v,f,M){if(a===void 0||r>l||f>c||M>d){a=u,l=r,c=f,d=M,i=0;return}var p=Ge.lineString([a,u],t.properties);if(e(p,r,n,M,i)===!1)return!1;i++,a=u})===!1)return!1}}})}function Cy(o,e,t){var r=t,n=!1;return Uh(o,function(i,s,a,l,c){n===!1&&t===void 0?r=i:r=e(r,i,s,a,l,c),n=!0}),r}function Hh(o,e){if(!o)throw new Error("geojson is required");Vi(o,function(t,r,n){if(t.geometry!==null){var i=t.geometry.type,s=t.geometry.coordinates;switch(i){case"LineString":if(e(t,r,n,0,0)===!1)return!1;break;case"Polygon":for(var a=0;a<s.length;a++)if(e(Ge.lineString(s[a],t.properties),r,n,a)===!1)return!1;break}}})}function wy(o,e,t){var r=t;return Hh(o,function(n,i,s,a){i===0&&t===void 0?r=n:r=e(r,n,i,s,a)}),r}function Ey(o,e){if(e=e||{},!Ge.isObject(e))throw new Error("options is invalid");var t=e.featureIndex||0,r=e.multiFeatureIndex||0,n=e.geometryIndex||0,i=e.segmentIndex||0,s=e.properties,a;switch(o.type){case"FeatureCollection":t<0&&(t=o.features.length+t),s=s||o.features[t].properties,a=o.features[t].geometry;break;case"Feature":s=s||o.properties,a=o.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":a=o;break;default:throw new Error("geojson is invalid")}if(a===null)return null;var l=a.coordinates;switch(a.type){case"Point":case"MultiPoint":return null;case"LineString":return i<0&&(i=l.length+i-1),Ge.lineString([l[i],l[i+1]],s,e);case"Polygon":return n<0&&(n=l.length+n),i<0&&(i=l[n].length+i-1),Ge.lineString([l[n][i],l[n][i+1]],s,e);case"MultiLineString":return r<0&&(r=l.length+r),i<0&&(i=l[r].length+i-1),Ge.lineString([l[r][i],l[r][i+1]],s,e);case"MultiPolygon":return r<0&&(r=l.length+r),n<0&&(n=l[r].length+n),i<0&&(i=l[r][n].length-i-1),Ge.lineString([l[r][n][i],l[r][n][i+1]],s,e)}throw new Error("geojson is invalid")}function Dy(o,e){if(e=e||{},!Ge.isObject(e))throw new Error("options is invalid");var t=e.featureIndex||0,r=e.multiFeatureIndex||0,n=e.geometryIndex||0,i=e.coordIndex||0,s=e.properties,a;switch(o.type){case"FeatureCollection":t<0&&(t=o.features.length+t),s=s||o.features[t].properties,a=o.features[t].geometry;break;case"Feature":s=s||o.properties,a=o.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":a=o;break;default:throw new Error("geojson is invalid")}if(a===null)return null;var l=a.coordinates;switch(a.type){case"Point":return Ge.point(l,s,e);case"MultiPoint":return r<0&&(r=l.length+r),Ge.point(l[r],s,e);case"LineString":return i<0&&(i=l.length+i),Ge.point(l[i],s,e);case"Polygon":return n<0&&(n=l.length+n),i<0&&(i=l[n].length+i),Ge.point(l[n][i],s,e);case"MultiLineString":return r<0&&(r=l.length+r),i<0&&(i=l[r].length+i),Ge.point(l[r][i],s,e);case"MultiPolygon":return r<0&&(r=l.length+r),n<0&&(n=l[r].length+n),i<0&&(i=l[r][n].length-i),Ge.point(l[r][n][i],s,e)}throw new Error("geojson is invalid")}we.coordAll=xy;we.coordEach=eo;we.coordReduce=yy;we.featureEach=zh;we.featureReduce=vy;we.findPoint=Dy;we.findSegment=Ey;we.flattenEach=Vi;we.flattenReduce=My;we.geomEach=Tl;we.geomReduce=Sy;we.lineEach=Hh;we.lineReduce=wy;we.propEach=Nh;we.propReduce=by;we.segmentEach=Uh;we.segmentReduce=Cy});var $h=wt(J=>{"use strict";y();Object.defineProperty(J,"__esModule",{value:!0});var et=63710088e-1,Il={centimeters:et*100,centimetres:et*100,degrees:360/(2*Math.PI),feet:et*3.28084,inches:et*39.37,kilometers:et/1e3,kilometres:et/1e3,meters:et,metres:et,miles:et/1609.344,millimeters:et*1e3,millimetres:et*1e3,nauticalmiles:et/1852,radians:1,yards:et*1.0936},Pl={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:29155334959812285e-23,millimeters:1e6,millimetres:1e6,yards:1.195990046};function rr(o,e,t={}){let r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}function Ty(o,e,t={}){switch(o){case"Point":return Ol(e).geometry;case"LineString":return Al(e).geometry;case"Polygon":return Ll(e).geometry;case"MultiPoint":return jh(e).geometry;case"MultiLineString":return Vh(e).geometry;case"MultiPolygon":return Zh(e).geometry;default:throw new Error(o+" is invalid")}}function Ol(o,e,t={}){if(!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ji(o[0])||!ji(o[1]))throw new Error("coordinates must contain numbers");return rr({type:"Point",coordinates:o},e,t)}function Py(o,e,t={}){return Zi(o.map(r=>Ol(r,e)),t)}function Ll(o,e,t={}){for(let n of o){if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(n[n.length-1].length!==n[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<n[n.length-1].length;i++)if(n[n.length-1][i]!==n[0][i])throw new Error("First and last Position are not equivalent.")}return rr({type:"Polygon",coordinates:o},e,t)}function Iy(o,e,t={}){return Zi(o.map(r=>Ll(r,e)),t)}function Al(o,e,t={}){if(o.length<2)throw new Error("coordinates must be an array of two or more positions");return rr({type:"LineString",coordinates:o},e,t)}function Oy(o,e,t={}){return Zi(o.map(r=>Al(r,e)),t)}function Zi(o,e={}){let t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}function Vh(o,e,t={}){return rr({type:"MultiLineString",coordinates:o},e,t)}function jh(o,e,t={}){return rr({type:"MultiPoint",coordinates:o},e,t)}function Zh(o,e,t={}){return rr({type:"MultiPolygon",coordinates:o},e,t)}function Ly(o,e,t={}){return rr({type:"GeometryCollection",geometries:o},e,t)}function Ay(o,e=0){if(e&&!(e>=0))throw new Error("precision must be a positive number");let t=Math.pow(10,e||0);return Math.round(o*t)/t}function Xh(o,e="kilometers"){let t=Il[e];if(!t)throw new Error(e+" units is invalid");return o*t}function Rl(o,e="kilometers"){let t=Il[e];if(!t)throw new Error(e+" units is invalid");return o/t}function Ry(o,e){return Yh(Rl(o,e))}function Fy(o){let e=o%360;return e<0&&(e+=360),e}function _y(o){return o=o%360,o>180?o-360:o<-180?o+360:o}function Yh(o){return o%(2*Math.PI)*180/Math.PI}function By(o){return o%360*Math.PI/180}function Gy(o,e="kilometers",t="kilometers"){if(!(o>=0))throw new Error("length must be a positive number");return Xh(Rl(o,e),t)}function ky(o,e="meters",t="kilometers"){if(!(o>=0))throw new Error("area must be a positive number");let r=Pl[e];if(!r)throw new Error("invalid original units");let n=Pl[t];if(!n)throw new Error("invalid final units");return o/r*n}function ji(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Ny(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function zy(o){if(!o)throw new Error("bbox is required");if(!Array.isArray(o))throw new Error("bbox must be an Array");if(o.length!==4&&o.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");o.forEach(e=>{if(!ji(e))throw new Error("bbox must only contain numbers")})}function Uy(o){if(!o)throw new Error("id is required");if(["string","number"].indexOf(typeof o)===-1)throw new Error("id must be a number or a string")}J.areaFactors=Pl;J.azimuthToBearing=_y;J.bearingToAzimuth=Fy;J.convertArea=ky;J.convertLength=Gy;J.degreesToRadians=By;J.earthRadius=et;J.factors=Il;J.feature=rr;J.featureCollection=Zi;J.geometry=Ty;J.geometryCollection=Ly;J.isNumber=ji;J.isObject=Ny;J.lengthToDegrees=Ry;J.lengthToRadians=Rl;J.lineString=Al;J.lineStrings=Oy;J.multiLineString=Vh;J.multiPoint=jh;J.multiPolygon=Zh;J.point=Ol;J.points=Py;J.polygon=Ll;J.polygons=Iy;J.radiansToDegrees=Yh;J.radiansToLength=Xh;J.round=Ay;J.validateBBox=zy;J.validateId=Uy});var ep=wt(Ee=>{"use strict";y();Object.defineProperty(Ee,"__esModule",{value:!0});var ke=$h();function to(o,e,t){if(o!==null)for(var r,n,i,s,a,l,c,d=0,u=0,h,v=o.type,f=v==="FeatureCollection",M=v==="Feature",p=f?o.features.length:1,m=0;m<p;m++){c=f?o.features[m].geometry:M?o.geometry:o,h=c?c.type==="GeometryCollection":!1,a=h?c.geometries.length:1;for(var g=0;g<a;g++){var b=0,x=0;if(s=h?c.geometries[g]:c,s!==null){l=s.coordinates;var S=s.type;switch(d=t&&(S==="Polygon"||S==="MultiPolygon")?1:0,S){case null:break;case"Point":if(e(l,u,m,b,x)===!1)return!1;u++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(e(l[r],u,m,b,x)===!1)return!1;u++,S==="MultiPoint"&&b++}S==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-d;n++){if(e(l[r][n],u,m,b,x)===!1)return!1;u++}S==="MultiLineString"&&b++,S==="Polygon"&&x++}S==="Polygon"&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(x=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-d;i++){if(e(l[r][n][i],u,m,b,x)===!1)return!1;u++}x++}b++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(to(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Hy(o,e,t,r){var n=t;return to(o,function(i,s,a,l,c){s===0&&t===void 0?n=i:n=e(n,i,s,a,l,c)},r),n}function qh(o,e){var t;switch(o.type){case"FeatureCollection":for(t=0;t<o.features.length&&e(o.features[t].properties,t)!==!1;t++);break;case"Feature":e(o.properties,0);break}}function Wy(o,e,t){var r=t;return qh(o,function(n,i){i===0&&t===void 0?r=n:r=e(r,n,i)}),r}function Jh(o,e){if(o.type==="Feature")e(o,0);else if(o.type==="FeatureCollection")for(var t=0;t<o.features.length&&e(o.features[t],t)!==!1;t++);}function Vy(o,e,t){var r=t;return Jh(o,function(n,i){i===0&&t===void 0?r=n:r=e(r,n,i)}),r}function jy(o){var e=[];return to(o,function(t){e.push(t)}),e}function Fl(o,e){var t,r,n,i,s,a,l,c,d,u,h=0,v=o.type==="FeatureCollection",f=o.type==="Feature",M=v?o.features.length:1;for(t=0;t<M;t++){for(a=v?o.features[t].geometry:f?o.geometry:o,c=v?o.features[t].properties:f?o.properties:{},d=v?o.features[t].bbox:f?o.bbox:void 0,u=v?o.features[t].id:f?o.id:void 0,l=a?a.type==="GeometryCollection":!1,s=l?a.geometries.length:1,n=0;n<s;n++){if(i=l?a.geometries[n]:a,i===null){if(e(null,h,c,d,u)===!1)return!1;continue}switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(i,h,c,d,u)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<i.geometries.length;r++)if(e(i.geometries[r],h,c,d,u)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}h++}}function Zy(o,e,t){var r=t;return Fl(o,function(n,i,s,a,l){i===0&&t===void 0?r=n:r=e(r,n,i,s,a,l)}),r}function Xi(o,e){Fl(o,function(t,r,n,i,s){var a=t===null?null:t.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return e(ke.feature.call(void 0,t,n,{bbox:i,id:s}),r,0)===!1?!1:void 0}var l;switch(a){case"MultiPoint":l="Point";break;case"MultiLineString":l="LineString";break;case"MultiPolygon":l="Polygon";break}for(var c=0;c<t.coordinates.length;c++){var d=t.coordinates[c],u={type:l,coordinates:d};if(e(ke.feature.call(void 0,u,n),r,c)===!1)return!1}})}function Xy(o,e,t){var r=t;return Xi(o,function(n,i,s){i===0&&s===0&&t===void 0?r=n:r=e(r,n,i,s)}),r}function Kh(o,e){Xi(o,function(t,r,n){var i=0;if(t.geometry){var s=t.geometry.type;if(!(s==="Point"||s==="MultiPoint")){var a,l=0,c=0,d=0;if(to(t,function(u,h,v,f,M){if(a===void 0||r>l||f>c||M>d){a=u,l=r,c=f,d=M,i=0;return}var p=ke.lineString.call(void 0,[a,u],t.properties);if(e(p,r,n,M,i)===!1)return!1;i++,a=u})===!1)return!1}}})}function Yy(o,e,t){var r=t,n=!1;return Kh(o,function(i,s,a,l,c){n===!1&&t===void 0?r=i:r=e(r,i,s,a,l,c),n=!0}),r}function Qh(o,e){if(!o)throw new Error("geojson is required");Xi(o,function(t,r,n){if(t.geometry!==null){var i=t.geometry.type,s=t.geometry.coordinates;switch(i){case"LineString":if(e(t,r,n,0,0)===!1)return!1;break;case"Polygon":for(var a=0;a<s.length;a++)if(e(ke.lineString.call(void 0,s[a],t.properties),r,n,a)===!1)return!1;break}}})}function $y(o,e,t){var r=t;return Qh(o,function(n,i,s,a){i===0&&t===void 0?r=n:r=e(r,n,i,s,a)}),r}function qy(o,e){if(e=e||{},!ke.isObject.call(void 0,e))throw new Error("options is invalid");var t=e.featureIndex||0,r=e.multiFeatureIndex||0,n=e.geometryIndex||0,i=e.segmentIndex||0,s=e.properties,a;switch(o.type){case"FeatureCollection":t<0&&(t=o.features.length+t),s=s||o.features[t].properties,a=o.features[t].geometry;break;case"Feature":s=s||o.properties,a=o.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":a=o;break;default:throw new Error("geojson is invalid")}if(a===null)return null;var l=a.coordinates;switch(a.type){case"Point":case"MultiPoint":return null;case"LineString":return i<0&&(i=l.length+i-1),ke.lineString.call(void 0,[l[i],l[i+1]],s,e);case"Polygon":return n<0&&(n=l.length+n),i<0&&(i=l[n].length+i-1),ke.lineString.call(void 0,[l[n][i],l[n][i+1]],s,e);case"MultiLineString":return r<0&&(r=l.length+r),i<0&&(i=l[r].length+i-1),ke.lineString.call(void 0,[l[r][i],l[r][i+1]],s,e);case"MultiPolygon":return r<0&&(r=l.length+r),n<0&&(n=l[r].length+n),i<0&&(i=l[r][n].length-i-1),ke.lineString.call(void 0,[l[r][n][i],l[r][n][i+1]],s,e)}throw new Error("geojson is invalid")}function Jy(o,e){if(e=e||{},!ke.isObject.call(void 0,e))throw new Error("options is invalid");var t=e.featureIndex||0,r=e.multiFeatureIndex||0,n=e.geometryIndex||0,i=e.coordIndex||0,s=e.properties,a;switch(o.type){case"FeatureCollection":t<0&&(t=o.features.length+t),s=s||o.features[t].properties,a=o.features[t].geometry;break;case"Feature":s=s||o.properties,a=o.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":a=o;break;default:throw new Error("geojson is invalid")}if(a===null)return null;var l=a.coordinates;switch(a.type){case"Point":return ke.point.call(void 0,l,s,e);case"MultiPoint":return r<0&&(r=l.length+r),ke.point.call(void 0,l[r],s,e);case"LineString":return i<0&&(i=l.length+i),ke.point.call(void 0,l[i],s,e);case"Polygon":return n<0&&(n=l.length+n),i<0&&(i=l[n].length+i),ke.point.call(void 0,l[n][i],s,e);case"MultiLineString":return r<0&&(r=l.length+r),i<0&&(i=l[r].length+i),ke.point.call(void 0,l[r][i],s,e);case"MultiPolygon":return r<0&&(r=l.length+r),n<0&&(n=l[r].length+n),i<0&&(i=l[r][n].length-i),ke.point.call(void 0,l[r][n][i],s,e)}throw new Error("geojson is invalid")}Ee.coordAll=jy;Ee.coordEach=to;Ee.coordReduce=Hy;Ee.featureEach=Jh;Ee.featureReduce=Vy;Ee.findPoint=Jy;Ee.findSegment=qy;Ee.flattenEach=Xi;Ee.flattenReduce=Xy;Ee.geomEach=Fl;Ee.geomReduce=Zy;Ee.lineEach=Qh;Ee.lineReduce=$y;Ee.propEach=qh;Ee.propReduce=Wy;Ee.segmentEach=Kh;Ee.segmentReduce=Yy});var rp=wt(Yi=>{"use strict";y();Object.defineProperty(Yi,"__esModule",{value:!0});var Ky=ep();function tp(o,e={}){if(o.bbox!=null&&e.recompute!==!0)return o.bbox;let t=[1/0,1/0,-1/0,-1/0];return Ky.coordEach.call(void 0,o,r=>{t[0]>r[0]&&(t[0]=r[0]),t[1]>r[1]&&(t[1]=r[1]),t[2]<r[0]&&(t[2]=r[0]),t[3]<r[1]&&(t[3]=r[1])}),t}var Qy=tp;Yi.bbox=tp;Yi.default=Qy});var ap=wt((cD,_l)=>{y();var Tt=Rh(),op=Dl(),ip=Wh(),rn=rp().default,eb=ip.featureEach,aD=ip.coordEach,lD=op.polygon,np=op.featureCollection;function sp(o){var e=new Tt(o);return e.insert=function(t){if(t.type!=="Feature")throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:rn(t),Tt.prototype.insert.call(this,t)},e.load=function(t){var r=[];return Array.isArray(t)?t.forEach(function(n){if(n.type!=="Feature")throw new Error("invalid features");n.bbox=n.bbox?n.bbox:rn(n),r.push(n)}):eb(t,function(n){if(n.type!=="Feature")throw new Error("invalid features");n.bbox=n.bbox?n.bbox:rn(n),r.push(n)}),Tt.prototype.load.call(this,r)},e.remove=function(t,r){if(t.type!=="Feature")throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:rn(t),Tt.prototype.remove.call(this,t,r)},e.clear=function(){return Tt.prototype.clear.call(this)},e.search=function(t){var r=Tt.prototype.search.call(this,this.toBBox(t));return np(r)},e.collides=function(t){return Tt.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=Tt.prototype.all.call(this);return np(t)},e.toJSON=function(){return Tt.prototype.toJSON.call(this)},e.fromJSON=function(t){return Tt.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var r;if(t.bbox)r=t.bbox;else if(Array.isArray(t)&&t.length===4)r=t;else if(Array.isArray(t)&&t.length===6)r=[t[0],t[1],t[3],t[4]];else if(t.type==="Feature")r=rn(t);else if(t.type==="FeatureCollection")r=rn(t);else throw new Error("invalid geojson");return{minX:r[0],minY:r[1],maxX:r[2],maxY:r[3]}},e}_l.exports=sp;_l.exports.default=sp});var Ki=wt((LD,Ji)=>{y();(function(){"use strict";function o(s,a){var l=s.x-a.x,c=s.y-a.y;return l*l+c*c}function e(s,a,l){var c=a.x,d=a.y,u=l.x-c,h=l.y-d;if(u!==0||h!==0){var v=((s.x-c)*u+(s.y-d)*h)/(u*u+h*h);v>1?(c=l.x,d=l.y):v>0&&(c+=u*v,d+=h*v)}return u=s.x-c,h=s.y-d,u*u+h*h}function t(s,a){for(var l=s[0],c=[l],d,u=1,h=s.length;u<h;u++)d=s[u],o(d,l)>a&&(c.push(d),l=d);return l!==d&&c.push(d),c}function r(s,a,l,c,d){for(var u=c,h,v=a+1;v<l;v++){var f=e(s[v],s[a],s[l]);f>u&&(h=v,u=f)}u>c&&(h-a>1&&r(s,a,h,c,d),d.push(s[h]),l-h>1&&r(s,h,l,c,d))}function n(s,a){var l=s.length-1,c=[s[0]];return r(s,0,l,a,c),c.push(s[l]),c}function i(s,a,l){if(s.length<=2)return s;var c=a!==void 0?a*a:1;return s=l?s:t(s,c),s=n(s,c),s}typeof define=="function"&&define.amd?define(function(){return i}):typeof Ji<"u"?(Ji.exports=i,Ji.exports.default=i):typeof self<"u"?self.simplify=i:window.simplify=i})()});var Xm=wt((Cc,wc)=>{y();(function(o,e){typeof Cc=="object"&&typeof wc<"u"?wc.exports=e():typeof define=="function"&&define.amd?define(e):(o=o||self,o.TinyQueue=e())})(Cc,function(){"use strict";var o=function(r,n){if(r===void 0&&(r=[]),n===void 0&&(n=e),this.data=r,this.length=this.data.length,this.compare=n,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};o.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},o.prototype.pop=function(){if(this.length!==0){var r=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),r}},o.prototype.peek=function(){return this.data[0]},o.prototype._up=function(r){for(var n=this,i=n.data,s=n.compare,a=i[r];r>0;){var l=r-1>>1,c=i[l];if(s(a,c)>=0)break;i[r]=c,r=l}i[r]=a},o.prototype._down=function(r){for(var n=this,i=n.data,s=n.compare,a=this.length>>1,l=i[r];r<a;){var c=(r<<1)+1,d=i[c],u=c+1;if(u<this.length&&s(i[u],d)<0&&(c=u,d=i[u]),s(d,l)>=0)break;i[r]=d,r=c}i[r]=l};function e(t,r){return t<r?-1:t>r?1:0}return o})});var $m=wt((UA,Ec)=>{"use strict";y();var Ks=Xm();Ks.default&&(Ks=Ks.default);Ec.exports=Ym;Ec.exports.default=Ym;function Ym(o,e,t){e=e||1;for(var r,n,i,s,a=0;a<o[0].length;a++){var l=o[0][a];(!a||l[0]<r)&&(r=l[0]),(!a||l[1]<n)&&(n=l[1]),(!a||l[0]>i)&&(i=l[0]),(!a||l[1]>s)&&(s=l[1])}var c=i-r,d=s-n,u=Math.min(c,d),h=u/2;if(u===0){var v=[r,n];return v.distance=0,v}for(var f=new Ks(void 0,E0),M=r;M<i;M+=u)for(var p=n;p<s;p+=u)f.push(new ur(M+h,p+h,h,o));var m=T0(o),g=new ur(r+c/2,n+d/2,0,o);g.d>m.d&&(m=g);for(var b=f.length;f.length;){var x=f.pop();x.d>m.d&&(m=x,t&&console.log("found best %d after %d probes",Math.round(1e4*x.d)/1e4,b)),!(x.max-m.d<=e)&&(h=x.h/2,f.push(new ur(x.x-h,x.y-h,h,o)),f.push(new ur(x.x+h,x.y-h,h,o)),f.push(new ur(x.x-h,x.y+h,h,o)),f.push(new ur(x.x+h,x.y+h,h,o)),b+=4)}t&&(console.log("num probes: "+b),console.log("best distance: "+m.d));var S=[m.x,m.y];return S.distance=m.d,S}function E0(o,e){return e.max-o.max}function ur(o,e,t,r){this.x=o,this.y=e,this.h=t,this.d=D0(o,e,r),this.max=this.d+this.h*Math.SQRT2}function D0(o,e,t){for(var r=!1,n=1/0,i=0;i<t.length;i++)for(var s=t[i],a=0,l=s.length,c=l-1;a<l;c=a++){var d=s[a],u=s[c];d[1]>e!=u[1]>e&&o<(u[0]-d[0])*(e-d[1])/(u[1]-d[1])+d[0]&&(r=!r),n=Math.min(n,P0(o,e,d,u))}return n===0?0:(r?1:-1)*Math.sqrt(n)}function T0(o){for(var e=0,t=0,r=0,n=o[0],i=0,s=n.length,a=s-1;i<s;a=i++){var l=n[i],c=n[a],d=l[0]*c[1]-c[0]*l[1];t+=(l[0]+c[0])*d,r+=(l[1]+c[1])*d,e+=d*3}return e===0?new ur(n[0][0],n[0][1],0,o):new ur(t/e,r/e,0,o)}function P0(o,e,t,r){var n=t[0],i=t[1],s=r[0]-n,a=r[1]-i;if(s!==0||a!==0){var l=((o-n)*s+(e-i)*a)/(s*s+a*a);l>1?(n=r[0],i=r[1]):l>0&&(n+=s*l,i+=a*l)}return s=o-n,a=e-i,s*s+a*a}});y();y();globalThis.MappedinDebug||(globalThis.MappedinDebug={});globalThis.MappedinDebug.__idleCallbackInteractionState={isInteracting:!1,interactionCheckers:[],pendingCallbacks:[],registerInteractionChecker:function(o){this.interactionCheckers.push(o)},unregisterInteractionChecker:function(o){let e;for(let t=this.interactionCheckers.length-1;t>=0;t--)if(e=this.interactionCheckers[t],e===o){this.interactionCheckers.splice(t,1);break}},checkInteraction:function(){let o=!1;for(let e=0;e<this.interactionCheckers.length;e++)if(o=this.interactionCheckers[e](),o)return!0;return!1},addPendingCallback:function(o,e){this.pendingCallbacks.push({callback:o,timeoutId:e}),this.scheduleDeferredCheck()},scheduleDeferredCheck:function(){var o=this;this.checkTimeoutId||(this.checkTimeoutId=setTimeout(function e(){if(o.checkInteraction())o.checkTimeoutId=setTimeout(e,16);else{o.checkTimeoutId=null;var t=o.pendingCallbacks.slice();o.pendingCallbacks=[];let r;for(let n=0;n<t.length;n++)if(r=t[n],r&&r.callback)try{r.callback()}catch{}}},16))},removePendingCallback:function(o){let e;for(let t=this.pendingCallbacks.length-1;t>=0;t--)if(e=this.pendingCallbacks[t],e.timeoutId===o){this.pendingCallbacks.splice(t,1);break}}};globalThis.requestIdleCallback=globalThis.requestIdleCallback||function(o){var e=performance.now(),t,r=!1,n=function(){if(!r){r=!0;try{o({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(performance.now()-e))}})}catch{}}};return globalThis.MappedinDebug?.__idleCallbackInteractionState?.checkInteraction()?(t=Date.now()+Math.random(),globalThis.MappedinDebug.__idleCallbackInteractionState.addPendingCallback(n,t),t):(t=setTimeout(n,0),t)};globalThis.cancelIdleCallback=globalThis.cancelIdleCallback||function(o){clearTimeout(o),globalThis.MappedinDebug?.__idleCallbackInteractionState?.removePendingCallback(o)};y();y();(function(){typeof globalThis!="object"&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__)})();var Tu="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAkGBwgHBgkICAgKCgkLDhcPDg0NDhwUFREXIh4jIyEeICAlKjUtJScyKCAgLj8vMjc5PDw8JC1CRkE6RjU7PDn/2wBDAQoKCg4MDhsPDxs5JiAmOTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTn/wgARCAIABAADAREAAhEBAxEB/8QAGwABAAMBAQEBAAAAAAAAAAAAAAECAwQFBgf/xAAWAQEBAQAAAAAAAAAAAAAAAAAAAQL/2gAMAwEAAhADEAAAAP3EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAIAAAJAFAAAAAAAAAAAAAAAAAAAAAAAAABAgAAEgCgAAAAAAAAAAAAAAAAAAAABERLSM1zM4zXMzjMoUIqCCSSS8XNC9mpoaVomharWTQAAAAAAAAAAAAAAAAEREtIoZrnGZkucUKFStQQSTFixdNDStF0TWrmiWqbJoAAAAAAAAAAAAAIgiWkZy4HNLzHLXKcxzpzmFYmRkUKFSCCSSxcuampsbR0HSdK9R1R1HTZvWll0mlAAAAAAAAAAAIiKLnLjHNLynLXKcycxzmNYmJmUKFSCAWLFy5qamxvHQvSdJ0nVHUdFm1aparWKAjNWSKAAAAARBEtYzlyXnjmOSuM4U4q4jjOM5a5k5zAyMjOqFCCCCSSS5c0jU1NzoOk6pew7TtjuO1e0646jezWr2WSaUAAAAAECIqtZco55eY464zhTirhOI5Dks5jAwMTIzqhUqQASWLFzSNTY3Og6V646zsO2O47V7DrjqNzWy9nlZ1c0LlrLEk0EQQVipRczIyMU5q5F4U8+vOPOrgThOOuU5jAxMjMzKpUggigJiSSxY0XQ1Njc6TqjtO49CX0D0T0Y7l7E6JdzU1NEvViSalBAWIqVKLSMjIxOauM4U86vPPOrz04TjrkOYwMTIzKJQqQQCKmBJJYutzQ1Njc6TrOyO475fRPRPQjuXsToXWPn6kkkEkhCkEAgggqVMjlrzzzDy7PMPPrhOQ5jBMqoVIIIAAIAJAAJJJLFzWN16TsO49CPTPUl9Q9A6o1LFiSSSSQpCwQQCCCpVMjlrzzyzy7PMPPrhOM5kwM6zKlQQAAQASAASCxY0NI3XpOw7j0I9M9SX0z0DqjU+UqpQqVIBFgEyixJYuWLFDkrzE8o8yvOONOasipBAAAAAAAAAAABJJY2OiO1fQPUj1T0pewuVKlCCqQsBIUSSSSWLlyTM5K808pPLrzziTnrEqQQAAAAAAAAAAASSWNjojtX0D1I9VfSOuND4uzMzqhQqVIALEli5c1jUuQc1vnp5pwJzVmQQAAAAAAAAAAAAAASSaHTHevpHoHTFjMyM6zKlSpABJJcsaGkamhU5q88804E5qzIIAAAAAAAAAAAAAAJJNDpjvX0j0Dqix8dVDMolSpAqCYElixc0XU0IMjlTlrIqAAAAAAAAAAAAAAAAAWNTqjqXYGZkZpUoQQRSFIsSXLroaGhBkcqctZFQAAAAAAAAAAAAAAAACxqdUdS7EngWQCAAQASACSSSwKlSCAAAAAAAAAAAAAAAAAACSSxYFSCCAACCQACSSSwKlSCAAAAAAAAAAAAAAAAAACSSxYGIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAJAJAJBAAIAIABAAAAAAAAAAAAAAAAAAAABIAJAJAJBAAIAIABAAAAJABAAAAAAAAAJBILEli5Y0LlzQ0Lly5csWLAkgFSChUoUMyhmUMyhQqVKkEEAEAAAAAAAAAkEgsSWLljQuXNDQuXLlyxYsCSAVIKFShQzKGZQzKFCpUqQe+ZmZkUKFCpUEEAAkksWLFzQ0NTU2NzY3Og3NzoNzc2NjU1NS5csSAQVKmZmZGRiYmBgYHOYGBgYGBiZGRkUMypUqQCAASSWLFi5oaGpqbG5sbnQbm50G5ubGxqampcuWJAIIKGZmZGRiYmBgYHOYGBgYGR+jmBzmBzmJiZGZQoQQSSWLmhqbGxudB0nSdJ1HSdR1HSdJ0G5qamhcsWJJJBIIIBUqVKFDIyMDA5jmOU5TlOY5TmOc5znMTEyMyhQggFixc0NTY2NzoOk6TpOo6TqOo6TpOg3NTU0LlixJJIJBAIKkFChQyMjAwOY5jlOU5jnP00yMTnOc5zAwMjMoVIJJLmhqbmx0HQdBubmxqXLkkgAAAAAAAAAAAAAEEFTMzMTEwOc5znMDAyMyhUgkkuaGpsbnQdB0G5ubGpcuSSAAAAAAAAAAAAAAQQVKGZ1gAEEEEFSCACSSxJJJIAAAAAAAAAAAAAAAAAAAAAAABBBBBUggAkkksSSSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCCpBUqQVIKggAkFiSSxYksSSSSAAAAAAAAAAAAAAAAAAQCCpBUqQVIKggAkFiSSxYksSWBIAAKFiQAAAAAAAAACCpUoUMzIyMzMzMyhQoVKkEEAgkEkklixYuXNDQ0NTQ1NC5cuWJAAAAAAAAAAIKlShQzMjIzMzMzKFChUqQQQCCQSSSWLFyxoXNDQ1NDU0LljUkkAAAAAAAAAAggggEEAgAAAAAAAAAAAAAEkgkkkkkAAAAAAAAAAgggggEAgAAAAAEgEAAAAAAEkgkkuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADyyCCCCCCCCAQASCSQWJJJJLEkkkkkgkkEgkAEgAAEAAgEAggEEEEEEEFSCCCCCCAQASCSQWJJJJLEkkkkkgkkEgEgEgAAEAAgEAggEEEEEH5AQQQQVBBAIAAJBIJJJLEkkkkliSSSSSQSSCQSAAAQAQQCCCCCCCCCpBBBBBUEEEAgAAkEgkkksSSSSSWJJJJJJBJIJBIAABABBAIIIIIIIIKg/LCAQCACAAAACQCQSCQSASSASCQCQAAAAAAQCAQAQCAQAQQCACAAAACQCQSCQSASSASCQCQAAAAAAQCAQAQCAQfPgAAAAAAAAAAAAAAkAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAgAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/xAApEAAABQUBAQACAwACAwAAAAABAgQFFQMGERQWEhNAUAAgMGCAkKCw/9oACAEBAAECAP8AwTZznOf3mc5/YZE41xVivFyM6i7C8C8C8zMzMzMyDyDyDyDwV4K7ldSuZV5VgVwqZ/SCca4qxXmcjOouwvAvEzMzMzMzMyDyDyDwV4K7ldSuRVwKgrgf88TDWMrO4VHOo61Hao7ndzvB3k7yZ5M8i8i8zMzMzMyDyDyDyV5K8keSPJHmm8U3em70nam603Mi8qotUDfk5GqZUdfUc6jrUdqjvUeDvB3kzyZ5M8i8i8zMzMzMzMg8g8leSvJHkjyR5pvFN4pu9N2pOtNzIvKqLWA39PX+/saplJlh1tRfVcKrlVdKrrVdqrvVdzu53Y7sZ2M6mdRdRdBdJSUk5SUB0B0B1K6kdSOxHam7Unek70nei7UXWi6UXKk40l9NaRWWuB8/75E41zKjraq+q41nOq6VXas7VXeq71Hc7ud2O7GdRdRdZQXSUlJSUlAdCugOpXUjqR2I7U3em70nek70nai60XSk5UnGkvItIrKoCsC0FwLgXAuBbube3ubm7uiuFcZcZaZYdZUWVl1dwruVdzrulZ0qulVzqOR3EzgZeZcZcK0Vm3t7W1tbW1tgrBYC0q0q4q8jgRxpuVJzoulB0oOlBzoOVBworqa0iwi0i0q4FwLQWAr2trZ2trb3RWiuFcZaZadbUW1l1ZwruVd0rulZ0qulVzqOR3E7gZeZeK4VorNzb29ra2tsFe2CwFpVxVxV5HAjjTcqTnRdKDpQdKDnQcqDhRXU1pFhVm/ISUnKSkrLSsrKyspJyUhvitOtrLq69Q4qHGu41nGqvqLjrDKhUDW+nv1nP+Oc+vYVArFUEVEWUl1FfQcU7imckzinX0VxFoLgXyMlJykrLS0tLS0rKSclI74rjraq6uvUuKhxruNdxqr6i46wysVA1vp79Zz/AI5z6A4VArFUEVkWUl1FfQcU7imcUzinX0VxFoLZKTlJWVlpaXl5eWlpWUB0BzBxkDr669SvUr666stqqz1xqes/j5AxahFFJXRWp1yZemX0F5HCQkpOUlZaWlpeXl5aWB2lQdAcwcZE7hWcFLgpXqF1ZbVVnUDU9Z/HyBi1CV6SuitTrky9MvoLyL5AXEXEXIXIXKSkpKSkpIHIHIHIrkVxK4yJnCsvrra6uqpPVE354GJVpKaCtOtoryuEiZxM5C5C5C5SUnJSclJSQOQORXIrkVxBxM4VV9dbXV1VJ6om/PAxKtFTQVp1tFeRwkRWitFYKvb2tra2draBUCsFgLCrSrQWitOsqqT1RN+jAxKtJTTWFWitMtMtFYKzb29ra2tnaBUCsFZVhVpVoLRWnWVFJ6om/RgYlWkpprAW73v36zn++c+gOFQKv1GoJv04GCp9Rq/T36zn++c+gOFT7fUagm/TgYKn1+3/AKEeMefHjx8/n8vl8vn8/Hjx5xj9bjHnx48fP5/L5fL5/Px48ecY/wAvOPxceQIFIKIJgSAiBAVuK2FaitINAM4MwMwMsJCQkJCQkJCwosws4tAtItQtgtot4oRSCm+Hy8ecfi48gQKQUQTAkBECArcVsK1FaQaAZwZgZgZYSEhISEhISFhRZhZxaBaRahbBbRbxQikFN8BpfMWgWozWLaLcKAUWpq62vr/DX19YEoJARAhBvK2laytRGgjORlIyEYiMJLfJbxLdJbhLbJbRLaJbJbZLbAWxzHMcxzHMcxzHMDbBrYNbJraNbRrbPbh7dPbx7fOwHYjsZ2UzMZoM0maxbRbhQCi1NXW19fX19fW1QSAiBCDeVtK1laiNBGYjKRkIxEYSW+S3iW6S3CW2S2iW0S2S2yW2AtgLY5jmOY5jmOY5gbYNbJrZNbRraPbZ7cPbp7ePb52A7EdjOymZjW4e3D26e3j2+ZgMwmYhYxY4SEhISEBjKxlYiMJGAjAS3iW9TtynblO26dtUrap2zTtmnbNO2SW2S3isRWYGkG0EAItTW1/h8Phr6+rp6AtwtQs5mI9vntw9tHtk9s1LZqWzUto9tnts9uHt09vHt8zAZhMxCxixwkJCQkIDGVjKxEYSMBGAlvEt6nblO3Kdt0rap21TtmnbNO2SWyS2yW8ViKzA1A2ggBFqa2v8Ph8NfW1dPRFuFqMzGYjW+e3D20e2T2zUtk9tHto1tCzHYj2+e3T24e3D24a3DW4Nuc5znOc4FuBbhbcLbhLcJblO3CW4S3iMRGcrYVECcKYB+cJBoCjM2maDsZ7fPbp7cPbh7cNbhrcG3Oc5znOcC3C24W3C24S3CW5TtwluEt4jERnK2FRAnCmAfnCQaAoxb/7ePl8NbU09PT1NYKHy8Y/ZePl8NbU09PT1NYKHy8Y/4Z6+g1tjb3d+Rk5SVlZWVlZSTkd8Fu3s/b6es/pvX0Gtsbe7vyMnKSkrKysrKSciC8Fu3s/YKnrP9gqAb8X0NQawqBVCrMrMqMoGuNUTiYf4ICT5/L4/H4fD4fH4hSCmBAAP4AgctUtYqgqoqsqsqoFIVwqAb8X0NQawqBVCrMrMqMoGuNUTiYf4ICT5/L4/H4fD4fH4hSCmBAAP4AgctUtYqgqkqsqsqsFIV/Hn8XHj5/H4a+traurq6mpqampqampqampqampqampqampqamrq62tr/D4/Lx5/Fx4+fx+Gvra2rq6upqampqampqamrq6upqampqampqamrq6utra/w+Py/wCgEzNTc5OTs7PT09PT8/Pz09PT07Ozk3Ng9TMxLy0rKSclJSMhIb+9vbu9u7u7u7u7u729vb2/vyEjJSUnKSstLzEzNTc5OTs7Oz09PT8/Pz09PT07Ozk5NzUzMS8tKyknJSUjISG/v727vbu7u7u7u7u9u729v78hIyUlJykrLS8x0nR9H0fR9H0XRdF0XRdD0PQ9F0XRdF0XRdF0fR9H0nSdJ0vS9L0vTdN03TdP0/T9P0/T9P0/T9P0/T9R0/T9P0/T9P0/TdN03S9L0vS9J0nSdJ0fR9H0XRdF0PRdD0PQ9D0PRdF0XRdF0XR9H0fSdJ0nS9L0vS9N03TdN0/T9P0/T9P0/T9P0/T9P1HT9P0/T9P0/T9N03TdL0vS9L0vSS8tLy0tLS0rKysrKysrKysrKystLS0vLS8vLy8vMTExMTExMzMzMTMzMzM1NTUzMzMzMzMzMzExMTExMS8vLy8vLy8tKy0tKysrKysrKysrKysrLS0tLy0vLy8vLzExMTExMTMzMzEzMzMzNTU1MzMzMzMzMzMxMTExMTEvLy8vnOc5znOc5znOc5znOc5znOc59ZznPr169evXr169evXr169evXr16znOfWc5znOc5znOc5znOc5znOc5znOc59ZznPr169evXr169evXr169evXr16znOfWc5z/9YD//xAArEAEAAgIDAQABBAICAQUAAAAAAVICYgNRYQRBEEBQUzFCIDARYICQoLD/2gAIAQEAAz8A/wDgmhCEI/nYQj+RhjH5ccflxw44YMe0dtmzZs2bNmzZs2bIsjtiwlxy45/Ljn8se0fwuPbjj8uOPy44YQxR2izZs2bNmzZs2bNkWR2xYS45cc/lhP5Y9/wEQwj8sIRD1s2bNmzZs2bNmzZs2bNmzZs2bNmzZs2bNmyLMZYZMZ/KJ/dRDCPywhjCI/LZs2bNmzZs2bNmzZs2bNmzZs2bNmzZs2bNkWYywlhP5RP/ABj9hDGGMIh69bNmzZs2bNmzZsmybJsmybJsmybJsmybJsmybJs2bNmzZs2bNmzZ7+mMsZYyj9hDGGMIj9NmzZs2bNmzZs2bJsmybJsmybJs2TZNk2TZNk2bJs2bNmzZs2bNmzZ6iWMsXr16hiwYMGDBgwYo/T169/T162bNmzZs2TZNk2T2ntPae09pSlKUpSlPae09p7T2mybJsmzZs2bNmz17+nr16hiwYOPtx9uPtx9sO2DBih69evXr1s2bNmzZsmybJsmye09p7T2lKUpSlKU9p7T2ntNk2TZNmzZs2bNmz17+vr1s2bNmzZs2bNmzZs2evXr169bNmye09p7SlKUp/wC6UpSlKe09p7etmzZs9evWzZs2bNmzZs2bNmzZs2bPXr1s9bNmye09p7SlKUp/7pSlKUp7T29bPWz169evWzZs2bNmzZs2bNmzZs2bNmzZs2evU9plM/vJhMJ7T29bNnrZ62bNmzZs2bNmzZs2bNmzZs2bNnr39J7TKZ/eTCYT3+nr162bNnrZs2bJsntNk2TZPabNmzZs2etnr39JlM/wUwmP09etmzZs2bNk2TZNk2TZNk2bNmzZs2bNnv6TKZ/gphMfp69etk9p7T2ntKUpSlKUp7T2nt69e/pMpn+GmH/j9PXr1Pae09pSySlklKU9p7T29evf0mUz/DTCY/T16lP/AHSlKU/xUpSlP/dKUpT/ABUpT/8AQllKWTJl0y6ZdMumXTLpl0y6ZJSn+QlKWTJl0y6ZdMumXTLpl0y6ZJSn/sn9xKWXTLpn0z6Z9M+mXTLplVlVlVlVlVlVlVlVlVlVlRlVlVlRlVlVlVlVlVlVlVl0z6Z9M4/DPpn0z6ZdMkp/byll0y6Z9M+mfTPpn0y6ZVZVZVZVZVZVZVZVZUZVZUZVZVZVZVZVZVZVZVZVZVZdM+mfTOPwz6Z9M+mTJlVlVlVl0yZ9M2fTPpn0z6Z9M+mbPpn0z6Z9M2fTPpl0yqyqyqyqyqyomiaJomiaJomiaJomjRo0aNGjRo0aNGjRNE0TRNE0TRNE0TRNE0ZVZVZVZVZVZVZM+mbPpn0z6Z9M+mfTNn0z6Z9M+mfTPpl0y6ZVZVZVTVlVlRNE0TRlRNE0TRNE0TRo0aNGjRo0aNGjRomiaJomiaJomiaJomqaJqyq0TRNE0TRNE0TVNE1TVNU1TRNE1TVNU0TRNE0TRNGjRo0aNGjRhWHFHTgh88Pmj8Pnj/V89HBRwf1w4f64cNMXFSHFTFxUxcVIcP9cOGkOCkPno+ej55/D55cEuKemHUIo0aNGjRo0TRNE0TRNE0TVNE0TVNE1TVNE1TRNU0TRNE0TRNGjRo0aNGjRhWHFHThh88Pnj8Pnq+ejgo4P64cP9cOKkOKkOKmLipi4aYuH+uHBSHBSHz0fPR88/h88uCXFNWHUIo0aNGjRo4ZcU9MOoRRFGjRo0aNGjRo0aNGjRo0RRhVxR04IcGP4cGP+jij/GEMI/xjCP3+M/5xhxT/AJwhwT/o4Mv9XBk4p6YdQiiKNGjRo0aNGjRo0aNGjRoijGsOKOnBi4Mfw4I/0cUf4whhH+MYR+/xn/OMOKf84Q4J/wBHBP8Ar/zxrDCsOKkOKjhq4auGrhq4auGjipDjpDGsI/k8awwrDipDio4aOGrhq4auGrho4qQ46QxrCP8A0bHcMLQ47w4rw4buCzgs4O3A4HA4XA4HA4HA4O3BZwWcN3Fdx3hhaGNoR/Dx3DC0OO8OK8OG7gs4LODtwOBwOFwOBwOBwODtwWcFnDdxXcd4YWhjaEf88UftoQh4y6ZuRyuVzOZzeudz+uf1z+uf1z+uf1z+uf1zuf1z+uf1z+uf1z+udzR25nM5o7c3rlcrlZsniOkSj9tCEPGXTNyuVy+uZzOb1z+uf1z+uf1z+uf1z+uf1z+udz+uf1z+uf1z+uf1z+ueO3O5nM5vXK5XKzZPEdMUftoYsemHTDpx9OPpxVcVXDVw1cNXDVw0cNHDRw0cNHDRw0cNHDRw0cNHDRw0cNHDRw0cNHDVw1cNXFVxVcVXFVx9OPph0w6Yo/bQxY9MOnH04+nH04quKrhq4auGrhq4aOGjho4aOGjho4aOGkOGkOGkOGjho4aOGjho4aOGjhq4auGriq4quKriq4+nH0w6Ydf+wHgcLhcLicTjYdww7hh3DDuGPcMe4Y9ww7hh3DDuGHcONxuJxOFwuBwOB8753z2fPZ89nz3fNd893zXfPd893z3fP/Y+e757uC75/wCyHz/2Q+f+yHBd893z3fPd893z3fPd893zXfNd893z2fPZ8/b5+3zvncDgcLhcLicTjYdww7hh3DDuGHcMe4Ydww7hh3DDuGHcONxuJxOFwuBwPnfO+d89nz2fPZ893zXfPd813z3fPd893z/2Pnu+e7gu+f8Ash8/9kPn/shwXcF3z3fPd893z3fPd893zXfNd893z2fPZ8/b5+3zvncDdu3bt03bt26bpum6bpum6bt27du3bt26bt26bpum6bpum6bpum6bt03TdN26bpum6bpum7dN03TdN03TdN03TdN03Tdum7dum7dN27dum6bpum6bpum6bpum7du3bt03bpu3bpum6bpum6bpum6bpu3TdN03bpum6bpum6bt03TdN03TdN03TdN03TdN03TduysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysysmzKzKzKybMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrMrJT+2lKUpSlKUpSlKUpSlKUpSlKUpSlKUpSlKUpSn9tKUpSlKUpSlKUpSlKUpSlKUpSlKUpSlKUpT/wDrA//EAB0RAAMBAAMBAQEAAAAAAAAAAAABERIwQFAgkMD/2gAIAQIBAT8A/COlKioqKioqKi+zSoqKioqL59Ro0aKyvpVlZWaNFXiVGkaNFZWV9CsrNGjRpFXepo0V8c69Zo0u1pGilfVnJWaNF+NFXNUaNFfmU0aReamkaNPzNM19VlZWaKysrK/XrKzTNGjRWaKyv+u0/8QAHREBAQACAQUAAAAAAAAAAAAAEQBAUCAQITCQwP/aAAgBAwEBPwD1NkRER07eYiIiNMRERGARERGgIiNAREZRERoCIjiYBERqiIwiI1REcCIiIiIjbkREREREfXZ//9k=";y();var Ga=class o extends Error{name="AssertionError";constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,o)}};function Pu(o,e){if(o==null){let t;e?.customMessage?t=e.customMessage:t=`Expected ${e?.valueName?`'${e.valueName}'`:"value"} to be defined, but received ${o}`;let r=e?.errorClass||Ga,n=new r(t);throw e?.captureStackTrace!==!1&&Error.captureStackTrace&&Error.captureStackTrace(n,Pu),n}}function ka(o,e,t){if(Pu(o),o?.type!==e){let r=`Expected type ${e} but got ${o?.type}`;throw new Error(t??r)}}y();var si=class{backgroundAlpha=1;backgroundColor=new z;width=0;height=0;options={};renderer;frameStats={drawCalls:0,triangles:0,lines:0,points:0};constructor(e){try{if(this.options=e,Wt()){this.renderer={setSize:()=>{},state:{reset:()=>{}},properties:{get:()=>{}},getSize:()=>Ot(),getDrawingBufferSize:()=>Ot(),getClearAlpha:()=>1,getClearColor:()=>new z,autoUpdate:!0,shadowMap:{autoUpdate:!0},getContext:()=>({getContextAttributes(){return{alpha:!0,antialias:!1,depth:!0,stencil:!1}}}),readRenderTargetPixelsAsync:()=>Promise.resolve([]),setRenderTarget:()=>{},setClearColor:()=>{},clear:()=>{},render:()=>{},clearStencil:()=>{},clearDepth:()=>{},domElement:document.createElement("canvas"),capabilities:{isWebGL2:!0,maxTextureSize:16384}};let{width:t,height:r}=Ot();this.renderer.domElement.style.width=`${t}px`,this.renderer.domElement.style.height=`${r}px`,Object.defineProperty(this.renderer.domElement,"clientWidth",{configurable:!0,get:()=>Ot().width}),Object.defineProperty(this.renderer.domElement,"clientHeight",{configurable:!0,get:()=>Ot().height})}else this.renderer=new hd({canvas:e.canvas,alpha:e.alpha||!1,stencil:!0,antialias:typeof e.antialias=="boolean"?e.antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.renderer.localClippingEnabled=!0;this.backgroundColor=new z(e.backgroundColor??"#ffffff"),this.backgroundAlpha=e.backgroundAlpha??1}catch(t){R.error(t),e.onWebGLRendererError&&e.onWebGLRendererError(t)}this.domElement()?.addEventListener("webglcontextlost",this.handleWebGLContextLost),this.domElement()?.addEventListener("webglcontextrestored",this.handleWebGLContextRestored),this.domElement()?.addEventListener("webglcontextcreationerror",this.handleWebGLContextCreationError),this.domElement()&&(this.domElement().style.zIndex="1")}destroy(){this.renderer&&this.renderer.dispose?.(),this.domElement()?.removeEventListener("webglcontextlost",this.handleWebGLContextLost),this.domElement()?.removeEventListener("webglcontextrestored",this.handleWebGLContextRestored),this.domElement()?.removeEventListener("webglcontextcreationerror",this.handleWebGLContextCreationError)}enabledLayers=new Set([0,1]);matricesUpdatedThisFrame=!1;startFrame(){this.matricesUpdatedThisFrame=!1}updateMatricesIfNeeded(e){this.matricesUpdatedThisFrame||(e.updateMatrixWorld(),this.matricesUpdatedThisFrame=!0)}renderScene(e,t){this.renderer&&(this.updateMatricesIfNeeded(e),this.renderer.render(e,t))}renderFullScene(e,t){if(this.renderer){this.renderer.state.reset(),this.updateMatricesIfNeeded(e),this.renderer.clearStencil(),this.renderer.setRenderTarget(null),this.renderer.autoClear=!1,t.layers.disableAll();for(let c of this.enabledLayers.values())t.layers.enable(c);this.renderer.render(e,t);let r=this.renderer.info?.render,n=r?.calls??0,i=r?.triangles??0,s=r?.lines??0,a=r?.points??0;this.renderer.clearDepth(),t.layers.disableAll(),t.layers.enable(ye.ALWAYS_ON_TOP_PATHS),this.renderer.render(e,t);let l=this.renderer.info?.render;this.frameStats.drawCalls=n+(l?.calls??0),this.frameStats.triangles=i+(l?.triangles??0),this.frameStats.lines=s+(l?.lines??0),this.frameStats.points=a+(l?.points??0),this.renderer.clearStencil(),this.renderer.state.reset()}}clear(){this.renderer&&(this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha),this.renderer.clear())}setBufferSize(e,t){E.env.NODE_ENV==="test"||!this.renderer||(this.width=e,this.height=t,this.renderer.setSize(e,t,!1))}setBackgroundColor(e,t){this.backgroundColor=e,this.backgroundAlpha=t}domElement(){return this.renderer?.domElement}handleWebGLContextCreationError=e=>{this.options.onWebGLContextCreationError?.(e)};handleWebGLContextLost=e=>{e.preventDefault(),this.options.onWebGLContextLost?.(e)};handleWebGLContextRestored=e=>{this.options.onWebGLContextRestored?.(e)}};y();y();y();y();var ai=class{type;event;constructor(e){this.type=0,this.event=e}get timestamp(){return this.event.timeStamp}},li=class{taps=[];add(e){this.lastPointerDown&&e.timestamp-this.lastPointerDown.timestamp<50?this.lastPointerDown.type=1:this.taps.push(e)}get lastPointerDown(){return this.taps.length>=1?this.taps[this.taps.length-1]:void 0}get isSingleTapWithTwoFingers(){return this.isSingleTap&&this.lastPointerDown?.type===1}get isSingleTapWithOneFinger(){return this.isSingleTap&&this.lastPointerDown?.type===0}get isDoubleTapWithOneFinger(){return this.isDoubleTap&&this.taps[0]?.type===0&&this.taps[1]?.type===0}get isSingleTap(){return this.taps.length===1}get isDoubleTap(){return this.taps.length===2}discardOutsideOfWaitWindow(e){this.taps=this.taps.filter(t=>e-t.timestamp<300)}flush(){this.taps=[]}get _taps(){return this.taps}destroy(){this.flush()}};y();function za(o){let e=new Set;for(let t of o){let r=t.object;for(;r.visible&&r.parent&&r.parent.visible===!0&&!e.has(r.parent);)r=r.parent,r instanceof he&&r.type==="group-container"&&r.visible&&r.components[0]&&e.add(r)}return Array.from(e)}y();function Ua(o,e){if(o==null||e==null)return o===e;if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!==e[t])return!1;return!0}var kn=class extends q{raycaster=new $t;state={hovered3DEntity:void 0,hovered2DEntities:new Set,hovered3DContainers:void 0,lastHover:void 0,interaction:{mouseDownStart:void 0,distanceFromMouseDown:void 0,isPanning:!1}};coreState;camera;worldPlane;_quadtree=new yd(new qt(0,0,0,0));_container;lastPointerEvent;cursor="grab";touchesCount=0;isUserMovingCamera;constructor(e,t,r,n,i){super(),this.isUserMovingCamera=i,this.raycaster.layers.enableAll(),this.raycaster.layers.disable(1),this.camera=r,this._container=e,this.coreState=t,this.worldPlane=n,this._container.addEventListener("pointerdown",this.onPointerDown,{capture:!1,signal:this.signal}),this._container.addEventListener("pointermove",this.onPointerMove,{capture:!1,signal:this.signal}),this._container.classList.add("mappedin-interactive")}updateQuadtree(e){this._quadtree=e}setHovered3DEntityInteractionComponentDirty(){if(this.state.hovered3DEntity){let e=this.state.hovered3DEntity.components[2];e&&(e.dirty=!0)}}hasTouched=!1;onPointerMove=Do(e=>{e&&(e.preventDefault(),this.updateInteractionStateIfPanning(e),(e.pointerType!=="touch"||e.pointerType===void 0&&this.hasTouched)&&this.handleHover(e),this.handleCursor())},E.env.NODE_ENV==="test"?0:16,{leading:!0});tapsControl=new li;getThreeDIntersectsFromXY(e){this.raycaster.setFromCamera(e,this.camera),this.raycaster.layers.enable(ye.GEOMETRY);let t=this.raycaster.intersectObjects(this._hitBoxes.entities,!0).filter(n=>n.object?.name==="worldPlane"||n.object?.visible),r=t.findIndex(n=>n.object?.name==="worldPlane");return r!==-1&&t.push(t.splice(r,1)[0]),t}getGroupContainerIntersectsFromXY(e){let t=this.getThreeDIntersectsFromXY(e),r;return t!=null&&t.length>0&&(r=za(t)),r}onPointerDown=e=>{e.target===this._container&&(this._container.addEventListener("pointerup",this.onPointerUp,{capture:!1,signal:this.signal}),this._container.addEventListener("pointercancel",this.onPointerUp,{capture:!1,signal:this.signal}),this.state.interaction.mouseDownStart={time:Date.now(),timestamp:e.timeStamp,offsetX:e.offsetX,offsetY:e.offsetY},this.lastPointerEvent=e,this.state.interaction.distanceFromMouseDown=0,this.state.interaction.isPanning=!1,this.handleCursor(),e.pointerType==="touch"&&(this.tapsControl.add(new ai(e)),this.touchesCount=Math.max(0,this.touchesCount+1)),this.clearPressTimer(),!(this.touchesCount>1)&&(this.pressTriggered=!1,this.pressTimeout=window.setTimeout(()=>this.maybeFirePress(),500)))};clickTimeout=void 0;pressTimeout=void 0;pressTriggered=!1;clearPressTimer(){this.pressTimeout!=null&&(clearTimeout(this.pressTimeout),this.pressTimeout=void 0)}maybeFirePress(){this.pressTimeout=void 0;let e=this.lastPointerEvent;if(!e||!this.state.interaction.mouseDownStart||this.state.interaction.isPanning||(this.state.interaction.distanceFromMouseDown??0)>15||this.touchesCount>1)return;let t=this.intersect(e);this.pressTriggered=!0,this.publish("long-press",{entity2D:t.entity2D,entity3D:t.entity3D,position:t.position,groupContainers:t.groupContainers,pointerEvent:{button:e.button}})}onPointerUp=e=>{this.clearPressTimer();let t=this.pressTriggered;this.pressTriggered=!1,this.tapsControl.discardOutsideOfWaitWindow(e.timeStamp),this.lastPointerEvent=e,this.touchesCount=Math.max(0,this.touchesCount-1),this.touchesCount===0&&(this._container.removeEventListener("pointerup",this.onPointerUp,{capture:!1}),this._container.removeEventListener("pointercancel",this.onPointerUp,{capture:!1})),this.updateInteractionStateIfPanning(e);let{mouseDownStart:r,isPanning:n}=this.state.interaction;!r||this.state.interaction.distanceFromMouseDown==null||(Date.now()<r.time+300&&(this.tapsControl.isSingleTapWithTwoFingers||this.state.interaction.distanceFromMouseDown<=15)&&(e.pointerType==="touch"?this.tapsControl.isSingleTapWithTwoFingers?(this.isUserMovingCamera()||this.publish("singletap-with-twofinger",e),this.flush()):this.tapsControl.isSingleTapWithOneFinger&&this.touchesCount===0?(this.clickTimeout&&clearTimeout(this.clickTimeout),this.clickTimeout=window.setTimeout(()=>{this.handleClick(e),this.flush()},300)):this.tapsControl.isDoubleTapWithOneFinger&&(this.publish("doubletap-with-onefinger",e),this.flush()):!t&&!n&&this.handleClick(e)),this.state.interaction.mouseDownStart=void 0,this.state.interaction.distanceFromMouseDown=void 0,this.state.interaction.isPanning=!1,this.handleCursor())};flush(){this.tapsControl.flush(),this.clickTimeout!=null&&(clearTimeout(this.clickTimeout),this.clickTimeout=void 0),this.clearPressTimer()}handleHover(e){let t=e||this.lastPointerEvent;if(t?.pointerType==="touch"||this.state.interaction.mouseDownStart||!t||this.isUserMovingCamera())return;let{entity3D:r,entity2D:n,position:i,groupContainers:s}=this.intersect(t);(this.detect3DEntityHover(r)||this.detect2DEntityHover(n)||this.detect3DContainerHover(s))&&(this.state.hovered3DEntity=r,this.state.lastHover=r,this.state.hovered2DEntities=new Set(n.map(a=>a.id)),this.state.hovered3DContainers=s,this.publish("hover",{entity2D:n,entity3D:this.state.hovered3DEntity,position:i,groupContainers:s})),this.handleCursor()}handleCursor(){let e=!!(this.state.hovered3DEntity&&this.state.hovered3DEntity?.components[2]||this.state.hovered2DEntities.size>0),t=!!this.state.interaction.mouseDownStart,r=this.state.interaction.isPanning,n=Mf(e,r,t);this.cursor!==n&&(this.cursor=n,n==="pointer"?this._container.classList.add("mappedin-interaction-hover"):this._container.classList.remove("mappedin-interaction-hover"))}detect2DEntityHover(e){if(e.length!==this.state.hovered2DEntities.size)return!0;for(let t=0;t<e.length;t++)if(!this.state.hovered2DEntities.has(e[t].id))return!0;return!1}handleClick(e){let t=this.intersect(e);this.publish("click",{entity2D:t.entity2D,entity3D:t.entity3D,position:t.position,groupContainers:t.groupContainers,pointerEvent:{button:e.button}})}dirty3D=!0;cachedHitBoxes={entities:[]};get _hitBoxes(){if(this.dirty3D){this.cachedHitBoxes.entities=[];let e;for(let t of this.coreState.geometry3DIdsInScene)if(e=this.coreState.geometry3DMap.get(t),e?.type==="geometry"||e?.type==="model"||e?.type==="path"||e?.type==="custom-geometry"||e?.type==="image"){let r=e.components[0];if(r instanceof ue&&r.pointerEventsPassThrough)continue;r.mesh&&!this.cachedHitBoxes.entities.includes(r.mesh)&&this.cachedHitBoxes.entities.push(r.mesh)}return this.dirty3D=!1,this.cachedHitBoxes.entities.push(this.worldPlane),this.cachedHitBoxes}return this.cachedHitBoxes}ndcPoint=new V;intersect(e){let{offsetX:t,offsetY:r}=e,n=[t,r],s=this._quadtree.queryPoint(n).filter(g=>g.intersectsPoint(n));this.ndcPoint.x=t/this._container.clientWidth*2-1,this.ndcPoint.y=-(r/this._container.clientHeight)*2+1;let a=this.getThreeDIntersectsFromXY(this.ndcPoint),l=[],c=[],d=[],u;for(let g of a){if(g.object.name==="worldPlane"){u??=g;continue}if(g.object.name==="hole-fill-mesh"||!(g.object instanceof X)||g.object.material?.colorWrite===!1)continue;let b=g?.instanceId??g?.batchId,x=b!=null&&g?.object.userData.entities?g.object.userData.entities[b]:g.object.userData?.entityId,S=x?this.coreState.geometry3DMap.get(x):void 0;if(S instanceof Q){let D=S.components[0];if(D instanceof ue&&D.pointerEventsPassThrough)continue}let C=g.object.userData?.entityId;if(C){let w=this.coreState.geometry3DMap.get(C)?.components[7];if(w?.verticalOffset!=null&&g.point.z>w.verticalOffset)continue}d.push(g),g.object.material.depthTest===!1?l.push(g):c.push(g)}let h=l[0]??c[0]??void 0,v=h?.point??u?.point,f,M;if(h!=null){let g=h?.instanceId??h?.batchId;f=g!=null&&h?.object.userData.entities?this.coreState.geometry3DMap.get(h?.object.userData.entities[g]):this.coreState.geometry3DMap.get(h?.object.userData.entityId),f?.components[2]&&(M=f)}let p=za(d),m=[];for(let g of s)if(g?.userData?.entityId==="watermark")m.push({id:"watermark"});else{let b=this.coreState.geometry2DMap.get(g?.userData.entityId);b&&m.push(b)}return Cf(m),{entity2D:m,entity3D:M,position:v,groupContainers:p.length>0?p:void 0}}detect3DEntityHover(e){return this.state.lastHover!==e&&(this.state.lastHover&&Ou(this.state.lastHover,!1,this.coreState),e&&Ou(e,!0,this.coreState)),this.state.hovered3DEntity!==e}detect3DContainerHover(e){return!Ua(this.state.hovered3DContainers,e)}updateInteractionStateIfPanning(e){this.state.interaction.mouseDownStart&&(this.state.interaction.distanceFromMouseDown=Math.sqrt(Math.pow(e.offsetX-this.state.interaction.mouseDownStart.offsetX,2)+Math.pow(e.offsetY-this.state.interaction.mouseDownStart.offsetY,2)),!this.state.interaction.isPanning&&this.state.interaction.distanceFromMouseDown>15&&(this.state.interaction.isPanning=!0,this.clearPressTimer()))}getMouseRayIntersects(){return this.raycaster.intersectObjects([this.worldPlane],!1)}destroy(){this.clearPressTimer(),this._container.removeEventListener("pointerdown",this.onPointerDown,{capture:!1}),this._container.removeEventListener("pointermove",this.onPointerMove,{capture:!1}),this._container.removeEventListener("pointerup",this.onPointerUp,{capture:!1}),this._container.removeEventListener("pointercancel",this.onPointerUp,{capture:!1}),super.destroy()}debugPanel;enableDebug(){let e=document.createElement("div");e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.backgroundColor="white",e.style.padding="10px",document.body.append(e),e.id="interaction-debug-panel",this.debugPanel=e,this.on("doubletap-with-onefinger",()=>{this.queueDebugMessage("doubletap-with-onefinger","#ffadad")}),this.on("singletap-with-twofinger",()=>{this.queueDebugMessage("singletap-with-twofinger","#ffd6a5")}),this.on("click",t=>{this.queueDebugMessage(`CLICK
2
- 3D: ${t.entity3D?.id}
3
- 2D: ${t.entity2D?.map(r=>r.id).join(", ")}
4
- Pos: ${t.position?.toArray().join(", ")}`,"#fdffb6")}),this.on("hover",t=>{this.queueDebugMessage(`HOVER
5
- 3D: ${t.entity3D?.id}
6
- 2D: ${t.entity2D?.map(r=>r.id).join(", ")}
7
- Pos: ${t.position?.toArray().join(", ")}`,"#caffbf")})}get _state(){return this.state}queueDebugMessage(e,t){let r=document.createElement("pre");r.style.maxWidth="300px",r.style.transition="opacity 500ms cubic-bezier(0.4, 0, 0.2, 1)",r.style.backgroundColor=t,r.textContent=e,this.debugPanel?.prepend(r),setTimeout(()=>{r.style.opacity="0",setTimeout(()=>{r.remove()},500)},2500)}getCursor(){return this.cursor}};function Ou(o,e,t){let r=o.components[2];r&&r.hover!==!0&&(r.hover=e?"user-interaction":!1,r.dirty=!0);let n=o.components[0].textMesh?.userData.entityId;if(!n)return;let i=t.geometry3DMap.get(n);i?.type==="text3d"&&(i.components[1].hoverByPolygon=e,i.components[1].dirty=!0)}function Mf(o,e,t){return e?"grabbing":o?"pointer":t?"grabbing":"grab"}function Cf(o){if(o.length<=1)return;let e=[],t=[],r=[];for(let i=0;i<o.length;i++){let s=o[i];s.components?s.type==="marker"?e.push(s):t.push(s):r.push(s)}if(e.length>1){let i,s;e.sort((a,l)=>{i=a.components[0],s=l.components[0];let c=i.projection.y,d=s.projection.y;return c!==d?d-c:i.markerContainer.compareDocumentPosition(s.markerContainer)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1})}if(t.length>1){let i=[];for(let s=0;s<t.length;s++){let a=t[s],l=a.components[0];i.push({entity:a,y:l.projection.y,idx:s})}i.sort((s,a)=>s.y!==a.y?a.y-s.y:a.idx-s.idx);for(let s=0;s<i.length;s++)t[s]=i[s].entity}let n=0;for(let i=0;i<e.length;i++)o[n++]=e[i];for(let i=0;i<t.length;i++)o[n++]=t[i];for(let i=0;i<r.length;i++)o[n++]=r[i]}y();y();y();var Lu=new K;function Nn(o,e=!0){let t=new jt,r=o.mesh?.geometry;if(!r||!o.batchedProps?.range)return;let n=o.batchedProps.range,i=n.start,s=n.count,a=r.getAttribute("position");if(a){let d=new Float32Array(s*3);for(let u=0;u<s;u++){let h=i+u;d[u*3]=a.array[h*3],d[u*3+1]=a.array[h*3+1],d[u*3+2]=a.array[h*3+2]}t.setAttribute("position",new De(d,3))}let l=r.getAttribute("normal");if(l){let d=new Float32Array(s*3);for(let u=0;u<s;u++){let h=i+u;d[u*3]=l.array[h*3],d[u*3+1]=l.array[h*3+1],d[u*3+2]=l.array[h*3+2]}t.setAttribute("normal",new De(d,3))}let c=r.getAttribute("uv");if(c){let d=new Float32Array(s*2);for(let u=0;u<s;u++){let h=i+u;d[u*2]=c.array[h*2],d[u*2+1]=c.array[h*2+1]}t.setAttribute("uv",new De(d,2))}if(r.index){let d=r.index,u=new Uint32Array(s);for(let h=0;h<s;h++)u[h]=d.array[i+h];t.setIndex(new De(u,1))}if(e&&o.instanceIndex!==-1&&Ba(o.mesh))try{o.mesh.getMatrixAt(o.instanceIndex,Lu),t.applyMatrix4(Lu)}catch(d){R.error(d)}return t}function Au(o,e,t){let r=Nn(o,!1);if(!r||!Ba(o.mesh))return;o.mesh.getMatrixAt(o.instanceIndex,t),o.mesh.deleteInstance(o.instanceIndex),o.mesh.optimize();let n=e.addGeometry(r);e.addInstance(n),e.setMatrixAt(n,t);let i=e.getGeometryIdAt(n),s=e.getGeometryRangeAt(i);return s&&o.batchedProps&&(o.batchedProps.range=s),r.dispose(),n}function Ru(o,e){if(e===0)return;let t=o.getAttribute("position");for(let r=0;r<t.count;r++)t.setZ(r,t.getZ(r)+e);t.needsUpdate=!0}var zn=class{#e=null;#n;constructor(e){this.#n=e}getCurrentSceneGLTF=async e=>{let t={onlyVisible:!0,binary:!0,light:!0,scale:1,...e},r=await this.#o(),n=this.#i(t),i=await r.parseAsync(n,{trs:!1,maxTextureSize:1/0,onlyVisible:t.onlyVisible,binary:t.binary,scale:t.scale}),s;if(i instanceof ArrayBuffer)s=new Blob([i],{type:"application/octet-stream"});else{let a=JSON.stringify(i,null,2);s=new Blob([a],{type:"text/plain"})}return s};#i=e=>{let{scale:t,light:r,onlyVisible:n}=e,i=new Rt,s=new de().setFromObject(this.#n.geometryScene);if(this.#s(this.#n.geometryScene,i,n),r){let a=new Ho(16777215,.3*Math.PI);a.position.set(0,Math.max(s.max.x,s.max.y)*t*.5,s.max.y*t*4),a.lookAt(0,0,-1),a.target.position.set(0,0,-1),a.add(a.target),i.add(a)}return i};async#o(){if(!this.#e){let{GLTFExporter:e}=await import("./GLTFExporter-6CFIB35E.js");this.#e=new e}return this.#e}#s=(e,t,r)=>{e.material&&e instanceof No&&this.#l(e).forEach(n=>t.add(n)),e.children.forEach(n=>{(!r||n.visible)&&this.#s(n,t,r)})};#a=(e,t,r)=>{let n=new On({color:new z(e),metalness:0});return n.opacity=t,n.transparent=r,n};#l(e){let t=[],n=(e.userData?.entities?Object.values(e.userData?.entities):[]).map(a=>this.#n.geometry3DMap.get(a)),i=new Map;e.updateWorldMatrix(!0,!1);let s=new O;return e.getWorldPosition(s),n.forEach(a=>{if(!a||!(a instanceof Q))return;let l=a.components[1],c=a.components[2];if(!l.visible||l instanceof Dt&&l.opacity===0||l instanceof _n||l instanceof Ko)return;let u=`${c?.hover?l.hoverColor||this.#n.hoverColor:l.color}-${l.opacity}-${Number(l.visible)}`;i.has(u)||i.set(u,[]),i.get(u)?.push(a)}),i.forEach((a,l)=>{let[c,d,u]=l.split("-"),h=a.reduce((p,m)=>{if(m.type==="custom-geometry")return p;let g=m.components[0];if("geometry"in g&&g.geometry instanceof jt){let b=g.geometry.clone();Ru(b,s.z),p.push(b)}else if(g instanceof ue&&g.batchedProps){let b=Nn(g);b&&(Ru(b,s.z),p.push(b))}return p},[]);if(h.length===0){R.error("No geometries found for batched mesh");return}let v=this.#a(c,Number(d),e.material.transparent),f=Ke(h,!0);if(!f){R.error("No merged geometry found for batched mesh");return}let M=new X(f,v);M.position.copy(e.position),M.rotation.copy(e.rotation),M.scale.copy(e.scale),M.visible=!!u,this.#u(M.position,M.scale,M.rotation,M.quaternion),t.push(this.#d(M))}),t}#d=e=>{let{geometry:t,material:r,position:n,rotation:i,quaternion:s,scale:a}=e;if(!t?.isBufferGeometry)return e;let l=t.attributes.position,c=t.attributes.normal,d=t.attributes.uv;return this.#f(l,c),this.#u(n,a,i,s),d&&this.#r(d),r?.map&&t.type==="PlaneGeometry"&&(e.side=Vt),e};#f=(e,t)=>{let r=new O,n=new O;for(let i=0;i<e.count;i++)r.fromBufferAttribute(e,i),this.#t(r),e.setXYZ(i,r.x,r.y,r.z),t&&(n.fromBufferAttribute(t,i),this.#t(n),t.setXYZ(i,n.x,n.y,n.z))};#t=e=>{let t=e.y;e.y=e.z,e.z=-t};#u=(e,t,r,n)=>{let i=e.y;e.y=e.z,e.z=-i;let s=t.y;if(t.y=t.z,t.z=s,r instanceof Lt)r.order="YXZ",r.set(r.x,r.y,r.z,r.order);else{let a=n.y;n.set(n.x,n.z,-a,n.w)}};#r=e=>{for(let t=0;t<e.count;t++){let r=e.getX(t),n=e.getY(t);e.setXY(t,r,n)}};destroy(){this.#e=null}};y();y();var wf="gray",Ef=.1,Un=100,Va=new Et.ClipperOffset;function Hn(o){let e=o.length;if(e<2)return e;let t=o[0],r=o[e-1];return t.x===r.x&&t.y===r.y?e-1:e}function ja(o,e){if(e<3)return 0;let t=0,r=0,n=0,i=0;for(let a=1;a<e;a++)o[a].x<o[t].x&&(t=a),o[a].y<o[r].y&&(r=a),o[a].x>o[n].x&&(n=a),o[a].y>o[i].y&&(i=a);let s=a=>a===t||a===r||a===n||a===i;for(let a=0;a<e;a++){let l=(a+e-1)%e;if(!s(a)&&!s(l))return a}for(let a=0;a<e;a++)if(!s(a))return a;return(t-(e>>1)+e)%e}function Df(o,e){Va.Clear(),e/=2;let t=o.map(n=>({X:n.x*Un,Y:n.y*Un}));Va.AddPath(t,Et.JoinType.jtMiter,Et.EndType.etClosedPolygon);let r=new Et.Paths;return Va.Execute(r,e*Un),r.length?r.map(i=>i.map(s=>({x:s.X/Un,y:s.Y/Un}))):[o]}function di(o,e,t){let{color:r=wf,opacity:n=1,altitude:i=0,height:s=Ef}=t||{};Array.isArray(n)&&(n=1);let a={min:{x:1/0,y:1/0,z:i},max:{x:-1/0,y:-1/0,z:s+i},center:{x:0,y:0,z:(s+i)/2}},c=o.geometry.coordinates[0].map(v=>{let f=e(v[1],v[0]);return a.min.x=Math.min(a.min.x,f.x),a.min.y=Math.min(a.min.y,f.y),a.max.x=Math.max(a.max.x,f.x),a.max.y=Math.max(a.max.y,f.y),f});o.properties?.style?.edgeOffset!=null&&o.properties.style.edgeOffset!==0||o.properties?.image!=null?c=Df(c,o.properties?.style?.edgeOffset||0):c=[c];let d=[];for(let v of c){let f=new Hr,M=Hn(v),p=ja(v,M);f.moveTo(v[p].x,v[p].y);for(let x=1;x<M;x++){let S=(p+x)%M;f.lineTo(v[S].x,v[S].y)}let m=o.geometry.coordinates.slice(1);f.holes=m.map(x=>{let S=x.map(w=>e(w[1],w[0])),C=new Ur,D=Hn(S);C.moveTo(S[0].x,S[0].y);for(let w=1;w<D;w++)C.lineTo(S[w].x,S[w].y);return C});let g=Rn(t?.bevel,s),b=new Wr(f,g);b.userData={style:{color:r,opacity:n},usedBevelSettings:g},d.push(b)}if(d.length===1)return d[0];let u=Ke(d);d.forEach(v=>v.dispose());let h=Rn(t?.bevel,s);return u.userData={style:{color:r,opacity:n},usedBevelSettings:h,_split:!0},u}y();var Tf="gray",Pf=.1;function ui(o,e,t){let{color:r=Tf,opacity:n=1,altitude:i=0,height:s=Pf}=t||{};Array.isArray(n)&&(n=1);let a={min:{x:1/0,y:1/0,z:i},max:{x:-1/0,y:-1/0,z:s+i}},l=Rn(t?.bevel,s),c=[];o.geometry.coordinates.forEach(u=>{let h=new Hr,v=u[0].map(g=>{let b=e(g[1],g[0]);return a.min.x=Math.min(a.min.x,b.x),a.min.y=Math.min(a.min.y,b.y),a.max.x=Math.max(a.max.x,b.x),a.max.y=Math.max(a.max.y,b.y),b}),f=Hn(v),M=ja(v,f);h.moveTo(v[M].x,v[M].y);for(let g=1;g<f;g++){let b=(M+g)%f;h.lineTo(v[b].x,v[b].y)}let p=u.slice(1);h.holes=p.map(g=>{let b=g.map(C=>e(C[1],C[0])),x=new Ur,S=Hn(b);x.moveTo(b[0].x,b[0].y);for(let C=1;C<S;C++)x.lineTo(b[C].x,b[C].y);return x});let m=new Wr(h,l);c.push(m)});let d=Ke(c);return c.forEach(u=>u.dispose()),d.userData={style:{color:r,opacity:n},usedBevelSettings:l},d}y();var Ze=100,If=.22,Of=.01;function Fu(o,e,t={}){let{width:r=If,height:n=Of,color:i="gray",opacity:s=1,altitude:a=0}=t,l={min:{x:1/0,y:1/0,z:a},max:{x:-1/0,y:-1/0,z:a+n}},c={bevelEnabled:!1,depth:n},d=new Et.ClipperOffset,u=o.geometry.coordinates.map(M=>M.map(p=>e(p[1],p[0])));d.AddPaths(u.map(M=>M.map(p=>({X:p.x*Ze,Y:p.y*Ze}))),Et.JoinType.jsMiter,Et.EndType.etOpenRound);let h=new Et.PolyTree;d.Execute(h,r/2*Ze);let v=[];for(let M of h.m_AllPolys){let p=new Hr;if(M.IsHole())continue;l.min.x=Math.min(l.min.x,M.m_polygon[0].X),l.min.y=Math.min(l.min.y,M.m_polygon[0].Y),l.max.x=Math.max(l.max.x,M.m_polygon[0].X),l.max.y=Math.max(l.max.y,M.m_polygon[0].Y);let m=M.m_polygon;p.moveTo(m[0].X/Ze,m[0].Y/Ze),m.slice(1).forEach(g=>p.lineTo(g.X/Ze,g.Y/Ze)),p.lineTo(m[0].X/Ze,m[0].Y/Ze),p.holes=M.m_Childs.map(g=>{let b=new Ur,x=g.m_polygon;return b.moveTo(x[0].X/Ze,x[0].Y/Ze),x.slice(1).forEach(S=>b.lineTo(S.X/Ze,S.Y/Ze)),b.lineTo(x[0].X/Ze,x[0].Y/Ze),b}),v.push(new Wr(p,c))}let f=Ke(v);return f.translate(0,0,a||0),f.userData={style:{color:i,opacity:s}},d.Clear(),f}function Lf(o){let e=o[1],t=o[6],{opacity:r}=e??{},{texture:n,topTexture:i}=t??{};return`${r}${n?.path||""}${i?.path||""}`}var hi=class extends q{state;convertTo3DMapPosition;constructor(e,t){super(),this.state=e,this.convertTo3DMapPosition=t}createEntityFromFeature(e,t,r){let n=new ue(t),i=Array.isArray(t)?t[0]?.properties:t.properties,s=i?.bevel,a=r&&"bevel"in r?r.bevel:void 0,l;a?l={...s,...a}:s&&(l=s);let c=new Q(n,new Dt({...r,url:i?.image?.path,bevel:l}));if(r?.outline){let d=this.state.outlinesOptions?.darkenFactor;c.components[3]=new Ud(jd(r.color,d))}return r?.focusable&&(c.components[4]=new Jd),i?.textures!=null&&Array.isArray(i.textures)&&i.textures.length>0?c.components[6]=new Mr(i.textures.find(d=>d.face==="side"),i.textures.find(d=>d.face==="top")):(r!=null&&"texture"in r&&r.texture!=null||r!=null&&"topTexture"in r&&r.topTexture!=null)&&(c.components[6]=new Mr(r.texture,r.topTexture)),c.id=Array.isArray(t)?e+"-merged":e,c}populateEntityMesh(e,t,r=!1){let n=e.components[0];if(n.geometry=t,t.userData.defaultUVs instanceof Float32Array&&(n.defaultUVs=t.userData.defaultUVs),e.components[1].slopeEnabled){let s=new kd;s.baselineVertices=new Float32Array(t.attributes.position.array),e.components[8]=s}r||(n.batchedProps={range:{start:0,count:1/0,indexCount:1/0,indexStart:0,vertexCount:1/0,vertexStart:0,reservedVertexCount:1/0,reservedIndexCount:1/0},geometryId:-1,positionCount:t.attributes.position.count}),n.currentHeight=e.components[1].height,e.components[1].initialHeight=e.components[1].height,n.dirty=!1}populateEntityGroup(e){let t,r,n;for(let i of e.values())if(n=this.state.geometry3DMap.get(i),n.components[0]instanceof ue){t=n.components[0].feature,r=n.components[1];try{if(Array.isArray(t)){let s=[];for(let l of t){let c=this.#e(l,r);c!=null&&s.push(c)}let a=Ke(s);this.populateEntityMesh(n,a,!0),s.forEach(l=>l.dispose())}else{let s=this.#e(t,r);s!=null&&this.populateEntityMesh(n,s)}}catch(s){R.warn(`Failed to create mesh for entity ${i}:`,s)}}return e}#e(e,t){let r;return e.geometry.type==="Polygon"?(r=di(e,this.convertTo3DMapPosition,t),e.properties?.textures&&e.properties.textures.length>0&&(r.userData.defaultUVs=new Float32Array(r.getAttribute("uv").array),Zd(r,e.properties.textures,this.state.naturalBearing,this.convertTo3DMapPosition))):e.geometry.type==="MultiPolygon"?r=ui(e,this.convertTo3DMapPosition,t):e.geometry.type==="LineString"?r=wu(e,this.convertTo3DMapPosition,t):e.geometry.type==="MultiLineString"&&(r=Fu(e,this.convertTo3DMapPosition,t)),r}update(){for(let e of this.state.geometryGroupIdsToLoad.values()){let t=this.state.geometry3DMap.get(e);if(t instanceof Fe&&t.userData.dirty&&!t.userData.modelURL){try{this.populateEntityGroup(t.userData.entities3D)}catch(i){R.warn(i)}let r,n={};if(t.userData.isMerged){let i=t.userData.entities3D.values().next().value;if(i&&(r=this.state.geometry3DMap.get(i),r?.type==="geometry")){let s=r.getComponent("geometry"),a=r.getComponent("style");if(s&&a){let l=new md({color:a.color}),c=new $r(s?.geometry,l);l.setColor(new z(a.color),new z(a.topColor??a.color)),c.renderOrder=ye.GEOMETRY,c.frustumCulled=!0,c.userData.entityId=r.id,c.layers.enable(Ve.SHOULD_CAST_SHADOWS),s.mesh=c,s.material=l,t.add(c)}}}else{for(let i of t.userData.entities3D.values()){r=this.state.geometry3DMap.get(i);let s=r?.components[0];if(r?.type==="geometry"){let a=Lf(r.components);n[a]===void 0&&(n[a]={style:r.components[1],entities:[]}),n[a].entities.push(r)}else s&&"mesh"in s&&s.mesh&&s.mesh?.parent!==t&&t.add(s.mesh)}for(let i in n){let s=Vd(n[i].entities,n[i].style);s.layers.enable(Ve.SHOULD_CAST_SHADOWS),t.add(s)}}for(let i of t.userData.entities3D.values())if(r=this.state.geometry3DMap.get(i),r!=null&&r.entities2D.size>0)for(let s of r.entities2D.values())s&&(r.attach(s),this.publish("geometry-2d-added"));this.publish("geometry-group-added"),t.userData.dirty=!1,t.userData.localCenter=void 0}}return Promise.resolve()}};y();var pi=new de,_u=new O;function Af(o,e){let t=o.components[2],r=o.components[1];return t?.hover?[r.hoverColor||e,r.hoverColor||e]:[r.color,r.topColor||r.color]}var mi=class{state;transparencyChanged=!1;convertTo3DMapPosition;convert3DMapPositionToCoordinate;constructor(e,t,r){this.convertTo3DMapPosition=t,this.convert3DMapPositionToCoordinate=r,this.state=e}determineTextureVisiblity(e,t,r){let n=Bn(e);(n?.texture!=null||n?.topTexture!=null)&&(r?.hover&&n.texturesVisible?n.hideTextures(e.instanceIndex):n.texturesVisible||n.showTextures(e.instanceIndex),t.texture==null&&n.removeSideTexture(e.instanceIndex),t.topTexture==null&&n.removeTopTexture(e.instanceIndex))}update(){let e,t;for(let r of this.state.geometry3DsInScene)if((r.type==="geometry"||r.type==="custom-geometry")&&(r.components[1]?.dirty||r.components[2]?.dirty)){let n=r.components[0],i=r.components[1];t=r.components[2];let s=Af(r,this.state.hoverColor);n.setColor(s[0],s[1]);let a=Bn(n);if(i.visible!==n.visible&&(n.visible=i.visible,n instanceof ue&&n.textMesh)){let c=this.state.geometry3DMap.get(n.textMesh.userData.entityId);c?.type==="text3d"&&c.components[0].polygonEntityId!=null&&(c.components[0].visible=i.visible)}i.altitude!==n.altitude&&(n.altitude=i.altitude);let l=i.opacity*Yr(r);if(a&&n.mesh&&n.type==="geometry"&&l!==n.opacity){if(a.opacity=l,a.transparent=l<1,n.imageMesh){let c=Array.isArray(n.imageMesh.material)?n.imageMesh.material:[n.imageMesh.material];for(let d of c)d.opacity=l}l===0?(n.mesh.layers.disable(Ve.SHOULD_CAST_SHADOWS),this.transparencyChanged=!0):n.opacity===0&&l!==0&&(n.mesh.layers.enable(Ve.SHOULD_CAST_SHADOWS),this.transparencyChanged=!0),n.opacity=l}if(i.renderOrder!==n.renderOrder&&(n.renderOrder=i.renderOrder),a&&Wd(a,i.side,l),a&&(a.setEffectRange(i.effectStart,i.effectDistance),a.setVisualEffect(i.darkenAmount,i.darkenUseDepth,i.desaturateAmount,i.desaturateUseDepth,i.washOutAmount,i.washOutUseDepth)),n instanceof ue&&i.shading!=null&&(i.shading?.start!==a?.getGradientShading().start||i.shading?.end!==a?.getGradientShading().end||i.shading?.intensity!==a?.getGradientShading().intensity)&&a?.setGradientShading(i.shading?.start??0,i.shading?.end??0,i.shading?.intensity??0),i.dirty=!1,n instanceof ue){let c=r.components[6];c instanceof Mr&&this.determineTextureVisiblity(n,c,t)}r.components[2]&&(r.components[2].dirty=!1)}else if(r?.type==="image"&&r.components[1]?.dirty){e=r.components[0];let n=r.components[1];n.visible!==e.visible&&(e.visible=n.visible),n.dirty=!1}else if(r?.type==="text3d"&&r.components[1]?.dirty){e=r.components[0];let n=r.components[1],i=e.polygonEntityId!=null;n.visible!=null&&n.visible!==e.visible&&(e.visible=n.visible);let{textMesh:s}=e;if(s)if(Object.assign(s,n.getState()),i){let a=n.hoverColor??this.state.text3dHoverColor;s.color=n.hoverByPolygon?a:n.color??_t.color,s.outlineColor=n.hoverByPolygon?a:n.outlineColor??_t.outlineColor,s.strokeColor=n.hoverByPolygon?a:n.strokeColor??_t.strokeColor}else s.color=n.color??_t.color,s.outlineColor=n.outlineColor??_t.outlineColor,s.strokeColor=n.strokeColor??_t.strokeColor;n.dirty=!1}else if(r?.type==="feature-collection"&&r?.userData.dirty===!1&&r?.userData.positionDirty){let n=r;if(n.userData.localCenter||(pi.makeEmpty(),pi.setFromObject(n),jr(pi)&&(pi.getCenter(_u),n.userData.localCenter=_u.clone())),!n.userData.centroid&&n.userData.localCenter){let i=this.convert3DMapPositionToCoordinate(n.userData.localCenter);n.userData.centroid=[i[0],i[1]]}if(n.userData.centroid&&n.userData.localCenter){let i=this.convertTo3DMapPosition(n.userData.centroid);n.position.x+=i.x-n.userData.localCenter.x,n.position.y+=i.y-n.userData.localCenter.y,n.userData.localCenter.set(i.x,i.y,n.userData.localCenter.z),n.userData.positionDirty=!1}}}endFrame=()=>{this.transparencyChanged=!1}};y();var fi=class extends q{state;renderer;mode;scene;cameraObject;viewCamera;systems;constructor(e,t,r,n,i,s,a){super(),this.renderer=e,this.state=t,this.mode=r,this.scene=n,this.cameraObject=i,this.viewCamera=s,this.systems=a,this.systems.cameraSystem.on("pan-start",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!1,{signal:this.signal}),this.systems.cameraSystem.on("zoom-start",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!1,{signal:this.signal}),this.systems.cameraSystem.on("zoom-end",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!0,{signal:this.signal}),this.systems.cameraSystem.on("rotate-start",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!1,{signal:this.signal}),this.systems.cameraSystem.on("rotate-end",()=>this.systems.twoDEntitySystem.collidersNeedRecomputing=!0,{signal:this.signal})}twoDdirty=!0;threeDdirty=!0;frameId=null;update=(e=!1)=>{if(this.renderer?.renderer==null)return Promise.resolve();if(e){this.renderer.startFrame();let t=this.commitRenderState();return this.paint(),t}else return this.frameId?Promise.resolve():new Promise((t,r)=>{this.frameId=requestAnimationFrame(()=>this.renderer?.renderer==null?t():this.mode==="standalone"?(this.renderer.startFrame(),this.commitRenderState()?.then(()=>{this.paint(),t()}).catch(n=>{r(n)})):t())})};paint(){if(!this.renderer?.renderer)return;this.mode==="standalone"&&this.renderer.clear();let e=!this.state.useStandaloneCamera&&this.mode!=="standalone";e&&(this.viewCamera.matrixWorld.copy(this.cameraObject.matrixWorld),this.viewCamera.matrixWorldInverse.copy(this.cameraObject.matrixWorldInverse),this.viewCamera.projectionMatrix.multiply(this.cameraObject.matrixWorld)),this.renderer.renderFullScene(this.scene,e?this.viewCamera:this.cameraObject),this.state.renderStats=this.renderer.frameStats,e&&(this.viewCamera.projectionMatrix.multiply(this.cameraObject.matrixWorldInverse),this.viewCamera.matrixWorldInverse.identity())}commitRenderState=()=>{try{let e=[];this.frameId=null,this.publish("pre-render"),this.state.internalTweenGroup.update(),this.state.externalTweenGroup.update(),(this.mode==="outdoors-interleaved"||this.mode==="standalone")&&this.systems.cameraSystem.update(),this.state.shouldMeasureCanvas&&(this.state.shouldMeasureCanvas=!1,this.publish("measure-canvas")),this.twoDdirty&&(this.state.geometry2DIdsInScene.clear(),this.state.geometry2DsInScene.clear(),Ad(this.state.geometryScene,this.state.geometry2DMap,this.state.geometry2DIdsInScene,this.state.geometry2DsInScene),this.systems.twoDEntitySystem.syncTwoDEntities(),this.systems.twoDEntitySystem.markDirty(),this.twoDdirty=!1),this.threeDdirty&&(this.state.geometry3DIdsInScene.clear(),this.state.geometry3DsInScene.clear(),this.state.geometryGroupIdsToLoad.clear(),Ld(this.state.geometryScene,this.state.geometry3DMap,this.state.geometry3DIdsInScene,this.state.geometry3DsInScene,this.state.geometryGroupIdsToLoad),this.systems.interactionSystem.dirty3D=!0,this.systems.outlineInterpolationSystem.geometries3DDirty=!0,this.systems.geometryInFocusSystem.focusablesDirty=!0,this.systems.shadowsSystem&&this.systems.shadowsSystem.castersChanged(),this.threeDdirty=!1);let t=this.systems.batchedMeshSystem.update();t&&e.push(t);let r=this.systems.modelSystem.update();return r&&e.push(r),this.systems.borderSystem.update(),this.systems.meshDetachmentSystem.update(),this.systems.meshModificationSystem.update(),this.systems.renderOrderSystem.update(),this.systems.clippingPlaneSystem.update(),this.systems.imageSystem.update(this.systems.cameraSystem.getRotation(),this.systems.cameraSystem.isCameraMoving(),this.systems.cameraSystem.lastCameraStoppedMovingTime()),e.push(this.systems.text3DSystem.update(this.systems.cameraSystem.getRotation())),this.systems.customGeometrySystem.update(),this.systems.panBoundsSystem.update(),this.systems.geometryInFocusSystem.update(this.systems.cameraSystem.isCameraMoving(),this.systems.cameraSystem.lastCameraStoppedMovingTime()),this.systems.outlineInterpolationSystem.update(this.systems.cameraSystem.getZoomLevel(),this.systems.cameraSystem.zoomDirty),this.systems.pathSystem.update(this.systems.cameraSystem.minZoomAltitude,this.systems.cameraSystem.maxZoomAltitude,this.systems.cameraSystem.getZoomAltitude(),this.systems.cameraSystem.getCurrentMetersPerPixel()),this.systems.cameraSystem.postRender(),this.systems.occlusion2DSystem.update(),this.systems.watermarkSystem.insertIntoQuadTree(this.systems.twoDEntitySystem.interactiveCollidersQTree),this.systems.interactionSystem.updateQuadtree(this.systems.twoDEntitySystem.interactiveCollidersQTree),this.systems.twoDEntitySystem.updateWatermark({width:this.systems.watermarkSystem.width,height:this.systems.watermarkSystem.height,position:this.systems.watermarkSystem.options.position}),this.systems.twoDEntitySystem.update(this.systems.cameraSystem.getZoomLevel(),this.systems.cameraSystem.isUserInteracting(),this.systems.cameraSystem.isCameraMoving(),this.systems.imageSystem.currentImageScreenBBoxes),this.systems.watermarkSystem.update(),this.systems.textureSystem.update(),this.systems.pluginSystem.update(this.state,this.systems),this.systems.drawSystem.update(),this.systems.geometryDisposalSystem.update(),this.systems.maskingSystem.update(),this.systems.cameraSystem.dirty=!1,this.systems.cameraSystem.zoomDirty=!1,this.systems.cameraSystem.rotationDirty=!1,this.systems.shadowsSystem&&((this.systems.modelSystem.transparencyChanged||this.systems.drawSystem.transparencyChanged)&&this.systems.shadowsSystem.castersChanged(),this.systems.shadowsSystem.update(this.systems.cameraSystem.getZoomLevel(),this.systems.cameraSystem.getPedestal())),this.systems.modelSystem.endFrame(),this.systems.drawSystem.endFrame(),this.systems.cameraSystem.stateDirty&&(this.publish("camera-state-change"),this.systems.cameraSystem.stateDirty=!1),this.publish("post-render"),Promise.all(e)}catch(e){return Promise.reject(e)}};destroy(){this.frameId&&cancelAnimationFrame(this.frameId),this.systems.twoDEntitySystem.cancelPendingFrames(),this.state.geometry2DIdsInScene.clear(),this.state.geometry3DIdsInScene.clear(),this.systems.twoDEntitySystem.markDirty(),this.update(),super.destroy()}};y();y();y();y();y();import{z as B}from"zod";y();import{z as gi}from"zod";var qr=gi.object({type:gi.enum(["Point"]),coordinates:gi.array(gi.number()).min(2).max(3)});var Rf=B.object({interactive:B.boolean().optional(),id:B.string().optional(),width:B.union([B.number(),B.string().regex(Oo),B.object({on:B.literal("zoom-level").optional(),input:B.array(B.number()).nonempty(),output:B.union([B.array(B.number()).nonempty(),B.array(B.string().regex(Oo)).nonempty()]),easing:B.string().optional()})]).optional(),accentColor:B.string().optional(),displayArrowsOnPath:B.boolean().optional(),animateArrowsOnPath:B.boolean().optional(),visibleThroughGeometry:B.boolean().optional(),dashed:B.boolean().optional(),dashCornerRadius:B.number().optional(),travelledEndFraction:B.number().optional(),travelledColor:B.string().optional(),smoothingTension:B.number().optional(),smoothingCornerRadius:B.number().optional(),dashLength:B.number().optional(),dashGap:B.number().optional(),dashRelativeToWidth:B.boolean().optional(),dashSize:B.number().optional(),gapSize:B.number().optional(),dashAbsolute:B.boolean().optional(),dashMeters:B.number().optional(),gapMeters:B.number().optional(),geometryType:B.enum(["tube","ribbon"]).optional(),endcapExtension:B.tuple([B.number(),B.number()]).optional(),billboarding:B.union([B.boolean(),B.number().min(0).max(90)]).optional(),border:B.object({enabled:B.boolean(),color:B.string(),width:B.number().optional()}).optional(),xrayStyle:B.object({color:B.string().optional(),tint:B.number().min(0).max(1).optional(),dithering:B.number().min(0).optional()}).optional()}),Ff=B.object({type:B.enum(["Feature"]),geometry:qr,properties:B.object({parentId:B.any().optional()})});function Bu(o,e){B.object({features:B.array(Ff)}).parse(o),Rf.parse(e)}function _f(o,e){let t=ca(o);t&&e==="tube"&&(R.warn("Screen-space pixel width is only supported with ribbon geometry. Falling back to world-space interpretation."),t=!1);let r;return typeof o=="object"&&"output"in o?r=o.output.map(n=>typeof n=="string"?Ht(n):Number(n)):gr(o)?r=[Ht(o)]:r=[o],{screenSpace:t,parsedOutputValues:r}}function Bf(o,e){return o||e==="ribbon"}function Gf(o,e){return o&&e==="ribbon"}function kf(o,e){return e?!1:o}var wr=class{type="path";mesh=new nt;material;geometry;outline;feature;options;width={on:"zoom-level",input:[17,22],output:[.8,.4]};breakpoint=0;screenSpace=!1;parsedOutputValues=[];altitudeBreakpoints;accentColor="blue";completeFraction=1;displayArrowsOnPath=!1;animateArrowsOnPath=!1;visibleThroughGeometry=!1;highlightStartFraction=0;highlightEndFraction=0;highlightCompleteFraction=1;highlightWidthMultiplier=1.1;highlightColor="red";highlightDisplayArrowsOnPath=!1;xrayOpacity=.25;xrayStyle;travelledEndFraction=0;travelledColor="#999";dashed=!1;maxDashCount=0;dashCapWarned=!1;curveLength=0;_dashDiscrete=!1;_dashedMask=!1;get dashDiscrete(){return this._dashDiscrete}get dashedMask(){return this._dashedMask}dashCornerRadius=0;smoothingTension=Ft.tension;smoothingCornerRadius=Ft.cornerRadius;dashLength=.1;dashGap=.1;dashRelativeToWidth=!1;dashSize=ua.size;gapSize=ua.gapSize;dashAbsolute=!1;dashMeters=1;gapMeters=.5;geometryType="tube";endcapExtension=[.5,.5];billboarding=80;border;isVertical=!1;dirty=!0;materialDirty=!0;constructor(e,t){this.feature=e,this.options=t||{},this.width=t?.width??this.width,this.accentColor=t?.accentColor??this.accentColor,this.displayArrowsOnPath=t?.displayArrowsOnPath??this.displayArrowsOnPath,this.animateArrowsOnPath=t?.animateArrowsOnPath??this.animateArrowsOnPath,this.highlightDisplayArrowsOnPath=t?.highlightDisplayArrowsOnPath??this.displayArrowsOnPath,this.visibleThroughGeometry=t?.visibleThroughGeometry??this.visibleThroughGeometry,this.dashed=t?.dashed??this.dashed,this.dashCornerRadius=t?.dashCornerRadius??this.dashCornerRadius,this.xrayOpacity=t?.xrayOpacity??this.xrayOpacity,this.xrayStyle=t?.xrayStyle,this.travelledEndFraction=t?.travelledEndFraction??this.travelledEndFraction,this.travelledColor=t?.travelledColor??this.travelledColor,this.smoothingTension=t?.smoothingTension??Ft.tension,this.smoothingCornerRadius=t?.smoothingCornerRadius??Ft.cornerRadius,this.dashLength=t?.dashLength??this.dashLength,this.dashGap=t?.dashGap??this.dashGap,this.dashRelativeToWidth=t?.dashRelativeToWidth??this.dashRelativeToWidth,this.dashSize=t?.dashSize??this.dashSize,this.gapSize=t?.gapSize??this.gapSize,this.dashAbsolute=t?.dashAbsolute??this.dashAbsolute,this.dashMeters=t?.dashMeters??this.dashMeters,this.gapMeters=t?.gapMeters??this.gapMeters,this.geometryType=t?.geometryType??"tube",this.resolveDashState(),this.endcapExtension=t?.endcapExtension??[.5,.5],this.billboarding=t?.billboarding??80,this.border=t?.border,this.updateScreenSpaceState()}resolveDashState(e={}){let t=e.dashed??this.dashed,r=e.geometryType??this.geometryType,n=Gf(t,r),i=n!==this._dashDiscrete;return this._dashDiscrete=n,this._dashedMask=kf(t,n),i}updateScreenSpaceState(){let e=_f(this.width,this.isFlat?"ribbon":"tube");this.screenSpace=e.screenSpace,this.parsedOutputValues=e.parsedOutputValues}get isFlat(){return Bf(this.dashDiscrete,this.geometryType)}setColor(){}setOpacity(){}set visible(e){this.mesh&&(this.mesh.visible=e)}get visible(){return this.mesh?this.mesh.visible:!1}position=new O;set complete(e){this.material&&(this.material.uniforms.complete.value=e,this.material.needsUpdate=!0)}};y();y();y();function Qt(o,e,t){return o.type==="portion"?{top:o.top*t,left:o.left*e,bottom:o.bottom*t,right:o.right*e,type:"pixel"}:o}y();y();y();var Gu=(o,e)=>(e-o+Math.PI)%(Math.PI*2)+Math.PI*2%(Math.PI*2)-Math.PI,ku=(o,e)=>new V(o.clientX-e.offsetLeft,o.clientY-e.offsetTop),Za=(o,e)=>Math.atan2(e.y-o.y,e.x-o.x),Wn=(o,e)=>Math.sqrt((e.y-o.y)**2+(e.x-o.x)**2),Xa=(o,e)=>new V((o.x+e.x)/2,(o.y+e.y)/2),Ya=o=>{let e=0,{wheelDelta:t,detail:r}=o;return t!==void 0?e=t:r!==void 0&&(e=-r),e};var yi=class{input1;input2;lastAngle;lastDistance;totalDistance;first;second;constructor(e,t){this.input1=e,this.input2=t,this.lastAngle=Za(e,t),this.lastDistance=Wn(e,t),this.totalDistance=0,this.first=e,this.second=t}update(e,t){let r=Wn(e,t);this.input1=e,this.input2=t;let n=Za(e,t);this.lastAngle=n,this.lastDistance=r,this.totalDistance+=(Wn(this.first,e)+Wn(this.second,t))/2,this.first=Xa(this.first,e),this.second=Xa(this.second,t)}};y();var Vn=class{touch;camera;cameraPlane;viewCoordinate;snapHolderMatrix;snapCamera;cameraPosition;raycaster;worldCoordinate;snapshotted=!1;constructor(e,t,r){this.touch=e,this.camera=t,this.cameraPlane=r,this.viewCoordinate={x:e.x,y:e.y},this.camera.updateMatrixWorld(),this.camera.updateMatrix(),this.snapHolderMatrix=this.camera.matrixWorld.clone(),this.snapCamera=this.camera.clone(),this.snapshotCameraState()}snapshotCameraState(){this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraPosition=this.camera.position.clone();let e=new V(this.viewCoordinate.x,this.viewCoordinate.y);this.raycaster=this.raycaster||new $t,this.raycaster.setFromCamera(e,this.snapCamera);let t=this.raycaster.intersectObject(this.cameraPlane,!0);this.worldCoordinate=t&&t.length>0?t[0].point:null,this.snapshotted=!0}updateAnchorState(e,t){this.camera=e,this.snapCamera=e.clone(),this.snapHolderMatrix=e.matrixWorld.clone(),this.updateViewCoordinate(t),this.snapshotCameraState()}updateViewCoordinate(e){this.viewCoordinate={x:e.x,y:e.y}}reUnproject(){let e=new V(this.viewCoordinate.x,this.viewCoordinate.y);this.raycaster?.setFromCamera(e,this.snapCamera);let t=this.raycaster?.intersectObject(this.cameraPlane,!0)[0];return t?t.point:void 0}};var ct={};yf(ct,{BLOCK_MERCATOR_ZOOM_LEVEL:()=>zf,CLIPPING_RADIUS:()=>jn,CONTROL_OPTIONS:()=>Nf,DEFAULT_ANIMATION_DURATION:()=>Qa,DEFAULT_BEARING:()=>jf,DEFAULT_MAX_ZOOM_LEVEL:()=>Wf,DEFAULT_MIN_ZOOM_LEVEL:()=>tl,DEFAULT_PITCH:()=>Vf,DEFAULT_ZOOM_LEVEL:()=>Hf,EVENTS:()=>el,MAPLIBRE_TILE_SIZE:()=>bi,MAX_LAT:()=>qa,MAX_MERCATOR_ZOOM_LEVEL:()=>xi,MIN_LAT:()=>$a,MIN_MERCATOR_ZOOM_LEVEL:()=>vi,ROOM_MERCATOR_ZOOM_LEVEL:()=>Uf,TWO_PI:()=>Ja,WHEEL_ZOOM_MULTIPLIER:()=>Ka,ZRANGE:()=>Jr});y();var bi=512,$a=-85.051129,qa=85.051129,jn=1e4,Nf={chain:"chain",cancel:"cancel"},Ja=Math.PI*2,Jr=100,Ka=1e4,vi=0,xi=24,zf=17,Uf=20,Qa=200,el=["change","pan-start","pan-end","rotate-start","rotate-end","zoom-start","zoom-end","multi-start","multi-end","multi-cancel","pedestal-start","pedestal-change","pedestal-end","user-pan-start","user-pedestal-start","user-rotate-start","user-dolly-start","user-zoom-start","user-tilt-start","user-pan-end","user-pedestal-end","user-rotate-end","user-dolly-end","user-zoom-end","user-tilt-end","position-updated","zoom-updated","tilt-updated","rotation-updated"],Hf=18,tl=12,Wf=22,Vf=0,jf=0;y();y();var Er=class extends Error{};Er.prototype.name="InvalidTokenError";function Zf(o){return decodeURIComponent(atob(o).replace(/(.)/g,(e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function Xf(o){let e=o.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return Zf(e)}catch{return atob(e)}}function Nu(o,e){if(typeof o!="string")throw new Er("Invalid token specified: must be a string");e||(e={});let t=e.header===!0?0:1,r=o.split(".")[t];if(typeof r!="string")throw new Er(`Invalid token specified: missing part #${t+1}`);let n;try{n=Xf(r)}catch(i){throw new Er(`Invalid token specified: invalid base64 for part #${t+1} (${i.message})`)}try{return JSON.parse(n)}catch(i){throw new Er(`Invalid token specified: invalid json for part #${t+1} (${i.message})`)}}y();function ot(o,e,t,r){return(o<e||o>t)&&R.warn(r),Math.min(t,Math.max(e,o))}function fC(o){let e=Nu(o);if(e.sub==null)throw new Error("Access token is missing sub claim.");return{sub:e.sub,aud:typeof e.aud=="string"?[e.aud]:e.aud??[],capabilities:e.capabilities??{}}}function vt(o){return o*(Math.PI/180)}function zu(o){return o*(180/Math.PI)}function Si(o,e){let t=Math.pow(10,e);return Math.sign(o)*Math.round(Math.abs(o)*t)/t}function Uu(o,e){return(o%e+e)%e}function Hu(o,e){let t=Uu(o,Math.PI*2),r=Uu(e,Math.PI*2),n=r-t,i=r+(n>Math.PI?-Math.PI*2:n<-Math.PI?Math.PI*2:0);return{start:t,end:i}}function gC(){return typeof window<"u"&&window!==null}function Wu(o,e){let[t,r]=o,[n,i]=e,s=vt(n-t),a=vt(i-r);return Math.sqrt(s*s+a*a)*yt}function Qe(o,e){let t=vt(o[0]),r=vt(o[1]),n=vt(e[0]),i=vt(e[1]),s=i-r,l=(n-t)*Math.cos((r+i)/2),c=s;return Math.sqrt(l*l+c*c)*yt}function rl(o,e){return Math.sqrt(Math.pow(o.x-e.x,2)+Math.pow(o.y-e.y,2))}function Mi(o){let e=vt(o),r=Math.cos(e)*yt;function n(s,a){let l=vt(s[0]),c=vt(s[1]),d=l*r,u=c*yt;return a?(a.x=d,a.y=u,a):{x:d,y:u}}return{toCartesian:n,toGeographic:(s,a)=>{let l=zu(s/r),c=zu(a/yt);return{lon:l,lat:c}}}}var yC=()=>{};var Ci=!1,Yf=!1;var Kr=class extends q{dirty=!1;zoomDirty=!1;rotationDirty=!1;panDirty=!1;stateDirty=!1;#e=tl;zoomSpeed=5;rotateSpeed=100;enabled=!0;enableZoom=!0;enablePan=!0;enablePedestal=!1;maxPedestal=1/0;minPedestal=0;enableRotate=!0;minZoomAltitude=0;maxZoomAltitude=1/0;get maxZoomLevel(){return this.convertAltitudeToZoomLevel(this.minZoomAltitude)}setMaxZoomLevel(e){this.minZoomAltitude=this.convertZoomLevelToAltitude(e),this.stateDirty=!0}get defaultMinZoomLevel(){return this.#e}get minZoomLevel(){return this.convertAltitudeToZoomLevel(this.maxZoomAltitude)}setMinZoomLevel(e){this.maxZoomAltitude=this.convertZoomLevelToAltitude(e),this.stateDirty=!0}ignoreZoomLimits=!1;zoomFactor=1;panBounds={min:new O(1/0,1/0),max:new O(-1/0,-1/0),center:new O(0,0,0),radius:1/0};minTilt=0;maxTilt=1.2;MOUSE_BUTTONS={ORBIT:Ao.RIGHT,ZOOM:Ao.MIDDLE,PAN:Ao.LEFT};camera;scene;renderer;elevation;orbit;cameraPlane;raycaster=new $t;rendererState;options;state=-1;intersection;viewState=null;tweens=new Map;clock=new cd(!0);coords={mouse:new V,rotateStart:new V,rotateEnd:new V,rotateDelta:new V,panStart:new O,panCameraStart:new O,panEnd:new O,panDelta:new O,initialShiftPos:new V,initialPedestal:0,floorAnchor:new O};touch={origin:{offsetLeft:0,offsetTop:0},touches:[],anchor1:null,anchor2:null,inputs:null};scrollTimer=null;lastWheelTime=0;resetZoom=!1;zoomStart;pedestalScaleFactor=1;isUserZooming=!1;stayInsideBounds=!0;userInteracting=!1;cameraMoving=!1;lastCameraMoveTime=Date.now();constructor(e,t,r,n,i){super(),this.camera=e,this.renderer=r,this.rendererState=n,this.scene=t,this.options=i,this.elevation=e.parent,this.orbit=this.elevation.parent,this.cameraPlane=this.createCameraPlane(),this.zoomStart=e.position.z,i.mode==="outdoors-overlay"||i.__EXPERIMENTAL_CameraControlsMode==="external"?this.addMovingStateListeners():this.addEventListeners()}addMovingStateListeners=()=>{for(let e of el)e.endsWith("start")?(this.on(e,this.setCameraMoving),e.startsWith("user")&&this.on(e,this.setUserInteracting)):(e.endsWith("end")||e.endsWith("cancel"))&&(this.on(e,this.unsetCameraMoving),e.startsWith("user")&&this.on(e,this.unsetUserInteracting))};get scrollPercent(){let e=this.minPedestal,t=this.maxPedestal,r=this.getPedestal();return r=Math.min(r,t),r=Math.max(r,e),(r-e)/(t-e)*100}get fov(){return this.camera.fov}get scrolledToBottom(){return this.minPedestal===0||Math.floor(this.getPedestal())<=this.minPedestal}get scrolledToTop(){return this.maxPedestal===0||Math.ceil(this.getPedestal())>=this.maxPedestal}get center(){let e=this.getPosition(),{lat:t,lon:r}=Xo(this.rendererState.center?.[1]??0,this.rendererState.center?.[0]??0,e.x,e.y);return[r,t]}setCenter(e,t){let{x:r,y:n}=Yo(this.rendererState.center?.[1]??0,this.rendererState.center?.[0]??0,t,e);this.setPosition(r,n)}raycastToFloor=e=>{this.raycaster.setFromCamera(e,this.camera);let t=this.raycaster.intersectObject(this.cameraPlane,!1)[0];return t?t.point:new O};isUserInteracting=()=>this.userInteracting;getPosition=()=>new O(this.orbit.position.x,this.orbit.position.y,this.orbit.position.z);getPedestal=()=>this.orbit.position.z;pan=(e,t)=>{isNaN(e)||isNaN(t)||(this.setPosition(this.orbit.position.x+e,this.orbit.position.y+t),this.publish("position-updated"))};postRender=()=>{(this.state===2||this.state===6)&&(this.raycaster.setFromCamera(this.coords.mouse,this.camera),this.intersection=this.raycaster.intersectObject(this.cameraPlane,!1)[0],this.intersection&&(this.coords.panStart.set(this.intersection.point.x,this.intersection.point.y,0),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0))),this.state===3&&this.resetZoom&&(this.resetZoom=!1,this.zoomStart=this.getZoomAltitude(),this.coords.floorAnchor=this.raycastToFloor(this.coords.mouse),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0)),this.state===7&&this.isAnimating===!1&&(this.state=-1,this.publish("multi-end"))};get isAnimating(){return this.rendererState.internalTweenGroup.getAll().some(e=>e.cameraAnimation)}isCameraMoving=()=>this.cameraMoving;lastCameraStoppedMovingTime=()=>this.lastCameraMoveTime;beginGesture=()=>{this.state=2,this.publish("pan-start")};endGesture=()=>{this.state===2&&(this.state=-1,this.publish("pan-end"))};setPosition=(e,t)=>{e===void 0||t===void 0||isNaN(e)||isNaN(t)||(this.state===-1&&this.publish("pan-start"),this.updateCameraPosition(e,t),this.publish("position-updated"),this.publish("change"),this.state===-1&&this.publish("pan-end"),this.dirty=!0,this.stateDirty=!0)};updateCameraPosition=(e,t)=>{let r=e-this.panBounds.center.x,n=t-this.panBounds.center.y,i=Math.sqrt(r*r+n*n);if(this.stayInsideBounds&&i>this.panBounds.radius){let s=Math.atan2(n,r),a={x:Math.cos(s)*this.panBounds.radius+this.panBounds.center.x,y:Math.sin(s)*this.panBounds.radius+this.panBounds.center.y};this.orbit.position.x=a.x,this.orbit.position.y=a.y}else this.orbit.position.x=e,this.orbit.position.y=t};tilt=e=>{if(isNaN(e))return;this.state===-1&&this.publish("rotate-start");let t=this.stayInsideBounds?Math.max(Math.min(e+this.getTilt(),this.maxTilt),this.minTilt):e+this.getTilt();t!==this.elevation.rotation.x&&(this.elevation.rotation.x=t,this.publish("tilt-updated")),this.publish("change"),this.state===-1&&this.publish("rotate-end"),this.stateDirty=!0};zoomIn=(e,t,r)=>{let n=this.getZoomAltitude();this.animateCamera({zoom:n/1.5},e,t,r)};zoomOut=(e,t,r)=>{let n=this.getZoomAltitude();this.animateCamera({zoom:n*1.5},e,t,r)};getRotation=()=>(-this.orbit.rotation.z+Math.PI*2)%(Math.PI*2);cancelAnimation=()=>{let e=Array.from(this.tweens.keys());if(e.length<1)return;let t=e[e.length-1];t.state===7&&this.publish("multi-cancel",{zooming:!0,rotating:!0,tilting:!0}),t.isPlaying()&&this.tweens.get(t)?.cancelledCallback?.(),this.completeTween(t),this.state===7&&(this.state=-1)};animateCamera=(e,t,r,n,i,s)=>{let a={interruptible:!0,...s},l={},c={},d=this.getPosition();if(e.position!=null&&(e.position.x!==void 0&&(l.x=d.x,c.x=e.position.x),e.position.y!==void 0&&(l.y=d.y,c.y=e.position.y),e.position.z!==void 0&&(l.z=d.z,c.z=e.position.z)),e.zoom!==void 0&&(l.zoom=this.stayInsideBounds?Math.min(Math.max(this.getZoomAltitude(),this.getZoomScaledMin()),this.getZoomScaledMax()):this.getZoomAltitude(),this.viewState==="multi_floor"||!this.stayInsideBounds?c.zoom=e.zoom:c.zoom=Math.min(Math.max(e.zoom,this.getZoomScaledMin()),this.getZoomScaledMax())),e.rotation!==void 0){let{start:g,end:b}=Hu(this.getRotation(),e.rotation);l.rotation=g,c.rotation=b}e.tilt!==void 0&&(l.tilt=this.getTilt(),this.viewState==="multi_floor"||!this.stayInsideBounds?c.tilt=e.tilt:c.tilt=Math.max(Math.min(e.tilt,this.maxTilt),this.minTilt));let u=l.zoom!==c.zoom,h=l.rotation!==c.rotation,v=l.tilt!==c.tilt,f=new Gc(l).to(c,E.env.TESTING?0:t).onUpdate(g=>{this.setMulti({x:g.x,y:g.y,z:g.z},g.zoom,g.rotation,g.tilt)}).onComplete(()=>{this.completeTween(f),this.publish("multi-end",{zooming:u,rotating:h,tilting:v}),n&&n()}).onStart(()=>{this.state!==7&&(this.state=7,f.state=7,this.publish("multi-start",{zooming:u,rotating:h,tilting:v})),this.publish("change")});this.rendererState.internalTweenGroup.add(f);let M=Array.from(this.tweens.entries()),p=M[M.length-1],m=!1;return p!=null&&(p[1].interruptible?(typeof p[1].cancelledCallback=="function"&&p[1].cancelledCallback(),this.completeTween(p[0])):(m=!0,p[0].chain(f))),this.tweens.set(f,{cancelledCallback:i,interruptible:a.interruptible}),r?f.easing(r):f.easing(yr.Quadratic.In),!e.doNotAutoStart&&!m&&(f.start(),this.publish("change")),f.cameraAnimation=!0,f};setMulti=(e,t,r,n,i=!0)=>{this.state===-1&&this.publish("multi-start");let s=!1;e!=null&&(e.x!==void 0&&!isNaN(e.x)&&e.y!==void 0&&!isNaN(e.y)&&(this.updateCameraPosition(e.x,e.y),s=!0),e.z!==void 0&&!isNaN(e.z)&&(this.setPedestal(e.z,!0,!1),s=!0)),s&&this.publish("position-updated");let a={zooming:!1,tilting:!!t,rotating:!1};if(t!==void 0&&!isNaN(t)){let l=this.stayInsideBounds?Math.min(Math.max(t,this.getZoomScaledMin()),this.getZoomScaledMax()):t;l!==this.camera.position.z&&(a.zooming=!0,this.camera.position.z=l,this.publish("zoom-updated"),this.zoomDirty=!0,this.viewState==="multi_floor"?t>jn&&(this.camera.near=t-jn,this.camera.far=t+jn):(this.camera.near=t/Jr,this.camera.far=t*Jr),this.camera.updateProjectionMatrix())}if(r!==void 0&&!isNaN(r)&&r!==this.getRotation()&&(a.rotating=!0,this.orbit.rotation.z=-r,this.publish("rotation-updated")),n!==void 0&&!isNaN(n)){let l=this.stayInsideBounds?Math.max(Math.min(n,this.maxTilt),this.minTilt):n;l!==this.elevation.rotation.x&&(a.tilting=!0,this.elevation.rotation.x=l,this.publish("tilt-updated"))}i&&this.publish("change"),this.state===-1&&this.publish("multi-end",a),this.stateDirty=!0};getZoomScaledMin=()=>this.minZoomAltitude*this.zoomFactor;getZoomScaledMax=()=>{let e=this.minZoomAltitude*this.zoomFactor;return Math.max(this.maxZoomAltitude,e)};setRotation=(e,t)=>{if(isNaN(e))return;this.state===-1&&!t&&this.publish("rotate-start");let r=-(e%Ja);r!==this.orbit.rotation.z&&(this.orbit.rotation.z=r,t||this.publish("rotation-updated")),t||this.publish("change"),this.state===-1&&!t&&this.publish("rotate-end"),this.dirty=!0,this.rotationDirty=!0,t||(this.stateDirty=!0)};setZoomAltitude=e=>{if(isNaN(e))return;this.state===-1&&this.publish("zoom-start");let t=this.stayInsideBounds?Math.min(Math.max(e,this.getZoomScaledMin()),this.getZoomScaledMax()):e;t!==this.camera.position.z&&(this.camera.position.z=t,this.publish("zoom-updated"),this.zoomDirty=!0),this.camera.near=t/Jr,this.camera.far=t*Jr,this.camera.updateProjectionMatrix(),this.publish("change"),this.state===-1&&this.publish("zoom-end"),this.dirty=!0,this.stateDirty=!0};setZoomLevel=e=>{this.setZoomAltitude(this.convertZoomLevelToAltitude(e))};getZoomAltitude=()=>this.camera.position.z;getZoomLevel=()=>this.convertAltitudeToZoomLevel(this.getZoomAltitude());setTilt=(e,t)=>{if(isNaN(e))return;this.state===-1&&!t&&this.publish("rotate-start");let r=this.stayInsideBounds?Math.max(Math.min(e,this.maxTilt),this.minTilt):e;r!==this.elevation.rotation.x&&(this.elevation.rotation.x=r,t||this.publish("tilt-updated")),t||this.publish("change"),this.state===-1&&!t&&this.publish("rotate-end"),this.dirty=!0,t||(this.stateDirty=!0)};getTilt=()=>this.elevation.rotation.x;setCameraPlaneElevation=e=>{this.cameraPlane.position.z=e};zoom=e=>{if(isNaN(e))return;this.state===-1&&this.publish("zoom-start");let t=this.getZoomAltitude()-e;this.camera.position.z=this.stayInsideBounds?Math.min(Math.max(t,this.minZoomAltitude*this.zoomFactor),this.maxZoomAltitude*this.zoomFactor):t,this.publish("zoom-updated"),this.zoomDirty=!0,this.publish("change"),this.state===-1&&this.publish("zoom-end"),this.stateDirty=!0};getProjectionScaleFactor=(e,t,r)=>Ma(e,t,r);update=()=>{this.orbit.updateMatrixWorld(),this.lastWheelTime>0&&this.state===3&&this.clock.getElapsedTime()-this.lastWheelTime>.2&&(this.lastWheelTime=0,this.state=-1,this.publish("zoom-end"),this.removeMouseMoveEventListeners())};setPedestal=(e,t=!1,r=!0)=>{typeof e=="number"&&!isNaN(e)&&(this.orbit.position.z=e,t&&(this.publishPedestalChangeEvent(e),this.publish("pedestal-change",{pedestal:e})),this.publish("change"),this.dirty=!0,r&&(this.stateDirty=!0))};dispose=()=>{this.scene.remove(this.cameraPlane),this.destroy()};createCameraPlane=()=>{let e=Ci?2e3:1e10,t=Ci?100:1,r=new We(e,e,t,t),n=new Be({color:0,wireframe:Ci,visible:Ci}),i=new X(r,n);return this.scene.add(i),i};addEventListeners=()=>{let{domElement:e}=this.renderer;this.addMovingStateListeners(),e.addEventListener("contextmenu",this.onContextMenu,{capture:!1,signal:this.signal}),e.addEventListener("mousedown",this.onMouseDown,{capture:!1,signal:this.signal}),e.addEventListener("wheel",this.onMouseWheel,{capture:!1,passive:!1,signal:this.signal}),e.addEventListener("touchstart",this.onTouchStart,{capture:!1,signal:this.signal}),e.addEventListener("touchend",this.onTouchEnd,{capture:!1,signal:this.signal}),e.addEventListener("touchmove",this.onTouchMove,{capture:!1,signal:this.signal})};addMouseEventListeners=()=>{this.addMouseMoveEventListeners(),window.addEventListener("mouseup",this.onMouseUp,{capture:!1,signal:this.signal}),window.addEventListener("mouseout",this.onWindowMouseOut,{capture:!1,signal:this.signal})};onWindowMouseOut=e=>{e.relatedTarget==null&&this.onMouseUp()};addMouseMoveEventListeners=()=>{window.addEventListener("mousemove",this.onMouseMove,{capture:!0,signal:this.signal})};removeMouseMoveEventListeners=()=>{window.removeEventListener("mousemove",this.onMouseMove,{capture:!0})};removeMouseUpEventListeners=()=>{this.removeMouseMoveEventListeners(),window.removeEventListener("mouseup",this.onMouseUp,{capture:!1}),window.removeEventListener("mouseout",this.onWindowMouseOut,{capture:!1})};onContextMenu=e=>{e.preventDefault()};onMouseUp=()=>{if(this.enabled!==!1){switch(this.removeMouseUpEventListeners(),this.state){case 2:this.publish("pan-end"),this.publish("user-pan-end");break;case 1:this.publish("zoom-end"),this.publish("user-dolly-end");break;case 0:this.publish("rotate-end"),this.publish("user-rotate-end");break;case 8:this.publish("pedestal-end"),this.publish("user-pedestal-end");break}this.state=-1,this.panDirty=!1}};onMouseMove=e=>{if(this.enabled!==!1)if(e.preventDefault(),this.mouseToScene(e),this.state===0){if(this.enableRotate===!1)return;this.handleMouseMoveRotate(e)}else if(this.state===2){if(this.enablePan===!1)return;this.handleMouseMovePan()}else this.state===3?(this.resetZoom=!0,this.state=-1):this.state===8&&this.handleMouseMovePedestal(e)};onTouchStart=e=>{if(this.enabled!==!1){switch(this.updateTouchOrigin(),this.touchToScene(e),e.touches.length){case 1:this.enablePedestal?(this.handleTouchStartPedestal(e),this.state=9):this.enablePan&&(this.handleTouchStartPan(e),this.state=6);break;case 2:this.touch.inputs=new yi(this.touch.touches[0],this.touch.touches[1]);break;default:this.state=-1}this.state}};onTouchMove=e=>{if(this.enabled!==!1)switch(this.touchToScene(e),e.touches.length){case 2:if(!this.touch.inputs)return;e.preventDefault(),e.stopPropagation();let t={...this.touch.inputs.first},r={...this.touch.inputs.second},n=new V(this.touch.touches[0].x,this.touch.touches[0].y),i=new V(this.touch.touches[1].x,this.touch.touches[1].y);if(this.touch.inputs.update(this.touch.touches[0],this.touch.touches[1]),this.enableRotate&&this.state===4)this.handleTouchMoveTilt(e);else if(this.state===5)this.handleTouchMoveDolly();else if(this.state!==5&&this.touch.inputs.totalDistance>.05){let s=t.y<n.y&&r.y<i.y,a=t.y>n.y&&r.y>i.y;this.enableRotate&&this.state!==4&&(a||s)?(this.handleTouchStartTilt(e),this.state=4):(this.handleTouchStartDolly(),this.state=5)}break;case 1:(this.enablePedestal||this.enablePan)&&(e.preventDefault(),e.stopPropagation()),this.enablePedestal&&this.state===9?this.handleTouchMovePedestal(e):this.enablePan&&this.state===6&&this.handleTouchMovePan(e);break;default:this.state=-1}};onTouchEnd=e=>{if(this.enabled!==!1){switch(this.handleTouchEnd(),this.state){case 2:case 6:this.publish("user-pan-end");break;case 4:this.publish("pan-end"),this.publish("user-tilt-end");break;case 1:case 5:this.publish("zoom-end"),this.publish("user-dolly-end");break;case 0:this.publish("rotate-end"),this.publish("user-rotate-end");break;case 8:case 9:this.publish("pedestal-end"),this.publish("user-pedestal-end");break}e.touches.length?this.onTouchStart(e):this.state=-1}};handleTouchMovePan=e=>{let t=Object.hasOwn(e,"x")?new V(e.x,e.y):this.touch.touches[0],r=this.raycastToFloor(t);this.coords.panEnd.set(r.x,r.y,0),this.coords.panDelta.subVectors(this.coords.panEnd,this.coords.panStart),this.setPosition(this.coords.panCameraStart.x-this.coords.panDelta.x,this.coords.panCameraStart.y-this.coords.panDelta.y),this.panDirty=!0};handleTouchStartDolly=()=>{let e=this.touch.touches[0].x-this.touch.touches[1].x,t=this.touch.touches[0].y-this.touch.touches[1].y;this.zoomStart=this.getZoomAltitude();let r=new V(this.touch.touches[0].x-e/2,this.touch.touches[0].y-t/2);this.coords.floorAnchor=this.raycastToFloor(r),this.orbit.updateMatrixWorld(),this.touch.anchor1=new Vn(this.touch.touches[0],this.camera,this.cameraPlane),this.touch.anchor2=new Vn(this.touch.touches[1],this.camera,this.cameraPlane),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("user-dolly-start"),this.publish("zoom-start"),this.publish("multi-start")};handleMouseMovePan=()=>{let e=this.raycastToFloor(this.coords.mouse);this.coords.panEnd.set(e.x,e.y,0),this.coords.panDelta.subVectors(this.coords.panEnd,this.coords.panStart),this.setPosition(this.coords.panCameraStart.x-this.coords.panDelta.x,this.coords.panCameraStart.y-this.coords.panDelta.y),this.panDirty=!0};handleTouchStartTilt=e=>{this.coords.rotateStart.set(e.touches[1].clientX,e.touches[1].clientY),this.publish("user-tilt-start"),this.publish("rotate-start")};handleTouchMovePedestal=e=>{this.handleMouseMovePedestal(e.touches[0])};handleTouchMoveTilt=e=>{this.coords.rotateEnd.set(e.touches[1].clientX,e.touches[1].clientY),this.coords.rotateDelta.subVectors(this.coords.rotateEnd,this.coords.rotateStart),this.setTilt(this.getTilt()-this.coords.rotateDelta.y/this.rotateSpeed),this.coords.rotateStart.copy(this.coords.rotateEnd)};handleTouchMoveDolly=()=>{let e=this.touch.inputs.first,t=this.touch.inputs.second;this.touch.anchor1.viewCoordinate={x:e.x,y:e.y},this.touch.anchor2.viewCoordinate={x:t.x,y:t.y};let r=this.makeTransformFromTouchAnchors(this.touch.anchor1,this.touch.anchor2);r&&this.setCameraFromTransformMatrix(r),this.orbit.updateMatrixWorld(),this.touch.anchor1.updateAnchorState(this.camera,e),this.touch.anchor2.updateAnchorState(this.camera,t)};handleTouchEnd=()=>{this.state===4||this.state===5?this.publish("multi-end"):this.state===6&&this.publish("pan-end"),this.panDirty=!1};handleTouchStartPan=e=>{let t=Object.hasOwn(e,"x")?new V(e.x,e.y):this.touch.touches[0],r=this.raycastToFloor(t);this.coords.panStart.set(r.x,r.y,0),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("user-pan-start"),this.publish("pan-start")};handleTouchStartPedestal=e=>{this.handleMouseDownPedestal(e.touches[0])};onMouseDown=e=>{if(this.enabled!==!1){if(this.mouseToScene(e),e.preventDefault(),this.state===3&&this.publish("zoom-end"),e.button===this.MOUSE_BUTTONS.ORBIT){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else(e.button===this.MOUSE_BUTTONS.PAN||e.button===this.MOUSE_BUTTONS.ZOOM)&&(this.enablePan?(this.handleMouseDownPan(),this.state=2):this.enablePedestal&&(this.handleMouseDownPedestal(e),this.state=8));this.state!==-1&&this.addMouseEventListeners()}};onMouseWheel=e=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1&&this.state!==3&&this.state!==7||(this.state===7&&this.cancelAnimation(),e.preventDefault(),e.stopPropagation(),this.mouseToScene(e),this.canScrollZoom(e)&&(this.lastWheelTime=this.clock.getElapsedTime(),this.publishUserZoomEvent()),this.state!==3&&this.canScrollZoom(e)&&(this.addMouseMoveEventListeners(),this.state=3,this.zoomStart=this.getZoomAltitude(),this.coords.floorAnchor=this.raycastToFloor(this.coords.mouse),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("zoom-start")),this.scrollTimer!=null&&clearTimeout(this.scrollTimer),this.scrollTimer=setTimeout(()=>{this.publish("zoom-end")},50),this.handleMouseWheel(e))};handleMouseWheel=e=>{if(this.publish("zoom-start"),!this.canScrollZoom(e)){this.lastWheelTime>0&&this.publish("zoom-end"),this.lastWheelTime=0,this.state=-1;return}let t=this.getZoomAltitude(),r=t-Ya(e)*t/Ka*this.zoomSpeed;if(this.setZoomAltitude(r),this.enablePan){let n=this.getZoomAltitude()/this.zoomStart;this.coords.panDelta.subVectors(this.coords.floorAnchor,this.coords.panCameraStart).multiplyScalar(1-n),this.setPosition(this.coords.panCameraStart.x+this.coords.panDelta.x,this.coords.panCameraStart.y+this.coords.panDelta.y)}this.publish("change")};setCameraFromTransformMatrix=e=>{this.orbit.updateMatrixWorld();let t=new Lt;t.setFromRotationMatrix(e,"ZYX");let r=(e.elements[14]-this.cameraPlane.position.z)/Math.cos(t.x),n=t.z,i=new O(0,0,1);i.applyEuler(t),i.setLength(r);let s=new O;s.setFromMatrixPosition(e),s.sub(i),this.enablePan&&this.setPosition(s.x,s.y),this.enableZoom&&this.setZoomAltitude(r),this.enableRotate&&this.setRotation(-n)};makeTransformFromTouchAnchors=(e,t)=>{this.orbit.updateMatrixWorld(),this.camera.updateProjectionMatrix();let r=this.camera.projectionMatrix.clone(),n=e.worldCoordinate,i=t.worldCoordinate,s=e.reUnproject(),a=t.reUnproject();if(!s||!a||!n||!i)return null;let l=e.viewCoordinate,c=t.viewCoordinate,d=i.x-n.x,u=i.y-n.y,h=Math.atan2(u,d),v=a.x-s.x,f=a.y-s.y,M=Math.atan2(f,v),p=Gu(h,M),m=new K;m.makeRotationZ(-p);let g=m.clone();g.multiply(e.snapHolderMatrix);let b=(ge,Se,mt)=>ge.elements[(Se-1)*4+mt-1],x=b(r,1,1)*b(g,1,1)-l.x*b(r,3,4)*b(g,3,1),S=b(r,1,1)*b(g,1,2)-l.x*b(r,3,4)*b(g,3,2),C=b(r,1,1)*b(g,1,3)-l.x*b(r,3,4)*b(g,3,3),D=n.x*x+n.y*S+n.z*C,w=b(r,2,2)*b(g,2,1)-l.y*b(r,3,4)*b(g,3,1),P=b(r,2,2)*b(g,2,2)-l.y*b(r,3,4)*b(g,3,2),T=b(r,2,2)*b(g,2,3)-l.y*b(r,3,4)*b(g,3,3),I=n.x*w+n.y*P+n.z*T,L=b(r,1,1)*b(g,1,1)-c.x*b(r,3,4)*b(g,3,1),A=b(r,1,1)*b(g,1,2)-c.x*b(r,3,4)*b(g,3,2),F=b(r,1,1)*b(g,1,3)-c.x*b(r,3,4)*b(g,3,3),k=i.x*L+i.y*A+i.z*F,_=b(r,2,2)*b(g,2,1)-c.y*b(r,3,4)*b(g,3,1),j=b(r,2,2)*b(g,2,2)-c.y*b(r,3,4)*b(g,3,2),G=b(r,2,2)*b(g,2,3)-c.y*b(r,3,4)*b(g,3,3),Z=i.x*_+i.y*j+i.z*G,se=Math.abs(L-x),xe=Math.abs(A-S),oe=Math.abs(F-C),ie=Math.abs(L-w),rt=Math.abs(A-P),ze=Math.abs(F-T),H=Math.abs(_-x),fe=Math.abs(j-S),Ye=Math.abs(G-C),pt=Math.abs(_-w),_e=Math.abs(j-P),$e=Math.abs(G-T),Oe=Math.min(se+xe+oe,ie+rt+ze),te=Math.min(H+fe+Ye,pt+_e+$e);Oe<te&&(L=_,A=j,F=G,k=Z);let Ue=w*C-x*T,Le=P*C-S*T,st=I*C-D*T,Ae=L*T-w*F,ce=A*T-P*F,He=k*T-I*F,pr=(He*Le-st*ce)/(Ae*Le-Ue*ce),be=(He*Ue-st*Ae)/(ce*Ue-Le*Ae),qe=P*x-S*w,ta=T*x-C*w,ra=I*x-D*w,at=A*w-P*L,mr=F*w-T*L,yn=((k*w-I*L)*qe-ra*at)/(mr*qe-ta*at),U=g.clone();return U.elements[12]=pr,U.elements[13]=be,U.elements[14]=yn,yn>0?U:null};updateTouchOrigin=()=>{let e=this.renderer.domElement;this.touch.origin.offsetLeft=e.getBoundingClientRect().left,this.touch.origin.offsetTop=e.getBoundingClientRect().top};touchToScene=e=>{this.touch.touches=[];for(let t=0,r=e.touches.length;t<r;t++){let n=e.touches[t],i=ku(n,this.touch.origin);this.touch.touches.push(new V(i.x/this.renderer.domElement.width*this.rendererState.pixelRatio*2-1,-(i.y/this.renderer.domElement.height*this.rendererState.pixelRatio)*2+1))}this.coords.mouse=this.touch.touches[0]};canScrollZoom=e=>{let t=Ya(e),r=this.getZoomAltitude();return!(t<0&&r===this.getZoomScaledMax()||t>0&&r===this.getZoomScaledMin())};mouseToScene=e=>{let t=this.getMousePos(e);return this.coords.mouse.x=t.x/this.renderer.domElement.width*this.rendererState.pixelRatio*2-1,this.coords.mouse.y=-(t.y/this.renderer.domElement.height*this.rendererState.pixelRatio)*2+1,this.coords.mouse};getMousePos=e=>{let t=this.renderer.domElement.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}};handleMouseDownRotate=e=>{this.coords.rotateStart.set(e.clientX,e.clientY),this.publish("rotate-start"),this.publish("user-rotate-start")};handleMouseDownPan=()=>{let e=this.raycastToFloor(this.coords.mouse);this.coords.panStart.set(e.x,e.y,0),this.coords.panCameraStart.set(this.orbit.position.x,this.orbit.position.y,0),this.publish("pan-start"),this.publish("user-pan-start")};handleMouseDownPedestal=e=>{let t=new V(e.clientX,e.clientY);this.coords.initialShiftPos=t,this.coords.initialPedestal=this.getPedestal(),this.pedestalScaleFactor=Ma(this.camera.fov,this.renderer.domElement.clientHeight,this.getZoomAltitude()),this.publish("pedestal-start"),this.publish("user-pedestal-start")};handleMouseMovePedestal=e=>{let t={x:e.clientX,y:e.clientY},r=this.coords.initialPedestal+this.pedestalScaleFactor*(t.y-this.coords.initialShiftPos.y);this.stayInsideBounds&&(r<this.minPedestal?r=Math.max(r,this.minPedestal):r>this.maxPedestal&&(r=Math.min(r,this.maxPedestal))),r!==this.getPedestal()&&this.setPedestal(r,!0)};handleMouseMoveRotate=e=>{this.coords.rotateEnd.set(e.clientX,e.clientY),this.coords.rotateDelta.subVectors(this.coords.rotateEnd,this.coords.rotateStart),this.setRotation(this.getRotation()+this.coords.rotateDelta.x/this.rotateSpeed),this.setTilt(this.getTilt()-this.coords.rotateDelta.y/this.rotateSpeed),this.coords.rotateStart.copy(this.coords.rotateEnd),this.publish("change")};publishUserZoomDebounced=zt(()=>{this.isUserZooming=!1,this.publish("user-zoom-end")},250);publishUserZoomEvent=()=>{this.isUserZooming?this.publishUserZoomDebounced():(this.publish("user-zoom-start"),this.isUserZooming=!0,this.publishUserZoomDebounced())};setCameraMoving=()=>{this.cameraMoving=!0};unsetCameraMoving=()=>{this.cameraMoving=!1,this.lastCameraMoveTime=Date.now()};setUserInteracting=()=>{this.userInteracting=!0};unsetUserInteracting=()=>{this.userInteracting=!1};publishPedestalChangeEvent=e=>{this.publish("pedestal-change",{pedestal:e,scrolledToTop:this.scrolledToTop,scrolledToBottom:this.scrolledToBottom,scrollPercent:this.scrollPercent})};convertAltitudeToZoomLevel=e=>{let[,t]=this.center,r=this.computeMetersPerPixelFromAltitude(e),n=Math.cos(W.degToRad(t))*2*Math.PI*yt/r;return W.clamp(Math.log2(n/512),vi,xi)};convertZoomLevelToAltitude=e=>this.computeMetersPerPixelFromZoomLevel(e)*this.options.canvasHeight/2/Math.tan(W.degToRad(this.camera.fov)/2);completeTween=e=>{e.isPlaying()&&e.stop(),this.rendererState.internalTweenGroup.remove(e),this.tweens.delete(e)};static CAMERA_FRAME_PADDING_SIDES=["top","bottom","left","right"];debugContainer=new Je;getCameraFrameForCoordinates(e,t){let r=t.minZoom!==void 0?t.minZoom:this.minZoomAltitude,n=t.maxZoom!==void 0?t.maxZoom:this.maxZoomAltitude,i=this.options.canvasWidth,s=this.options.canvasHeight,a=this.getRotation(),l=this.getTilt(),c=this.getPosition();this.setRotation(t.rotation??a,!0),this.setTilt(t.tilt??l,!0);let d=nl(e,{canvasWidth:i,canvasHeight:s,paddingOption:t.padding,verticalPadding:t.verticalPadding,minZoom:r,maxZoom:n,position:c,camera:this.camera,orbit:this.orbit});return this.setRotation(a,!0),this.setTilt(l,!0),{center:d.position,zoomLevel:this.convertAltitudeToZoomLevel(d.zoom)}}focusOn(e,t){if(Yf){this.debugContainer&&Ce(this.debugContainer);let M=new Zt(4,4,4),p=new Be({color:65280,depthTest:!1}),m=new re(M,p,e.length),g=new K;e.forEach((b,x)=>{g.setPosition(b),m.setMatrixAt(x,g)}),m.instanceMatrix.needsUpdate=!0,this.debugContainer.add(m),this.scene.add(this.debugContainer)}let r=t.curve,n=t.callback,i=t.cancelledCallback,s=t.minZoom!==void 0?t.minZoom:this.minZoomAltitude,a=t.maxZoom!==void 0?t.maxZoom:this.maxZoomAltitude,l=this.options.canvasWidth,c=this.options.canvasHeight,d;t.duration!==void 0?d=t.duration:E.env.TESTING==="true"?d=0:d=Qa;let u=t.padding,h=this.getRotation(),v=this.getTilt();t.rotation!=null&&this.setRotation(t.rotation),t.tilt!=null&&this.setTilt(t.tilt);let f=nl(e,{canvasHeight:c,paddingOption:u,canvasWidth:l,minZoom:s,maxZoom:a,camera:this.camera,orbit:this.orbit,position:this.getPosition(),verticalPadding:t.verticalPadding});this.setRotation(h),this.setTilt(v),this.animateCamera({position:f.position,tilt:t.tilt,rotation:t.rotation,zoom:f.zoom},d,r,n,i,t)}resize(e,t){this.options.canvasWidth=e,this.options.canvasHeight=t}computeMetersPerPixelFromZoomLevel(e){let[,t]=this.center,r=W.clamp(e,vi,xi),n=Math.pow(2,r),i=W.clamp(t,$a,qa),s=n*512;return Math.cos(W.degToRad(i))*Math.PI*2*yt/s}computeMetersPerPixelFromAltitude(e){return e*2*Math.tan(W.degToRad(this.camera.fov)/2)/this.options.canvasHeight}getCurrentMetersPerPixel(){let e=Math.max(0,this.getPedestal()-this.minPedestal);return this.computeMetersPerPixelFromAltitude(this.getZoomAltitude()+e)}};function nl(o,{canvasWidth:e,orbit:t,paddingOption:r,verticalPadding:n=0,canvasHeight:i,minZoom:s,maxZoom:a,camera:l,position:c}){let d={zoom:s,position:c};if(o.length===0)return d;for(let Le of Kr.CAMERA_FRAME_PADDING_SIDES)typeof r[Le]!="number"&&(r[Le]=0);let u=Qt(r,e,i);if(u.left+u.right>=e||u.top+u.bottom>=i)return d;t.updateMatrixWorld();let h=l.matrixWorldInverse,v=l.fov*(Math.PI/180)/2,f=v,p=Math.atan(Math.tan(v)*(e/i)),m=new O(1/0,1/0,1/0),g=new O(-1/0,-1/0,-1/0),b=new de,x=new O;for(let Le=0,st=o.length;Le<st;Le++)x.copy(o[Le]),b.expandByPoint(x),x.applyMatrix4(h),m.min(x),g.max(x),x.copy(o[Le]),x.z-=n,x.applyMatrix4(h),m.min(x),g.max(x),x.copy(o[Le]),x.z+=n,x.applyMatrix4(h),m.min(x),g.max(x);let S=g.x-m.x,C=g.y-m.y,D=e-u.left-u.right,w=i-u.top-u.bottom,P=(g.x+m.x)/2,T=(g.y+m.y)/2,I=S/D,L=C/w,A=s,F=a,k=A*Math.tan(p)*2,_=F*Math.tan(p)*2,j=k/e,G=_/e,Z=Math.max(I,L);Z=W.clamp(Z,j,G);let se=D*Z,xe=w*Z,oe={min:{x:P-se/2-u.left*Z,y:T-xe/2-u.bottom*Z},max:{x:P+se/2+u.right*Z,y:T+xe/2+u.top*Z}},ie=(oe.min.x+oe.max.x)/2,rt=(oe.min.y+oe.max.y)/2,ze=b.getCenter(new O),H=Math.abs(ie-oe.min.x),fe=Math.abs(rt-oe.min.y),Ye=H/Math.tan(p),pt=fe/Math.tan(f),_e=new O;_e.set(ie,rt,g.z+Math.max(Ye,pt)),_e.applyMatrix4(l.matrixWorld);let $e=new O;$e.set(ie,rt,g.z),$e.applyMatrix4(l.matrixWorld);let Oe=new O().subVectors($e,_e),te=(ze.z-_e.z)/Oe.z,Ue=new O().copy(_e).add(Oe.clone().multiplyScalar(te));return $e.set(Ue.x,Ue.y,Ue.z),_e.sub($e),{position:Ue,zoom:_e.length()}}y();import{z as ae}from"zod";var $f=ae.object({rotation:ae.array(ae.number()).length(3).optional(),altitude:ae.number().optional(),scale:ae.array(ae.number()).length(3).optional(),interactive:ae.boolean().optional(),verticalOffset:ae.number().optional(),id:ae.union([ae.number(),ae.string()]).optional()}),qf=ae.object({type:ae.enum(["Feature"]),geometry:qr,properties:$f}),Jf=ae.object({type:ae.enum(["FeatureCollection"]),features:ae.array(qf)}),Kf=ae.object({color:ae.string()}),Qf=ae.object({url:ae.string(),color:ae.string().optional(),opacity:ae.number().optional(),material:ae.record(ae.string(),Kf).optional()});function Vu(o,e,t){ae.union([ae.number(),ae.string()]).parse(o),Jf.parse(e),Qf.parse(t)}var Dr=class{mesh;meshContainer=null;type="model";positionDirty=!0;outline;geometry;material;feature;instanceIndex=-1;instancingDisabled=!1;constructor(e){this.feature=e}#e=!0;get visible(){return this.#e}set visible(e){this.#e=e}color=new z;clippingPlane;get modelScene(){return this.clippingPlane?this.mesh?.children.find(e=>e.name!=="hole-fill-mesh"):this.mesh}position=new O;#n=0;get altitude(){return this.#n}set altitude(e){this.#n=e}#i=1;get opacity(){return this.#i}set opacity(e){this.#i=e}#o=ye.GEOMETRY;get renderOrder(){return this.#o}set renderOrder(e){this.#o=e}#s=!1;get visibleThroughGeometry(){return this.#s}set visibleThroughGeometry(e){this.#s=e}};y();y();var Tr={container:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9998"},focusOnBox:{position:"absolute",border:"2px solid orange",backgroundColor:"transparent",pointerEvents:"none"},getFocusOnTransformBox:{position:"absolute",border:"2px dashed cyan",backgroundColor:"rgba(0, 255, 255, 0.1)",pointerEvents:"none"},animateToBox:{position:"absolute",width:"12px",height:"12px",border:"2px solid lime",backgroundColor:"rgba(0, 255, 0, 0.3)",borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"},label:{position:"absolute",fontSize:"10px",fontFamily:"monospace",color:"white",backgroundColor:"rgba(0, 0, 0, 0.7)",padding:"2px 4px",borderRadius:"2px",whiteSpace:"nowrap"}},ol={container:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9999"},top:{position:"absolute",top:"0",left:"0",right:"0",backgroundColor:"rgba(255, 0, 0, 0.2)",borderBottom:"2px dashed rgba(255, 0, 0, 0.6)"},bottom:{position:"absolute",bottom:"0",left:"0",right:"0",backgroundColor:"rgba(0, 255, 0, 0.2)",borderTop:"2px dashed rgba(0, 255, 0, 0.6)"},left:{position:"absolute",top:"0",bottom:"0",left:"0",backgroundColor:"rgba(0, 0, 255, 0.2)",borderRight:"2px dashed rgba(0, 0, 255, 0.6)"},right:{position:"absolute",top:"0",bottom:"0",right:"0",backgroundColor:"rgba(255, 255, 0, 0.2)",borderLeft:"2px dashed rgba(255, 255, 0, 0.6)"},label:{position:"absolute",fontSize:"10px",fontFamily:"monospace",color:"white",backgroundColor:"rgba(0, 0, 0, 0.7)",padding:"2px 4px",borderRadius:"2px"}},wi=class o{#e;#n;#i=!1;#o=null;#s=null;#a=null;#l=null;#d=null;#f=null;#t=null;#u=null;#r=!1;#b=new Map;#g=!1;#c=new Map;#S=!1;static#C={};#M=!1;#p=null;#m=null;#y=null;#v=null;constructor(e,t){this.#e=e,this.#n=t}showCameraTargets(){this.#i||(this.#i=!0,this.#A(),this.#R())}hideCameraTargets(){this.#i&&(this.#i=!1,this.#F(),this.#T())}setFocusOnPointCloud(e,t,r){!this.#i&&!this.#r||(this.#i&&(this.#d=e.map(n=>n.clone()),this.#P()),this.#B(e,t,r))}setGetFocusOnTransformPointCloud(e,t,r){!this.#i&&!this.#r||(this.#i&&(this.#f=e.map(n=>n.clone()),this.#P()),this.#B(e,t,r))}setAnimateToPosition(e){this.#i&&(this.#t=e.clone(),this.#P())}#A(){let e=this.#e.container;if(!e)return;this.#o=document.createElement("div"),this.#o.dataset.debugCameraTargets="true",Object.assign(this.#o.style,Tr.container),this.#s=document.createElement("div"),this.#s.dataset.debugType="focusOn",Object.assign(this.#s.style,Tr.focusOnBox),this.#s.style.display="none";let t=document.createElement("span");Object.assign(t.style,Tr.label),t.style.top="-20px",t.style.left="0",t.style.color="orange",t.textContent="focusOn",this.#s.appendChild(t),this.#a=document.createElement("div"),this.#a.dataset.debugType="getFocusOnTransform",Object.assign(this.#a.style,Tr.getFocusOnTransformBox),this.#a.style.display="none";let r=document.createElement("span");Object.assign(r.style,Tr.label),r.style.top="-20px",r.style.left="0",r.style.color="cyan",r.textContent="getFocusOnTransform",this.#a.appendChild(r),this.#l=document.createElement("div"),this.#l.dataset.debugType="animateTo",Object.assign(this.#l.style,Tr.animateToBox),this.#l.style.display="none";let n=document.createElement("span");Object.assign(n.style,Tr.label),n.style.top="-20px",n.style.left="50%",n.style.transform="translateX(-50%)",n.style.color="lime",n.textContent="animateTo",this.#l.appendChild(n),this.#o.appendChild(this.#s),this.#o.appendChild(this.#a),this.#o.appendChild(this.#l),e.appendChild(this.#o)}#T(){this.#o&&(this.#o.remove(),this.#o=null),this.#s=null,this.#a=null,this.#l=null}#R(){this.#u=this.#e.on("post-render",()=>{this.#P()})}#F(){this.#u!==null&&(this.#u(),this.#u=null)}#_(e){let t=1/0,r=1/0,n=-1/0,i=-1/0,s=new V;for(let a of e)this.#e.project(s,a),s.x!==-1e3&&(t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y));return t!==1/0?{minX:t,minY:r,maxX:n,maxY:i}:null}#w(e,t){if(!t||t.length===0){e.style.display="none";return}let r=this.#_(t);r?(e.style.display="block",e.style.left=`${r.minX}px`,e.style.top=`${r.minY}px`,e.style.width=`${r.maxX-r.minX}px`,e.style.height=`${r.maxY-r.minY}px`):e.style.display="none"}#P(){if(!(!this.#i||!this.#o))if(this.#s&&this.#w(this.#s,this.#d),this.#a&&this.#w(this.#a,this.#f),this.#l&&this.#t){let e=new V;this.#e.project(e,this.#t),e.x!==-1e3?(this.#l.style.display="block",this.#l.style.left=`${e.x}px`,this.#l.style.top=`${e.y}px`):this.#l.style.display="none"}else this.#l&&(this.#l.style.display="none")}showFocusOnDebug(e){if(e===!1){this.hideFocusOnDebug();return}this.#D(this.#b),this.#D(this.#c),this.#r=!0,this.#g=e.pointCloud===!1?!1:{size:e.pointCloud?.size??2,color:e.pointCloud?.color??"lime"},this.#S=e.boundingBox===!1?!1:{color:e.boundingBox?.color??"lime"}}hideFocusOnDebug(){this.#r&&(this.#r=!1,this.#g=!1,this.#S=!1,this.#D(this.#b),this.#D(this.#c))}#B(e,t,r){if(!this.#r)return;let n=t??o.#C;this.#g!==!1&&this.#k(e,n,r),this.#S!==!1&&this.#G(e,n,r)}#k(e,t,r){let n=this.#e.getThreeScene();if(!n||e.length===0){this.#E(this.#b,t);return}if(this.#g===!1)return;let{size:i,color:s}=this.#g,a=r??s,l=this.#b.get(t);if(!l||l.count!==e.length){this.#E(this.#b,t);let d=new Vr(i,8,6),u=new Be({color:a,depthTest:!1,transparent:!0,opacity:.3});l=new re(d,u,e.length),l.renderOrder=9999,n.add(l),this.#b.set(t,l)}let c=new Je;for(let d=0;d<e.length;d++)c.position.copy(e[d]),c.updateMatrix(),l.setMatrixAt(d,c.matrix);l.instanceMatrix.needsUpdate=!0,this.#e.render()}#E(e,t){let r=e.get(t);r&&(this.#e.getThreeScene()?.remove(r),r.geometry.dispose(),r.material.dispose(),e.delete(t))}#D(e){let t=this.#e.getThreeScene();for(let r of e.values())t?.remove(r),r.geometry.dispose(),r.material.dispose();e.clear()}#G(e,t,r){let n=this.#e.getThreeScene();if(!n||e.length===0){this.#E(this.#c,t);return}if(this.#S===!1)return;let i=r??this.#S.color,s=this.#e.getThreeCamera(),a=s.matrixWorldInverse,l=e.map(b=>b.clone().applyMatrix4(a)),c=new de().setFromPoints(l),d=c.getSize(new O),u=c.getCenter(new O),h=new K().copy(a).invert(),v=u.applyMatrix4(h),f=new kr().setFromRotationMatrix(s.matrixWorld);this.#E(this.#c,t);let M=new Zt(d.x,d.y,d.z),p=new zo(M);M.dispose();let m=new zr({color:i,depthTest:!1,transparent:!0,opacity:.5}),g=new Xt(p,m);g.position.copy(v),g.quaternion.copy(f),g.renderOrder=9999,n.add(g),this.#c.set(t,g),this.#e.render()}showScreenOffsets(){this.#M||(this.#M=!0,this.#I())}hideScreenOffsets(){this.#M&&(this.#M=!1,this.#N())}#I(){let e=this.#e.container;if(!e)return;this.#p=document.createElement("div"),this.#p.dataset.debugScreenOffsets="true",Object.assign(this.#p.style,ol.container);let t=r=>{let n=document.createElement("div");n.dataset.debugOffset=r,Object.assign(n.style,ol[r]);let i=document.createElement("span");switch(Object.assign(i.style,ol.label),i.dataset.debugLabel=r,r){case"top":i.style.bottom="4px",i.style.left="50%",i.style.transform="translateX(-50%)";break;case"bottom":i.style.top="4px",i.style.left="50%",i.style.transform="translateX(-50%)";break;case"left":i.style.right="4px",i.style.top="50%",i.style.transform="translateY(-50%)";break;case"right":i.style.left="4px",i.style.top="50%",i.style.transform="translateY(-50%)";break}return n.appendChild(i),n};this.#m={top:t("top"),bottom:t("bottom"),left:t("left"),right:t("right")},this.#p.appendChild(this.#m.top),this.#p.appendChild(this.#m.bottom),this.#p.appendChild(this.#m.left),this.#p.appendChild(this.#m.right),e.appendChild(this.#p),this.#O(),this.#v=this.#n.on("padding-change",()=>{this.#O()}),this.#y=new ResizeObserver(()=>{this.#O()}),this.#y.observe(e)}#N(){this.#v&&(this.#v(),this.#v=null),this.#y&&(this.#y.disconnect(),this.#y=null),this.#p&&(this.#p.remove(),this.#p=null),this.#m=null}#O(){if(!this.#m||!this.#p)return;let e=this.#n.insetsPadding,t=this.#e.container,r=t.clientWidth,n=t.clientHeight,i=Qt(e,r,n),s=this.#m.top,a=s.querySelector("[data-debug-label]");i.top>0?(s.style.height=`${i.top}px`,s.style.display="block",a&&(a.textContent=`top: ${this.#x(e.top,e.type)}`)):s.style.display="none";let l=this.#m.bottom,c=l.querySelector("[data-debug-label]");i.bottom>0?(l.style.height=`${i.bottom}px`,l.style.display="block",c&&(c.textContent=`bottom: ${this.#x(e.bottom,e.type)}`)):l.style.display="none";let d=this.#m.left,u=d.querySelector("[data-debug-label]");i.left>0?(d.style.height="",d.style.top=`${i.top}px`,d.style.bottom=`${i.bottom}px`,d.style.width=`${i.left}px`,d.style.display="block",u&&(u.textContent=`left: ${this.#x(e.left,e.type)}`)):d.style.display="none";let h=this.#m.right,v=h.querySelector("[data-debug-label]");i.right>0?(h.style.height="",h.style.top=`${i.top}px`,h.style.bottom=`${i.bottom}px`,h.style.width=`${i.right}px`,h.style.display="block",v&&(v.textContent=`right: ${this.#x(e.right,e.type)}`)):h.style.display="none"}#x(e,t){return t==="portion"?`${(e*100).toFixed(1)}%`:`${e}px`}destroy(){this.hideCameraTargets(),this.hideScreenOffsets(),this.hideFocusOnDebug()}};var eg=0,tg=90,rg=(E.env.NODE_ENV==="test",!1),Ei={linear:yr.Linear.None,"ease-in":yr.Quadratic.In,"ease-out":yr.Quadratic.Out,"ease-in-out":yr.Quadratic.InOut},ng=-50,Di=class extends q{#e;#n;#i;#o;constructor(e,t,r){super(),this.#e=e,this.#n=t,this.#i=r,this.#o=new wi(e,this),this.#e.map&&this.#e.map.transform.setMinElevationForCurrentTile(ng),this.#n.cameraSystem.on("pedestal-change",({pedestal:n})=>{this.#n.cameraSystem.setCameraPlaneElevation(n),this.#e.mode==="outdoors-overlay"&&typeof this.#e.map?.setCenterElevation=="function"&&this.#e.map.setCenterElevation(this.#n.cameraSystem.getPedestal())})}get center(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map.getCenter?.().toArray():this.#n.cameraSystem.center}setCenter(e){if(this.#e.mode==="outdoors-overlay"&&this.#e.map){this.#e.map?.setCenter(e),this.#n.interactionSystem.handleHover();return}this.#n.cameraSystem.setCenter(e[0],e[1]),this.#n.interactionSystem.handleHover()}get zoomLevel(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getZoom():this.#n.cameraSystem.getZoomLevel()}setZoomLevel(e){this.#e.mode==="outdoors-overlay"&&this.#e.map&&this.#e.map?.setZoom(e),this.#n.cameraSystem.setZoomLevel(ot(e,this.minZoomLevel,this.maxZoomLevel,"zoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMinZoomLevel() and mapView.Camera.setMaxZoomLevel() to adjust limits."))}getState(){return{zoomLevel:this.zoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,minPitch:this.minPitch,maxPitch:this.maxPitch,autoMinZoomLevel:this.autoMinZoomLevel,panMode:this.panMode,screenOffsets:this.insetsPadding,center:this.center,bearing:this.bearing,pitch:this.pitch,elevation:this.elevation}}get isAnimating(){return this.#n.cameraSystem.isAnimating}cancelAnimation(){this.#n.cameraSystem.cancelAnimation()}get maxZoomLevel(){return this.#n.cameraSystem.maxZoomLevel}get minZoomLevel(){return this.#n.cameraSystem.minZoomLevel}setAutoMinZoomLevel(e){this.#n.panBoundsSystem.autoMinZoomLevel=e,e&&(this.#n.panBoundsSystem.dirty=!0,this.#n.panBoundsSystem.update())}get autoMinZoomLevel(){return this.#n.panBoundsSystem.autoMinZoomLevel}setMinZoomLevel(e,t=!1){t&&this.setAutoMinZoomLevel(!1);let r=ot(e,ct.MIN_MERCATOR_ZOOM_LEVEL,this.maxZoomLevel,`setMinZoomLevel was clamped. minZoomLevel must be between ${ct.MIN_MERCATOR_ZOOM_LEVEL} and maxZoomLevel.`);this.#n.cameraSystem.setMinZoomLevel(r),this.zoomLevel<r&&this.setZoomLevel(r),this.#e.map?.setMinZoom(r)}setMaxZoomLevel(e){let t=ot(e,this.minZoomLevel,ct.MAX_MERCATOR_ZOOM_LEVEL,`setMaxZoomLevel was clamped. maxZoomLevel must be between minZoomLevel and ${ct.MAX_MERCATOR_ZOOM_LEVEL}.`);this.#n.cameraSystem.setMaxZoomLevel(t),this.zoomLevel>t&&this.setZoomLevel(t),this.#e.map?.setMaxZoom(t)}get maxPitch(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getMaxPitch?.():W.radToDeg(this.#n.cameraSystem.maxTilt)}get minPitch(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getMinPitch?.():W.radToDeg(this.#n.cameraSystem.minTilt)}setMinPitch(e){let t=Math.max(eg,e);this.#e.map?.setMinPitch(t),this.#n.cameraSystem.minTilt=W.degToRad(t)}setMaxPitch(e){let t=Math.min(tg,e);this.#e.map?.setMaxPitch(t),this.#n.cameraSystem.maxTilt=W.degToRad(t)}get bearing(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getBearing():W.radToDeg(this.#n.cameraSystem.getRotation())}setBearing(e){if(this.#e.mode==="outdoors-overlay"&&this.#e.map){this.#e.map?.setBearing(e);return}this.#n.cameraSystem.setRotation(W.degToRad(e))}get pitch(){return this.#e.mode==="outdoors-overlay"&&this.#e.map?this.#e.map?.getPitch():W.radToDeg(this.#n.cameraSystem.getTilt())}setPitch(e){if(this.#e.mode==="outdoors-overlay"&&this.#e.map){this.#e.map?.setPitch(e);return}this.#n.cameraSystem.setTilt(W.degToRad(ot(e,this.minPitch,this.maxPitch,"pitch was clamped to minPitch/maxPitch bounds. Use mapView.Camera.setMinPitch() and mapView.Camera.setMaxPitch() to adjust limits.")))}get elevation(){return this.#n.cameraSystem.getPedestal()}get maxElevation(){return this.#n.cameraSystem.maxPedestal}setMaxElevation(e){this.#n.cameraSystem.maxPedestal=e,this.elevation>e&&this.setElevation(e)}setElevation(e){let t=ot(e,-1/0,this.maxElevation,"elevation was clamped to maxElevation. Use mapView.Camera.setMaxElevation() to adjust the limit.");this.#n.cameraSystem.setPedestal(t,!0)}#s;animateElevation(e,t){this.#s&&this.#s.stop();let r=ot(e,-1/0,this.maxElevation,"animateElevation was clamped to maxElevation. Use mapView.Camera.setMaxElevation() to adjust the limit.");return new Promise(n=>{this.#n.cameraSystem.animateCamera({position:{z:r}},t?.duration||300,Ei[t?.easing||"ease-in-out"],n,n,{interruptible:t?.interruptible??!0})})}get insetsPadding(){return this.#i.insetsPadding}get panMode(){return this.#n.cameraSystem.enablePan===!1&&this.#n.cameraSystem.enablePedestal===!0?"elevation":"default"}setPanMode(e){if(e!=="default"&&e!=="elevation")throw new Error("Invalid pan mode");e!==this.panMode&&(e==="default"?(this.#n.cameraSystem.enablePan=!0,this.#n.cameraSystem.enablePedestal=!1):(this.#n.cameraSystem.enablePan=!1,this.#n.cameraSystem.enablePedestal=!0))}setInsetPadding(e){let t=this.#i.insetsPadding;Object.keys(e).every(r=>e[r]===t[r])||(this.#i.insetsPadding=Object.assign({},t,e),this.publish("padding-change",{padding:this.#i.insetsPadding}))}animateTo(e){let t=e.center?this.#e.convertTo3DMapPosition(e.center[1],e.center[0],e.center[2]||this.elevation):void 0;if(t&&this.#o.setAnimateToPosition(t),this.#e.mode==="outdoors-overlay"&&this.#e.map)return this.#e.map?.flyTo({center:e.center??this.center,zoom:e.zoomLevel??this.zoomLevel,bearing:e.bearing??this.bearing,pitch:e.pitch??this.pitch,duration:e.duration??600}),Promise.resolve();let r=e.zoomLevel!==void 0?this.#n.cameraSystem.convertZoomLevelToAltitude(ot(e.zoomLevel,this.minZoomLevel,this.maxZoomLevel,"zoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMinZoomLevel() and mapView.Camera.setMaxZoomLevel() to adjust limits.")):void 0,n=e.bearing!==void 0?W.degToRad(e.bearing):void 0,i=e.pitch!==void 0?W.degToRad(ot(e.pitch,this.minPitch,this.maxPitch,"pitch was clamped to minPitch/maxPitch bounds. Use mapView.Camera.setMinPitch() and mapView.Camera.setMaxPitch() to adjust limits.")):void 0;return new Promise(s=>{this.#n.cameraSystem.animateCamera({position:t,zoom:r,rotation:n,tilt:i},e.duration||0,Ei[e.easing||"ease-in-out"],()=>{this.#n.interactionSystem.handleHover(),s()},s,{interruptible:e?.interruptible??!0})})}getCameraFrameForCoordinates(e,t){let r=this.#a(t||{},()=>Promise.resolve()),{pointCloud:n}=ju(e,this.#e,this.#i.geometry3DMap);if(n.length===0)return R.error("No valid coordinates found in targets:",e),{center:this.center,zoomLevel:this.zoomLevel};this.#o.setGetFocusOnTransformPointCloud(n,t?.debugKey,t?.debugColor);let{center:i,zoomLevel:s}=this.#n.cameraSystem.getCameraFrameForCoordinates(n,r);return{center:this.#e.convert3DMapPositionToCoordinate(i),zoomLevel:s}}#a(e,t){return{minZoom:e?.maxZoomLevel===void 0?void 0:this.#n.cameraSystem.convertZoomLevelToAltitude(ot(e.maxZoomLevel,this.minZoomLevel,this.maxZoomLevel,"maxZoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMaxZoomLevel() to adjust limits.")),maxZoom:e?.minZoomLevel===void 0?void 0:this.#n.cameraSystem.convertZoomLevelToAltitude(ot(e.minZoomLevel,this.minZoomLevel,this.maxZoomLevel,"minZoomLevel was clamped to minZoomLevel/maxZoomLevel bounds. Use mapView.Camera.setMinZoomLevel() to adjust limits.")),padding:e?.padding?Object.assign({},An,e?.padding):this.insetsPadding,curve:Ei[e?.easing||"ease-in-out"],rotation:e?.bearing===void 0?void 0:W.degToRad(e.bearing),tilt:e?.pitch!==void 0?W.degToRad(ot(e.pitch,this.minPitch,this.maxPitch,"pitch was clamped to minPitch/maxPitch bounds. Use mapView.Camera.setMinPitch() and mapView.Camera.setMaxPitch() to adjust limits.")):void 0,duration:e?.duration,callback:()=>{this.#n.interactionSystem.handleHover(),t()},cancelledCallback:t,interruptible:e?.interruptible??!0,verticalPadding:e?.verticalPadding}}focusOn(e,t){let{pointCloud:r,geoBounds:n,firstPosition:i}=ju(e,this.#e,this.#i.geometry3DMap);if(r.length===0)return R.error("No valid coordinates found in targets:",e),Promise.resolve();if(this.#o.setFocusOnPointCloud(r,t?.debugKey,t?.debugColor),this.#e.mode==="outdoors-overlay"&&this.#e.map){let s=Qt(t?.padding?Object.assign({},An,t.padding):this.insetsPadding,this.#e.canvasWidth,this.#e.canvasHeight),a={top:s.top,bottom:s.bottom,left:s.left,right:s.right};return r.length===1&&i?this.#e.map?.flyTo({center:[i[0],i[1]],duration:t?.duration??ct.DEFAULT_ANIMATION_DURATION,animate:!0,padding:a,bearing:t?.bearing===void 0?this.#e.map.getBearing():t?.bearing,pitch:t?.pitch===void 0?this.#e.map.getPitch():t?.pitch,zoom:t?.maxZoomLevel||this.#e.map.getMaxZoom()}):(rg&&og(this.#e,n),this.#e.map?.fitBounds(n,{duration:t?.duration??ct.DEFAULT_ANIMATION_DURATION,padding:a,bearing:t?.bearing===void 0?this.#e.map.getBearing():t?.bearing,pitch:t?.pitch===void 0?this.#e.map.getPitch():t?.pitch,maxZoom:t?.maxZoomLevel??this.#e.map.getMaxZoom()})),this.#n.interactionSystem.handleHover(),Promise.resolve()}return new Promise(s=>{this.#n.cameraSystem.focusOn(r,this.#a(t||{},s))})}showCameraTargetsDebug(){this.#o.showCameraTargets()}hideCameraTargetsDebug(){this.#o.hideCameraTargets()}showFocusOnDebug(e){this.#o.showFocusOnDebug(e)}hideFocusOnDebug(){this.#o.hideFocusOnDebug()}showScreenOffsetsDebug(){this.#o.showScreenOffsets()}hideScreenOffsetsDebug(){this.#o.hideScreenOffsets()}destroy(){this.#o.destroy(),super.destroy()}};function il(o,e){o[0]=Math.min(o[0],e[0]),o[1]=Math.min(o[1],e[1]),o[2]=Math.max(o[2],e[0]),o[3]=Math.max(o[3],e[1])}function ju(o,e,t){let r=[],n=[1/0,1/0,-1/0,-1/0],i=null;if(!o||!Array.isArray(o)||o.length===0)return{pointCloud:r,geoBounds:n,firstPosition:i};let s=e.getSystems().renderSystem;for(let a of o)if(typeof a=="string"){(s.threeDdirty||s.twoDdirty)&&e.renderSync();let l=t.get(a);if(!l){R.error("Entity not found with id:",a);continue}let c=new de;Td(e,"userData"in l?l.userData.entityId??l.id:l.id,r,c,l instanceof he?l.position.z:void 0);let d=e.convert3DMapPositionToCoordinate(c.min),u=e.convert3DMapPositionToCoordinate(c.max);il(n,d),il(n,u),i||(i=e.convert3DMapPositionToCoordinate(c.getCenter(new O)))}else r.push(e.convertTo3DMapPosition(a[1],a[0],a[2]||0)),il(n,a),i||(i=a);return{pointCloud:r,geoBounds:n,firstPosition:i}}function og(o,e){let t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]],[e[0],e[1]]];o.map?.getLayer("bounds-outline")&&o.map.removeLayer("bounds-outline"),o.map?.getSource("bounds-source")&&o.map.removeSource("bounds-source"),o.map?.addSource("bounds-source",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}}}),o.map?.addLayer({id:"bounds-outline",type:"line",source:"bounds-source",layout:{},paint:{"line-color":"#FF0000","line-width":2,"line-opacity":.8}})}y();y();var Zu=`uniform vec4 uSize;
8
- varying vec2 vUv;
9
- void main() {
10
- vUv = uv;
11
- // Scale the position by the size of the quad
12
- // and shift to top left corner for 0,0
13
- vec2 transformed = position.xy * uSize.xy - vec2(1.0, -1.0);
14
- // Apply width .x and height .y of image
15
- transformed += vec2(uSize.x, -uSize.y);
16
- // Apply left .w and top .z offset
17
- transformed += vec2(uSize.w, -uSize.z) * 2.0;
18
- gl_Position = vec4(transformed, 1.0, 1.0);
19
- }`;y();var Xu=`varying vec2 vUv;
20
- uniform sampler2D uTexture;
21
- uniform float uOpacity;
22
- void main() {
23
- #ifndef debug
24
- vec4 texture = texture2D(uTexture, vUv);
25
- gl_FragColor = vec4(texture.rgb, texture.a * uOpacity);
26
- #else
27
- gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
28
- #endif
29
- }`;y();var Yu=4.291666666666667,$u=15,qu=25,Ju=43/60;y();var Ku=["horizontal","icon"],ig=new Map([[Ku[0],`<svg viewBox="0 0 206 48">
30
- <path d="M27.2678 14.2261H22.3187C21.0695 14.2261 20.4695 14.7801 20.4695 15.9852V31.142L10.3966 15.5591C9.69665 14.4784 9.2475 14.2773 7.8475 14.2261H2.97462C1.67462 14.2261 1.07631 14.7801 1.07631 15.9852V44.7665C1.07631 45.9716 1.67462 46.5256 2.97462 46.5256H7.92377C9.22207 46.5256 9.82207 45.9716 9.82207 44.7665V29.6847L19.9441 45.1926C20.695 46.3244 21.095 46.5256 22.4933 46.5256H27.2933C28.5916 46.5256 29.1916 45.9716 29.1916 44.7665V15.9852C29.1407 14.7801 28.5424 14.2261 27.2678 14.2261Z"/>
31
- <path d="M5.44915 10.9602C8.45863 10.9602 10.8983 8.50669 10.8983 5.48011C10.8983 2.45353 8.45863 0 5.44915 0C2.43967 0 0 2.45353 0 5.48011C0 8.50669 2.43967 10.9602 5.44915 10.9602Z"/>
32
- <path d="M61.7899 25.0449C63.2306 23.1903 65.078 22.2051 67.556 22.2051C72.0526 22.2051 74.7611 25.3347 74.7611 29.4511V39.2489C74.8187 39.7125 74.5306 39.9443 74.0695 39.9443H72.5136C72.0526 39.9443 71.7645 39.7125 71.8221 39.2489V29.5091C71.8221 27.1909 69.9187 25.2187 67.4984 25.2187C65.1339 25.2187 63.2323 27.1329 63.2323 29.2773V39.2489C63.2899 39.7125 63.0018 39.9443 62.5407 39.9443H60.9831C60.5221 39.9443 60.2916 39.7125 60.2916 39.2489V29.4511C60.2916 27.1329 58.3899 25.2187 56.0255 25.2187C53.7204 25.2187 51.7594 27.075 51.7594 29.2773V39.3068C51.817 39.7705 51.5289 40.0023 51.0102 40.0023H49.5119C49.0509 40.0023 48.7628 39.7705 48.7628 39.3068V23.25C48.7051 22.7864 48.9933 22.4966 49.5119 22.4966H50.9526C51.356 22.4966 51.5289 22.6704 51.5289 23.0182V24.2352C52.7407 22.9602 54.239 22.2648 56.0255 22.2648C58.4475 22.2068 60.3492 23.192 61.7899 25.0466V25.0449ZM77.1255 31.2477C77.1255 26.3216 81.1018 22.2051 86.1187 22.2051C88.539 22.2051 90.6136 23.1903 92.3441 25.1608V23.1903C92.3441 22.7267 92.5746 22.5528 93.0357 22.5528H94.4187C94.8797 22.5528 95.1102 22.7847 95.1102 23.3062V39.3648C95.1102 39.8284 94.8797 40.0602 94.4187 40.0602H93.0357C92.5746 40.0602 92.3441 39.8284 92.3441 39.4227V37.4523C90.6712 39.3648 88.5967 40.35 86.1746 40.35C81.1018 40.2341 77.1238 36.1773 77.1238 31.2477H77.1255ZM92.1136 31.2477C92.1136 27.8284 89.4611 25.2187 86.0594 25.2187C82.7746 25.2187 80.1221 27.8864 80.1221 31.2477C80.1221 34.6687 82.7746 37.2784 86.1187 37.2784C86.9062 37.2789 87.6861 37.1232 88.4138 36.8202C89.1414 36.5173 89.8026 36.0731 90.3593 35.513C90.9161 34.9528 91.3577 34.2878 91.6587 33.556C91.9597 32.8241 92.1143 32.0397 92.1136 31.2477ZM100.992 37.3943V46.3807C101.049 46.8443 100.761 47.1341 100.298 47.1341H98.7424C98.2814 47.1341 97.9933 46.9023 97.9933 46.3807V23.1903C97.9933 22.7267 98.2238 22.4369 98.7424 22.4369H100.183C100.646 22.379 100.934 22.6687 100.934 23.0744V24.9869C102.605 23.0744 104.68 22.1472 107.044 22.1472C112.002 22.1472 116.037 26.2619 116.037 31.1898C116.037 36.1176 112.059 40.2341 107.044 40.2341C104.622 40.2341 102.603 39.3068 100.992 37.3943ZM106.987 25.2187C103.7 25.2187 101.049 27.8864 101.049 31.2477C101.049 34.6687 103.7 37.2784 107.044 37.2784C110.446 37.2784 113.039 34.6108 113.039 31.2477C113.039 27.8864 110.388 25.2187 106.987 25.2187ZM121.11 37.3943V46.3807C121.168 46.8443 120.88 47.1341 120.419 47.1341H118.861C118.4 47.1341 118.112 46.9023 118.112 46.3807V23.1903C118.112 22.7267 118.342 22.4369 118.861 22.4369H120.302C120.764 22.379 121.053 22.6687 121.053 23.0744V24.9869C122.724 23.0744 124.798 22.1472 127.163 22.1472C132.12 22.1472 136.156 26.2619 136.156 31.1898C136.156 36.1176 132.178 40.2341 127.163 40.2341C124.742 40.2341 122.781 39.3068 121.11 37.3943ZM127.105 25.2187C123.819 25.2187 121.168 27.8864 121.168 31.2477C121.168 34.6687 123.819 37.2784 127.163 37.2784C130.564 37.2784 133.158 34.6108 133.158 31.2477C133.158 27.8864 130.507 25.2187 127.107 25.2187H127.105ZM153.97 32.3506H141.054C141.342 35.2483 143.995 37.4523 147.164 37.4523C148.893 37.4523 150.393 37.0466 151.719 36.0597C152.007 35.8858 152.295 35.7699 152.353 35.7699C152.583 35.7699 152.756 35.8858 152.929 36.1773L153.505 37.1625C153.622 37.3364 153.68 37.4523 153.68 37.5682C153.68 37.8 153.507 38.0318 153.103 38.3216C151.258 39.5966 149.183 40.292 146.992 40.292C141.688 40.292 137.883 36.3511 137.883 31.2477C137.883 26.204 141.803 22.2051 146.703 22.2051C151.546 22.2051 154.717 25.7983 154.717 31.0176C154.717 31.5972 154.717 32.3506 153.968 32.3506H153.97ZM141.056 30.0324H151.72C151.432 26.8432 149.473 24.929 146.648 24.929C145.241 24.8904 143.875 25.3995 142.833 26.3501C141.791 27.3007 141.154 28.6194 141.056 30.0307V30.0324ZM156.332 31.2477C156.332 26.3216 160.31 22.2051 165.326 22.2051C167.748 22.2051 169.707 23.1324 171.32 25.0449V16.2324C171.263 15.7687 171.551 15.479 172.012 15.479H173.57C174.031 15.479 174.319 15.7108 174.319 16.2324V39.3068C174.319 39.7705 174.088 40.0023 173.57 40.0023H172.129C171.666 40.0602 171.378 39.7705 171.378 39.3648V37.3943C169.649 39.3068 167.632 40.292 165.268 40.292C160.31 40.2341 156.332 36.1773 156.332 31.2477ZM171.264 31.2477C171.264 27.8284 168.612 25.2187 165.21 25.2187C161.924 25.2187 159.273 27.8864 159.273 31.2477C159.273 34.6687 161.924 37.2784 165.268 37.2784C166.057 37.2838 166.839 37.1316 167.569 36.8304C168.299 36.5292 168.962 36.0852 169.52 35.5241C170.077 34.963 170.519 34.296 170.818 33.5619C171.117 32.8277 171.268 32.0411 171.263 31.2477H171.264ZM177.72 19.0739C177.715 18.8594 177.754 18.646 177.833 18.4468C177.912 18.2476 178.031 18.0667 178.182 17.915C178.333 17.7633 178.512 17.6439 178.71 17.5642C178.909 17.4845 179.121 17.446 179.334 17.4511C179.546 17.4507 179.756 17.4923 179.952 17.5737C180.148 17.6551 180.326 17.7746 180.476 17.9254C180.626 18.0762 180.745 18.2553 180.826 18.4523C180.907 18.6494 180.948 18.8606 180.948 19.0739C180.953 19.2884 180.914 19.5017 180.835 19.7009C180.756 19.9001 180.637 20.081 180.486 20.2327C180.335 20.3845 180.156 20.5038 179.957 20.5835C179.759 20.6633 179.547 20.7017 179.334 20.6966C178.412 20.7545 177.72 20.0591 177.72 19.0739ZM177.836 39.2489V23.1903C177.836 22.7267 178.066 22.4369 178.527 22.4369H180.083C180.544 22.4369 180.832 22.6687 180.775 23.1903V39.2489C180.832 39.7125 180.544 39.9443 180.083 39.9443H178.527C178.066 39.9443 177.836 39.7125 177.836 39.2489ZM186.944 23.0165V24.1756C188.212 22.8426 189.71 22.2051 191.497 22.2051C195.937 22.2051 198.646 25.2767 198.646 29.3932V39.2489C198.703 39.7125 198.415 39.9443 197.954 39.9443H196.398C195.936 39.9443 195.705 39.7125 195.705 39.2489V29.4511C195.705 27.1329 193.803 25.2187 191.439 25.2187C189.134 25.2187 187.175 27.075 187.175 29.2773V39.3068C187.232 39.7705 186.944 40.0023 186.424 40.0023H184.868C184.407 40.0023 184.119 39.7705 184.119 39.3068V23.1903C184.061 22.7267 184.349 22.4949 184.868 22.4949H186.309C186.712 22.4949 186.944 22.6687 186.944 23.0165Z"/>
33
- <path d="M204 40C205.115 40 206 39.0857 206 38V37.9886C206 36.9029 205.126 36 204 36C202.885 36 202 36.9143 202 38V38.0114C202 39.0971 202.874 40 204 40ZM204 39.7829C202.989 39.7829 202.23 38.9829 202.23 38.0114V38C202.23 37.0286 203 36.2171 204 36.2171C205.011 36.2171 205.77 37.0171 205.77 37.9886V38C205.77 38.9714 205 39.7829 204 39.7829ZM203.218 38.9714H203.609V38.2743H204.034L204.517 38.9714H204.989L204.448 38.2057C204.724 38.1257 204.92 37.92 204.92 37.5886C204.92 37.1657 204.586 36.9486 204.138 36.9486H203.218V38.9714ZM203.609 37.9543V37.2914H204.103C204.368 37.2914 204.517 37.4057 204.517 37.6229C204.517 37.8171 204.368 37.9543 204.103 37.9543H203.609Z"/>
34
- </svg>`],[Ku[1],`<svg viewBox="0 0 43 60">
35
- <path d="M14.0291 7.06645C14.0291 10.9691 10.8885 14.1329 7.01453 14.1329C3.14051 14.1329 0 10.9691 0 7.06645C0 3.16376 3.14051 0 7.01453 0C10.8885 0 14.0291 3.16376 14.0291 7.06645Z"/>
36
- <path d="M28.7335 18.3468H35.1045C36.7455 18.3468 37.5178 19.0599 37.5821 20.6158V57.7309C37.5821 59.2868 36.8099 60 35.1367 60H28.9588C27.1569 60 26.642 59.7406 25.6767 58.282L12.6452 38.282V57.7309C12.6452 59.2868 11.8729 60 10.1997 60H3.82873C2.15554 60 1.3833 59.2868 1.3833 57.7309V20.6158C1.3833 19.0599 2.15554 18.3468 3.82873 18.3468H10.1032C11.9051 18.4116 12.4843 18.671 13.3852 20.0648L26.3524 40.162V20.6158C26.3524 19.0599 27.1247 18.3468 28.7335 18.3468Z"/>
37
- <path d="M41.5 60C42.3362 60 43 59.3143 43 58.5V58.4914C43 57.6771 42.3448 57 41.5 57C40.6638 57 40 57.6857 40 58.5V58.5086C40 59.3229 40.6552 60 41.5 60ZM41.5 59.8371C40.7414 59.8371 40.1724 59.2371 40.1724 58.5086V58.5C40.1724 57.7714 40.75 57.1629 41.5 57.1629C42.2586 57.1629 42.8276 57.7629 42.8276 58.4914V58.5C42.8276 59.2286 42.25 59.8371 41.5 59.8371ZM40.9138 59.2286H41.2069V58.7057H41.5259L41.8879 59.2286H42.2414L41.8362 58.6543C42.0431 58.5943 42.1897 58.44 42.1897 58.1914C42.1897 57.8743 41.9397 57.7114 41.6034 57.7114H40.9138V59.2286ZM41.2069 58.4657V57.9686H41.5776C41.7759 57.9686 41.8879 58.0543 41.8879 58.2171C41.8879 58.3629 41.7759 58.4657 41.5776 58.4657H41.2069Z"/>
38
- </svg>`]]),sg=/<svg([^>]*)>/g;function Qu(o,e,t,r){let n=ig.get(o);return n?n.replace(sg,`<svg$1 width="${t}" height="${r}" xmlns="http://www.w3.org/2000/svg" fill="${e}">`):""}y();var sl=class o{static instance;loader;constructor(){this.loader=new Uo}static getInstance(){return o.instance||(o.instance=new o),o.instance}getLoader(){return this.loader}load(e){return new Promise((t,r)=>{this.loader.load(e,t,void 0,r)})}},er=sl.getInstance();var eh=!1,Ti=class extends q{#e={padding:16,scale:1,iconOnly:!1,position:"bottom-left",color:"dark",onClick:()=>{window?.open("https://www.mappedin.com")},interactive:!0,visible:!0};#n;#i;#o;#s=void 0;#a=void 0;#l=0;#d=0;dirty=!0;get color(){return this.#e.color==="light"?"white":"#293136"}get iconName(){return this.#e.iconOnly?"icon":"horizontal"}get minWidth(){return this.#e.iconOnly?$u:75}get defaultWidth(){return this.#e.iconOnly?qu:150}get aspectRatio(){return this.#e.iconOnly?Ju:Yu}get options(){return{...this.#e}}set options(e){this.#e={padding:e.padding||this.#e.padding,position:e.position||this.#e.position,iconOnly:e.iconOnly||this.#e.iconOnly,color:e.color||this.#e.color,scale:e.scale||this.#e.scale,onClick:this.#e.onClick,interactive:e.interactive??this.#e.interactive,visible:e.visible??this.#e.visible}}get icon(){return Qu(this.iconName,this.color,this.#l*this.#n.pixelRatio,this.#d*this.#n.pixelRatio)}constructor(e,t,r){super(),r&&Object.entries(r).forEach(([n,i])=>{i!==void 0&&(this.#e[n]=i)}),this.#i=e,this.#n=t}setSize(e,t){this.#s&&(this.#s.uniforms.uSize.value.x=e,this.#s.uniforms.uSize.value.y=t)}setXY(e,t){this.#s&&(this.#s.uniforms.uSize.value.w=e,this.#s.uniforms.uSize.value.z=t)}get width(){return this.#l}get height(){return this.#d}getPositionAlignedOffset(e,t){return{"top-left":{x:0,y:0},"top-right":{x:-e,y:0},"bottom-left":{x:0,y:-t},"bottom-right":{x:-e,y:-t},center:{x:-(e/2),y:-(t/2)},top:{x:-(e/2),y:0},bottom:{x:-(e/2),y:-t},left:{x:0,y:-(t/2)},right:{x:-e,y:-(t/2)}}[this.#e.position]}getPositionAlignedCanvasCoordinates=(e,t)=>({"top-left":{x:0,y:0},"top-right":{x:e,y:0},"bottom-left":{x:0,y:t},"bottom-right":{x:e,y:t},center:{x:e/2,y:t/2},top:{x:e/2,y:0},bottom:{x:e/2,y:t},left:{x:0,y:t/2},right:{x:e,y:t/2}})[this.#e.position];getPositionAlignedPadding=()=>{let e=this.#e.padding;if(typeof e=="number")return{"top-left":{x:e,y:e},"top-right":{x:-e,y:e},"bottom-left":{x:e,y:-e},"bottom-right":{x:-e,y:-e},center:{x:0,y:0},top:{x:0,y:e},bottom:{x:0,y:-e},left:{x:e,y:0},right:{x:-e,y:0}}[this.#e.position];let t={top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0};return{x:t.left-t.right,y:t.top-t.bottom}};insertIntoQuadTree(e){this.#a!=null&&typeof this.#e.onClick=="function"&&this.#e.interactive&&e.insert(this.#a)}resize(e,t){if(this.#e.visible!==!0)return;let r=this.getPositionAlignedCanvasCoordinates(e,t),n=this.getPositionAlignedPadding(),i=this.getPositionAlignedOffset(this.#l,this.#d),s=Math.min(e-this.#l,Math.max(0,r.x+n.x+i.x)),a=Math.min(t-this.#d,Math.max(0,r.y+n.y+i.y));this.setSize(this.#l/e,this.#d/t),this.setXY(s/e,a/t),this.#a=new qt(s,a,this.#l,this.#d,{entityId:"watermark"})}update(){this.dirty&&(this.#e.visible===!0?(this.#l=Math.min(this.#n.canvasWidth,Math.max(this.minWidth,this.defaultWidth*this.#e.scale)),this.#d=this.#l/this.aspectRatio,er.getLoader().load(`data:image/svg+xml;base64,${btoa(this.icon)}`,e=>{if(this.#s=new lt({uniforms:{uTexture:{value:e},uSize:{value:new $c(0,0,0,0)},uOpacity:{value:.7}},vertexShader:Zu,fragmentShader:Xu,depthWrite:!1,depthTest:!1,defines:{debug:eh},wireframe:eh,transparent:!0,visible:!0}),this.#o)this.#o.visible=!0,this.#o.material=this.#s,this.#o.material.needsUpdate=!0;else{let t=new We(2,2,1,1);this.#o=new X(t,this.#s),this.#o.position.set(0,0,-1),this.#o.frustumCulled=!1,this.#o.renderOrder=999;let r=new Zt(1,1,1),n=new X(r,new Be({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1}));n.frustumCulled=!1,n.layers.set(1),this.#o.add(n),this.#i.add(this.#o)}this.resize(this.#n.canvasWidth,this.#n.canvasHeight),this.publish("texture-loaded")})):this.#o&&(this.#o.visible=!1),this.dirty=!1)}destroy(){this.#o&&(this.#i.remove(this.#o),Ce(this.#o)),this.#o=void 0,this.#s&&this.#s.dispose(),this.#s=void 0,this.#a=void 0}};y();var Pi=100,cg=!1,Oi=class extends q{currentTotalBoundingBox;state;cameraSystem;debugMesh=null;dirty=!0;autoMinZoomLevel=!0;constructor(e,t){super(),this.state=e,this.cameraSystem=t}expandBoundsIfOutside(e){if(this.currentTotalBoundingBox==null){this.dirty=!0;return}this.currentTotalBoundingBox.containsPoint(e)||(this.dirty=!0)}update(){if(this.dirty){this.currentTotalBoundingBox==null&&(this.currentTotalBoundingBox=new de,this.state.geometryScene.children.length===0?this.currentTotalBoundingBox.setFromCenterAndSize(new O(0,0,0),new O(Pi*2,Pi*2,0)):(this.currentTotalBoundingBox.setFromObject(this.state.geometryScene),this.currentTotalBoundingBox.expandByScalar(Pi)));let e=new de().setFromObject(this.state.geometryScene);this.currentTotalBoundingBox.union(e);let t=e.getSize(new O),r=Math.max(t.x,t.y,t.z);for(let i of this.state.geometry2DMap.values())i.positionDirty===!0&&(this.currentTotalBoundingBox.expandByPoint(i.position),i.positionDirty=!1);let n=Ii.copy(this.currentTotalBoundingBox).expandByScalar(Math.max(r,Pi)).getBoundingSphere(dg).radius;if(this.cameraSystem.panBounds={center:this.currentTotalBoundingBox.getCenter(new O),min:Ii.min,max:Ii.max,radius:n},this.publish("update"),this.cameraSystem.dirty=!0,this.dirty=!1,cg&&this.state.geometryScene.parent instanceof Rt){this.debugMesh&&(this.state.geometryScene.parent.remove(this.debugMesh),this.debugMesh=null),this.debugMesh=new Je,this.debugMesh.add(new X(new Vr(this.cameraSystem.panBounds.radius),new Be({color:16711680,transparent:!0,opacity:.2}))),this.debugMesh.position.copy(this.cameraSystem.panBounds.center),this.state.geometryScene.parent.add(this.debugMesh);let i=new O;Ii.getSize(i);let s=new Zt(i.x,i.y,i.z),a=new Be({color:65280,wireframe:!0,transparent:!0,opacity:.5}),l=new X(s,a);l.position.copy(this.currentTotalBoundingBox.getCenter(new O)),this.debugMesh.add(l)}}}},Ii=new de,dg=new Pn;y();var al="\xA9 Mappedin",ug="https://info.mappedin.com/feedback",cl=["top-left","top-right","bottom-left","bottom-right"],hg=640,pg=()=>`<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' fill-rule='evenodd' viewBox='0 0 20 20'>
39
- <circle cx='10' cy='10' r='5.9' fill='rgba(255,255,255,1)'/>
40
- <path fill='rgba(0,0,0,0.7)' d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/>
41
- </svg>`,ll={custom:[],position:"bottom-right",feedback:!0},Li=class{controlContainerEl;controlPositions;compact=void 0;#e;attribContainerEl;attribInnerEl;attribButtonEl;feedbackLinkEl;attribHTML=al;customAttributions=[];constructor(e,t={}){this.#e=!!t.outdoorEnabled,this.controlContainerEl=document.createElement("div"),this.controlContainerEl.classList.add("mappedin-control-container"),this.controlContainerEl.style.zIndex="2",e.appendChild(this.controlContainerEl),this.controlPositions=cl.reduce((r,n)=>{let i=document.createElement("div");return i.classList.add(`mappedin-ctrl-${n}`),this.controlContainerEl.appendChild(i),r[n]=i,r},{})}addAttributionControl(e=ll){let t=e.position&&cl.includes(e.position)?e.position:ll.position;this.attribContainerEl=document.createElement("details"),this.attribContainerEl.classList.add("mappedin-ctrl-attrib",`mappedin-ctrl-attrib-${t}`),this.attribContainerEl.open=!0,this.attribContainerEl.ariaLabel="Attribution",this.controlPositions[t].appendChild(this.attribContainerEl),this.attribButtonEl=document.createElement("summary"),this.attribButtonEl.addEventListener("click",this.toggleAttribution),this.attribButtonEl.classList.add("mappedin-ctrl-attrib-button"),this.attribButtonEl.title="Toggle attribution",this.attribButtonEl.ariaLabel="Toggle attribution",this.attribButtonEl.tabIndex=0,this.attribButtonEl.innerHTML=pg(),this.attribContainerEl.appendChild(this.attribButtonEl),this.attribInnerEl=document.createElement("div"),this.attribInnerEl.classList.add("mappedin-ctrl-attrib-inner"),this.attribHTML=this.#e?al:"",this.attribInnerEl.innerHTML=this.attribHTML,this.attribContainerEl.appendChild(this.attribInnerEl),(e.feedback??ll.feedback)&&(this.feedbackLinkEl=document.createElement("a"),this.feedbackLinkEl.href=ug,this.feedbackLinkEl.target="_blank",this.feedbackLinkEl.rel="noopener",this.feedbackLinkEl.textContent="Provide Feedback",this.feedbackLinkEl.classList.add("mappedin-ctrl-attrib-inner"),this.feedbackLinkEl.classList.add("mappedin-ctrl-attrib-inner-bold"),this.attribContainerEl.appendChild(this.feedbackLinkEl)),e.custom&&(this.customAttributions=e.custom),this.updateAttributionDisplay()}toggleAttribution=e=>{this.attribContainerEl!=null&&(e.preventDefault(),this.attribContainerEl.classList.contains("mappedin-compact")&&(this.attribContainerEl.classList.contains("mappedin-compact-show")?(this.attribContainerEl.removeAttribute("open"),this.attribContainerEl.classList.remove("mappedin-compact-show")):(this.attribContainerEl.classList.add("mappedin-compact-show"),this.attribContainerEl.setAttribute("open",""))))};updateAttribution(e){if(!e.style||!this.attribInnerEl||!this.attribContainerEl)return;let t=this.#e?[al]:[],r=e.style.sourceCaches;for(let n in r){let i=r[n];if(i.used||i.usedForTerrain){let s=i.getSource();s.attribution&&t.indexOf(s.attribution)<0&&t.push(s.attribution)}}t=t.filter(n=>String(n).trim()),t=t.filter((n,i)=>{for(let s=i+1;s<t.length;s++)if(t[s].indexOf(n)>=0)return!1;return!0}),this.attribHTML=t.join(" "),this.updateAttributionDisplay()}updateAttributionDisplay(){let e=[...new Set([this.attribHTML,...this.customAttributions])].filter(Boolean).join(" ");this.attribInnerEl&&(this.attribInnerEl.innerHTML=e)}resizeAttribution(e){this.attribContainerEl&&(e<=hg||this.compact?this.compact===!1?this.attribContainerEl.setAttribute("open",""):!this.attribContainerEl.classList.contains("mappedin-compact")&&!this.attribContainerEl.classList.contains("mappedin-attrib-empty")&&(this.attribContainerEl.setAttribute("open",""),this.attribContainerEl.classList.add("mappedin-compact","mappedin-compact-show")):(this.attribContainerEl.setAttribute("open",""),this.attribContainerEl.classList.contains("mappedin-compact")&&this.attribContainerEl.classList.remove("mappedin-compact","mappedin-compact-show")))}destroyAttributionControl(){this.attribButtonEl&&this.attribButtonEl.removeEventListener("click",this.toggleAttribution),this.attribContainerEl&&(this.attribContainerEl.remove(),this.attribContainerEl=void 0,this.attribInnerEl=void 0,this.attribButtonEl=void 0)}resize(e){this.resizeAttribution(e)}updateData(e){this.updateAttribution(e)}destroy(){this.destroyAttributionControl(),this.controlContainerEl.remove(),this.compact=void 0}};y();var Qr=class{mesh;type="custom-geometry";dirty=!0;feature;builder;outline;constructor(e,t){this.mesh=new nt,this.feature=e,this.builder=t}get visible(){return this.mesh.visible}set visible(e){this.mesh.visible=e}#e=1;set opacity(e){this.#e=e}get opacity(){return this.#e}color=new z;setColor(e){this.color.set(e)}get position(){return this.mesh?.position}#n=0;get altitude(){return this.#n}set altitude(e){this.mesh&&(this.mesh.position.z=e,this.#n=e)}get renderOrder(){return this.mesh?this.mesh.renderOrder:0}set renderOrder(e){this.mesh&&(this.mesh.renderOrder=e)}};y();var Ai=class{state;convertTo3DMapPosition;constructor(e,t){this.state=e,this.convertTo3DMapPosition=t}update(){let e,t;for(let r of this.state.geometry3DsInScene)r?.type==="custom-geometry"&&(e=r.components[0],t=r.components[1],e.dirty&&t.visible!==!1&&(e.position.copy(this.convertTo3DMapPosition(e.feature.geometry.coordinates[1],e.feature.geometry.coordinates[0],t.altitude)),e.builder.setup(e.mesh),e.mesh.traverse(n=>{n.userData={...n.userData,entityId:r.id,type:"custom-geometry"}}),e.dirty=!1),t.visible!==!1&&e.builder.update(e.mesh))}};y();y();function Zn(o){return o.children.some(e=>e.userData.isOutline)}function dl(o){return o.children.find(e=>e.userData.isOutline)}function Xn(o,e){let t=o.userData.entities3D.values().next().value;return t?e.geometry3DMap.get(t)?.components[3]!==void 0:!1}function th(o,e,t,r,n,i,s,a){let c=o.getAttribute("position").array;if(s!=null&&a!=null){let M=new Set(a);for(let p=0;p<e.count;p++){let m=(e.start+p)*3;c[m+2]=M.has(p)?Math.max(t+r,2e-4+r):r}if(i){let{transform:p,initialHeight:m}=i,g=Math.max(m,1e-4),b=t/g,x=-1/0;for(let C=0;C<s.length;C+=3)x=Math.max(x,s[C+2]);let S=x-g;for(let C=0;C<a.length;C++){let D=a[C],w=(e.start+D)*3,P=s[C*3],T=s[C*3+1],I=s[C*3+2];c[w+2]+=(I-S)/g*(p.shearX*P+p.shearY*T+p.zOffset)*b}}o.attributes.position.needsUpdate=!0;return}let d=s!=null,u=s??c,h=1/0,v=-1/0;for(let M=0;M<e.count;M++){let p=d?M*3:(e.start+M)*3,m=u[p+2];h=Math.min(h,m),v=Math.max(v,m)}let f=v-h;if(!n||n.thickness===0||f===0)for(let M=0;M<e.count;M++){let p=(e.start+M)*3,m=d?M*3:p,g=u[m+2];Math.abs(g-v)<1e-4?c[p+2]=Math.max(t+r,2e-4+r):c[p+2]=r}else{let M=n.thickness,p=h+M,m=h+M,g=v-M,b=v-M,x=r-M,S=r,C=r,D=r+t,w=r+t,P=r+t+M;for(let T=0;T<e.count;T++){let I=(e.start+T)*3,L=d?T*3:I,A=u[L+2],F;if(A<=p){let k=M>0?(A-h)/M:0;F=x+k*(S-x)}else if(A>=b){let k=M>0?(A-b)/M:0;F=w+k*(P-w)}else{let k=g-m,_=k>0?(A-m)/k:0;F=C+_*(D-C)}c[I+2]=F}}if(i){let{transform:M,initialHeight:p}=i,m=Math.max(p,1e-4),g=t/m,b,x,S;for(let C=0;C<e.count;C++){let D=(e.start+C)*3,w=d?C*3:D;b=u[w],x=u[w+1],S=u[w+2],c[D+2]+=(S-h)/m*(M.shearX*b+M.shearY*x+M.zOffset)*g}}o.attributes.position.needsUpdate=!0}y();y();var rh=`// Modified from https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/linedashed.glsl.js
42
- uniform float scale;
43
- attribute float lineDistance;
44
-
45
- varying float vLineDistance;
46
- attribute float visibility;
47
- varying vec4 v_color;
48
- varying vec4 vWorldPosition;
49
-
50
- #include <common>
51
- #include <uv_pars_vertex>
52
- #include <color_pars_vertex>
53
- #include <fog_pars_vertex>
54
- #include <morphtarget_pars_vertex>
55
- #include <logdepthbuf_pars_vertex>
56
- #include <clipping_planes_pars_vertex>
57
-
58
- void main() {
59
-
60
- vLineDistance = scale * lineDistance;
61
- v_color = color;
62
-
63
- #include <uv_vertex>
64
- #include <color_vertex>
65
- #include <morphinstance_vertex>
66
- #include <morphcolor_vertex>
67
- #include <begin_vertex>
68
- #include <morphtarget_vertex>
69
- #include <project_vertex>
70
- vWorldPosition = modelMatrix * vec4(transformed, 1.0);
71
- if (visibility < 0.5) {
72
- gl_Position = vec4(-2.0, -2.0, -2.0, 1.0);
73
- }
74
- #include <logdepthbuf_vertex>
75
- #include <clipping_planes_vertex>
76
- #include <fog_vertex>
77
-
78
- }`;y();var nh=`// Modified from https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/linedashed.glsl.js
79
- uniform vec3 diffuse;
80
- uniform float opacity;
81
-
82
- uniform float dashSize;
83
- uniform float totalSize;
84
-
85
- uniform float effectStart;
86
- uniform float effectDistance;
87
- uniform float darkenAmount;
88
- uniform float darkenUseDepth;
89
- uniform float desaturateAmount;
90
- uniform float desaturateUseDepth;
91
- uniform float washOutAmount;
92
- uniform float washOutUseDepth;
93
-
94
- varying float vLineDistance;
95
- varying vec4 v_color;
96
- varying vec4 vWorldPosition;
97
-
98
- #include <common>
99
- #include <color_pars_fragment>
100
- #include <uv_pars_fragment>
101
- #include <map_pars_fragment>
102
- #include <fog_pars_fragment>
103
- #include <logdepthbuf_pars_fragment>
104
- #include <clipping_planes_pars_fragment>
105
-
106
- void main() {
107
-
108
- vec4 diffuseColor = vec4( diffuse, opacity );
109
- #include <clipping_planes_fragment>
110
-
111
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
112
-
113
- discard;
114
-
115
- }
116
-
117
- vec3 outgoingLight = vec3( 0.0 );
118
-
119
- #include <logdepthbuf_fragment>
120
- #include <map_fragment>
121
- #include <color_fragment>
122
-
123
- outgoingLight = diffuseColor.rgb; // simple shader
124
-
125
- #include <opaque_fragment>
126
- #include <tonemapping_fragment>
127
- #include <colorspace_fragment>
128
- #include <fog_fragment>
129
- #include <premultiplied_alpha_fragment>
130
-
131
- // Depth-based visual effects (mirrors batched-lambert-fragment-with-shadows.glsl)
132
- if(effectDistance > 0.0) {
133
- float t = clamp((effectStart - vWorldPosition.z) / effectDistance, 0.0, 1.0);
134
- float fade = pow(t, 0.65) * 0.9;
135
-
136
- // Desaturate towards grayscale
137
- float luma = dot(gl_FragColor.rgb, vec3(0.299, 0.587, 0.114));
138
- float dsFade = desaturateUseDepth > 0.5 ? fade : 1.0;
139
- gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(luma), desaturateAmount * dsFade);
140
-
141
- // Darken towards #333333
142
- float dkFade = darkenUseDepth > 0.5 ? fade : 1.0;
143
- gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2), darkenAmount * dkFade);
144
-
145
- // Wash out towards white
146
- float woFade = washOutUseDepth > 0.5 ? fade : 1.0;
147
- gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(1.0), washOutAmount * woFade);
148
- }
149
-
150
- // Discard alpha lower than 0.01 to avoid opacity fighting
151
- if (v_color.a <= 0.01) {
152
- discard;
153
- }
154
- }
155
- `;var Yn=class extends zr{effectUniforms={effectStart:{value:0},effectDistance:{value:0},darkenAmount:{value:0},darkenUseDepth:{value:1},desaturateAmount:{value:0},desaturateUseDepth:{value:1},washOutAmount:{value:0},washOutUseDepth:{value:0}};constructor(e){super(e),this.onBeforeCompile=t=>{t.vertexShader=rh,t.fragmentShader=nh;let r=this.effectUniforms.effectStart,n=this.effectUniforms.effectDistance,i=this.effectUniforms.darkenAmount,s=this.effectUniforms.darkenUseDepth,a=this.effectUniforms.desaturateAmount,l=this.effectUniforms.desaturateUseDepth,c=this.effectUniforms.washOutAmount,d=this.effectUniforms.washOutUseDepth;this.effectUniforms=t.uniforms,Object.assign(this.effectUniforms,{effectStart:r,effectDistance:n,darkenAmount:i,darkenUseDepth:s,desaturateAmount:a,desaturateUseDepth:l,washOutAmount:c,washOutUseDepth:d})}}setEffectRange(e,t){this.effectUniforms.effectStart.value=e,this.effectUniforms.effectDistance.value=t}getEffectRange(){return{start:this.effectUniforms.effectStart.value,distance:this.effectUniforms.effectDistance.value}}setVisualEffect(e,t,r,n,i,s){this.effectUniforms.darkenAmount.value=e,this.effectUniforms.darkenUseDepth.value=t?1:0,this.effectUniforms.desaturateAmount.value=r,this.effectUniforms.desaturateUseDepth.value=n?1:0,this.effectUniforms.washOutAmount.value=i,this.effectUniforms.washOutUseDepth.value=s?1:0}getVisualEffect(){return{darkenAmount:this.effectUniforms.darkenAmount.value,darkenUseDepth:this.effectUniforms.darkenUseDepth.value,desaturateAmount:this.effectUniforms.desaturateAmount.value,desaturateUseDepth:this.effectUniforms.desaturateUseDepth.value,washOutAmount:this.effectUniforms.washOutAmount.value,washOutUseDepth:this.effectUniforms.washOutUseDepth.value}}};y();var Pr=class{#e=[];#n=!1;#i;#o;#s;constructor(e=3e3){this.#s=e}get size(){return this.#e.length}add(e){this.#e.push(e),this.#n||this.#a()}onComplete(e){this.#i=e}clearOnComplete(){this.#i=void 0}#a(){this.#n=!0,this.#o=requestIdleCallback(e=>{let t=0;for(;this.#e.length>0&&e.timeRemaining()>2;){let r=this.#e.shift();r&&(r(),t++)}if(t===0&&this.#e.length>0&&e.timeRemaining()<2){let r=this.#e.shift();r&&r()}this.#o=void 0,this.#e.length>0?this.#a():(this.#n=!1,this.#i&&this.#i())},{timeout:this.#s})}clearAll(){this.#e=[],this.#n=!1,this.#i=void 0,this.#o!==void 0&&(cancelIdleCallback(this.#o),this.#o=void 0)}};var yg=80,Ri=class extends q{rendererState;maxOpacity;outlineOpacitiesDirty=!0;useIdleFramesOnly=!0;#e=!0;get geometries3DDirty(){return this.#e}set geometries3DDirty(e){this.#e=e}#n=-1/0;idleBuildQueue;idleComputeBoundingSphereQueue;constructor(e,t,r=!0,n=3e3){super(),this.rendererState=e,this.maxOpacity=t?.maxOpacity??1,this.useIdleFramesOnly=r,this.idleBuildQueue=new Pr(n),this.idleComputeBoundingSphereQueue=new Pr(n),this.idleBuildQueue.onComplete(this.#s)}#i=new Map;buildOutlines(e){let t=[];for(let u of e.userData.entities3D.values()){let h=this.rendererState.geometry3DMap.get(u);if(h instanceof Q&&h.type==="geometry"&&h.components[3]&&h.components[3].dirty===!0&&h.components[0].material!=null){let v=h.components[0],f=h.components[8],M=f?.baselineVertices!=null,p=v.geometry,m=!1;if(p){if(p&&f?.baselineVertices){let x=p.clone();x.setAttribute("position",new De(f.baselineVertices.slice(),3)),p=x,m=!0}}else{p=Nn(v),m=!0;let x=f?.baselineVertices;if(x&&p){let S=p.getAttribute("position")?.count??0,C=x.length/3;if(S!==C){let D=v.batchedProps?.range?.vertexStart??0,w=p.getIndex();if(w){let P=w.array;for(let T=0;T<w.count;T++)P[T]=P[T]-D;w.needsUpdate=!0}}p.setAttribute("position",new De(x.slice(),3))}}let g=h.components[1],b=(g.bevel?.thickness??0)!==0;t.push([h.components[3],new zo(p,g.bevel?.enabled?1:yg),M,b,h.components[3].enabled&&g.visible]),m&&(p?.dispose(),p=void 0)}}if(t.length===0)return;let r=Ke(t.map(u=>u[1]),!1);if(r==null)return;let n=r.getAttribute("position"),i=new Float32Array(n.count*4),s=new De(i,4);r.setAttribute("color",s);let a=new Uint8Array(n.count);a.fill(0);let l=new De(a,1,!1);r.setAttribute("visibility",l);let c=0;for(let u=0;u<t.length;u++){let[h,v,f,M,p]=t[u],m=v.getAttribute("position").count;if(h.edgeColors=s,h.edgeVisibility=l,h.geometry=r,h.resetVisibility(),h.ranges={count:m,start:c},h.visible=p,!f)h.baselineVertices=void 0,h.topFaceVerticesIndices=void 0;else{let g=1/0,b=-1/0;for(let S=0;S<m;S++){let C=n.array[(c+S)*3+2];C<g&&(g=C),C>b&&(b=C)}if(!M&&b-g>1e-4){let S=[];for(let D=0;D<m;D++)Math.abs(n.array[(c+D)*3+2]-b)<1e-4&&S.push(D);let C=new Float32Array(S.length*3);for(let D=0;D<S.length;D++){let w=(c+S[D])*3;C[D*3]=n.array[w],C[D*3+1]=n.array[w+1],C[D*3+2]=n.array[w+2]}h.baselineVertices=C,h.topFaceVerticesIndices=S}else{let S=new Float32Array(m*3);for(let C=0;C<m;C++){let D=(c+C)*3;S[C*3]=n.array[D],S[C*3+1]=n.array[D+1],S[C*3+2]=n.array[D+2]}h.baselineVertices=S,h.topFaceVerticesIndices=void 0}}c+=m,v.dispose()}let d=new Xt(r,new Yn({vertexColors:!0,linewidth:1,transparent:!0,opacity:1,side:Ro}));d.userData.isOutline=!0,e.add(d)}update(e,t=!0){for(let n of this.rendererState.geometry3DsInScene){if(n.type!=="geometry")continue;let i=n.components[3];if(!i?.needsRebuild)continue;let s=n.parentObject3D;if(s instanceof Fe){let a=dl(s);a&&Ce(a);for(let l of s.userData.entities3D){let c=this.rendererState.geometry3DMap.get(l);if(c?.type==="geometry"&&c.components[3]){let d=c.components[3];d.dirty=!0,d.geometry=void 0,d.ranges=void 0,d.edgeColors=void 0,d.edgeVisibility=void 0}}}i.needsRebuild=!1,this.geometries3DDirty=!0}if(this.geometries3DDirty){for(let n of this.rendererState.geometry3DsInScene)n.type==="feature-collection"&&Xn(n,this.rendererState)&&!Zn(n)&&n.userData.entities3D.size>0&&this.#o(this.idleBuildQueue,()=>this.buildOutlines(n));this.#e=!1,this.outlineOpacitiesDirty=!0}for(let n of this.rendererState.geometry3DsInScene)if(n.type==="geometry"&&n.components[3]&&n.components[3].dirty===!0&&n.components[0].material!=null&&n.parentObject3D instanceof Fe){let i=n.components[3].geometry;if(!i)continue;let s=n.components[3];if(!s)continue;let a=s.enabled&&n.components[1].visible;if(s.visible!==a&&(s.visible=a),!s.visible)continue;let l=s.edgeColors;if(!l||!s.ranges)continue;let c=new z(s.color);for(let m=0;m<s.ranges.count;m++){let g=s.ranges.start+m;l.setXYZ(g,c.r,c.g,c.b)}let d=n.components[1],u=d.height*d.heightScale,h=d.altitude,v=d?.bevel,M=n.components[8]?.currentSlope,p=d.initialHeight;th(i,s.ranges,u,h,v,M?{transform:M,initialHeight:p}:void 0,s.baselineVertices,s.topFaceVerticesIndices),i.attributes.color.needsUpdate=!0,this.#o(this.idleComputeBoundingSphereQueue,()=>i.computeBoundingSphere()),s.dirty=!1}else if(n.type==="feature-collection"&&Zn(n)){let i=dl(n);if(!i)continue;let s=i.material;if(!(s instanceof Yn))continue;let a;for(let d of n.userData.entities3D.values()){a=d;break}if(a==null)continue;let l=this.rendererState.geometry3DMap.get(a);if(!l||l.type!=="geometry")continue;let c=l.components[1];s.setEffectRange(c.effectStart,c.effectDistance),s.setVisualEffect(c.darkenAmount,c.darkenUseDepth,c.desaturateAmount,c.desaturateUseDepth,c.washOutAmount,c.washOutUseDepth)}let r=t?la(e,16,19,0,this.maxOpacity):this.#n;if((r!==this.#n||this.outlineOpacitiesDirty)&&this.rendererState.geometry3DsInScene.size>0){for(let n of this.rendererState.geometry3DsInScene)if(n.type==="geometry"&&n.components[0]instanceof ue){let i=n.components[3];if(i&&i.edgeColors&&i.geometry&&i.visible){let s=Math.min(r,n.components[1].opacity*Yr(n));if(i.currentOpacity!==s){for(let a=0;a<i.ranges.count;a++){let l=i.ranges.start+a;i.edgeColors.setW(l,s)}i.geometry.attributes.color.needsUpdate=!0}}}}this.#n=r,this.#e=!1,this.outlineOpacitiesDirty=!1}#o(e,t){this.useIdleFramesOnly?e.add(t):t()}#s=()=>{this.publish("needs-render")};destroy(){this.#i.clear(),this.idleBuildQueue.clearAll(),this.idleComputeBoundingSphereQueue.clearAll()}};y();y();import{z as Xe}from"zod";var Fi=class extends X{userData={entityId:"",cacheKey:"",isResizable:!1}},bg=Xe.object({flipImageToFaceCamera:Xe.boolean().optional(),url:Xe.string(),maxImageSize:Xe.number().positive().optional(),interactive:Xe.boolean().optional()}),vg=Xe.object({type:Xe.enum(["Feature"]),properties:Xe.object({width:Xe.number(),height:Xe.number(),rotation:Xe.number().min(0).max(360).optional(),verticalOffset:Xe.number().optional()}),geometry:qr});function oh(o,e,t){Xe.union([Xe.number(),Xe.string()]).parse(o),vg.parse(e),bg.parse(t)}var $n=class{mesh=new nt;imageMesh;outline;type="image";instanceIndex=-1;geometry;material;feature;constructor(e){this.feature=e}get visible(){return this.mesh?.visible??!1}set visible(e){this.mesh&&(this.mesh.visible=e)}position=new O};y();function hl(o,e){return{x:o.x*Math.cos(e)-o.y*Math.sin(e),y:o.x*Math.sin(e)+o.y*Math.cos(e)}}function xg(o,e){return o.map(t=>hl(t,e))}function Sg(o){let e=1/0,t=1/0,r=-1/0,n=-1/0;for(let i of o)e=Math.min(e,i.x),t=Math.min(t,i.y),r=Math.max(r,i.x),n=Math.max(n,i.y);return{minX:e,minY:t,maxX:r,maxY:n}}function Mg(o,e){let t=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){let i=e[r].x,s=e[r].y,a=e[n].x,l=e[n].y;s>o.y!=l>o.y&&o.x<(a-i)*(o.y-s)/(l-s)+i&&(t=!t)}return t}function ih(o,e,t,r,n){for(let i=0;i<n;i++)for(let s=0;s<r;s++)if(o[t+i][e+s]!==1)return!1;return!0}function Cg(o,e,t){let r=o.maxX-o.minX,n=o.maxY-o.minY,i,s,a={...o};return r/n>e?(s=n/t,i=s*e,a.minX+=(r-i*t)/2):(i=r/t,s=i/e,a.minY+=(n-s*t)/2),{dx:i,dy:s,gridBounds:a}}function wg(o,e,t,r,n){let i=Array(t).fill(0).map(()=>Array(t).fill(0));for(let s=0;s<t;s++)for(let a=0;a<t;a++){let l={x:e.minX+a*r,y:e.minY+s*n};Mg(l,o)&&(i[s][a]=1)}return i}function Eg(o,e){let t=Array(e).fill(0).map(()=>Array(e).fill(0));for(let r=0;r<e;r++)for(let n=0;n<e;n++)if(o[r][n]===1){let i=0;for(let s=1;s<=Math.min(e-n,e-r)&&ih(o,n,r,s,s);s++)i=s;t[r][n]=i}return t}function Dg(o,e,t,r,n,i){let s=0,a=0,l=0;for(let c=0;c<r;c++)for(let d=0;d<r;d++)if(o[c][d]===1){let u=Math.pow(e[c][d],2),h=t.minX+d*n,v=t.minY+c*i;s+=u,a+=h*u,l+=v*u}return{x:a/s,y:l/s}}function Tg(o,e,t,r,n,i,s){let a=-1/0,l=null,c=o.length,d=Math.sqrt(Math.pow(e.maxX-e.minX,2)+Math.pow(e.maxY-e.minY,2));for(let u=0;u<c;u++)for(let h=0;h<c;h++)if(o[u][h]===1)for(let v=1;v<=c-h;v++){let f=v;if(!(f>c-u)&&ih(o,h,u,v,f)){let M=v*f,p=e.minX+(h+v/2)*t,m=e.minY+(u+f/2)*r,g={x:p,y:m},x=Math.sqrt(Math.pow(g.x-n.x,2)+Math.pow(g.y-n.y,2))/d,S=M*(1-i)-x*i*M;S>a&&(a=S,l={center:g,width:v*t*s,height:v*r*s})}}return l}function pl(o,e,t,r={}){let{scaleFactor:n=.9,centerPriority:i=.5,resolution:s=100,minimumSizeRatio:a=.5}=r,l=vt(t),c=o.width/o.height,d=xg(e,l),u=Sg(d),{dx:h,dy:v,gridBounds:f}=Cg(u,c,s),M=wg(d,f,s,h,v),p=Eg(M,s),m=Dg(M,p,f,s,h,v),g=Tg(M,f,h,v,m,i,n);return!g||g.width<o.width*a||g.height<o.height*a?o:{...g,center:hl(g.center,-l),rotation:t,polygonCenter:hl(m,-l)}}y();var le={HIGH:1,MEDIUM:.5,LOW:.25,VERY_LOW:.125},pe={[le.HIGH]:2048,[le.MEDIUM]:1024,[le.LOW]:512,[le.VERY_LOW]:256},sh={[pe[le.HIGH]]:65280,[pe[le.MEDIUM]]:16776960,[pe[le.LOW]]:16753920,[pe[le.VERY_LOW]]:16711680},_i={HIGH:50,MEDIUM:100,LOW:250},ah="https://resize-worker.mappedin.com",lh=["cdn.mappedin.com","cdn.eu.mappedin.com"],ml=["resize-worker.mappedin.com","resize-worker-staging.mappedin.net"],fl=.01,qn=1024,Jn=256,ch=512,dh=2048,uh=3,hh=37,ph=16*1024*1024;y();function gl(o){try{let t=new URL(o).hostname;return lh.includes(t)||ml.includes(t)}catch{return!1}}function Pg(o){try{let e=new URL(o);return ml.includes(e.hostname)}catch{return!1}}function yl(o,e){return Pg(o)?o.replace(/\/resize:fit:\d+:\d+:(\d+)\//,`/resize:fit:${e}:${e}:$1/`):`${ah}/resize:fit:${e}:${e}:0/plain/${o}`}function mh(o){return o<=_i.HIGH?pe[le.HIGH]:o<=_i.MEDIUM?pe[le.MEDIUM]:o<=_i.LOW?pe[le.LOW]:pe[le.VERY_LOW]}function fh(o){let e=o*hh;return e<=pe[le.LOW]?pe[le.LOW]:e<=pe[le.MEDIUM]?pe[le.MEDIUM]:pe[le.HIGH]}function gh(o,e){return gl(o)?o:`${o}|${e??qn}`}function Bi(o,e){o.color=new z(16777215),o.emissive=new z(sh[e]),o.emissiveIntensity=.5}function Gi(o){o.color=new z(16777215),o.emissive=new z(0),o.emissiveIntensity=0}y();function bh(o){let{transformImageRequest:e,getMaxTextureSize:t,publish:r}=o,n=new Map,i=new Set,s=0,a=!1,l={transformImageRequest:e,isDisposed:()=>a};function c(){if(s>0)return s;let p=t(),m=jo().isMobile?ch:pe[le.HIGH];return s=Math.min(m,p),s}function d(p){return Math.min(p,c())}function u(p,m){return Math.min(d(mh(m)),fh(p.maxLongEdge))}function h(p,m,g){if(p.base||p.basePending)return;p.basePending=!0;let b=p.isResizable?yl(m,g):m;yh(b,S=>{let C=p.isResizable?S:Ag(S,g);return C.colorSpace=br,p.base=C,p.basePending=!1,C},()=>{p.basePending=!1},l).then(()=>{a||r()}).catch(()=>{})}function v(p,m,g){p.hiLod!=null&&g<=p.hiLod||p.readyLod!=null&&g<=p.readyLod||(p.ready=m,p.readyLod=g,i.add(p))}function f(p){p.ready=null,p.readyLod=null,i.delete(p)}function M(p,m,g){if(!p.isResizable||p.hiLod!=null&&g<=p.hiLod||p.readyLod!=null&&g<=p.readyLod||p.pendingFetchLOD!=null&&g<=p.pendingFetchLOD)return;p.pendingFetchLOD=g;let b=()=>{p.pendingFetchLOD===g&&(p.pendingFetchLOD=null)},x=yl(m,g);yh(x,C=>(C.colorSpace=br,v(p,C,g),b(),C),()=>{b()},l).then(()=>{a||r()}).catch(()=>{})}return{register(p,m,g,b,x,S){if(a)return;let C=n.get(p);if(C?(S>C.maxLongEdge&&(C.maxLongEdge=S),x<C.distance&&(C.distance=x)):(C={url:m,base:null,hi:null,hiLod:null,ready:null,readyLod:null,basePending:!1,pendingFetchLOD:null,isResizable:b,distance:x,maxLongEdge:S},n.set(p,C)),h(C,m,b?Jn:g),b){let w=u(C,x);w>Jn&&M(C,m,w)}},get(p){if(a)return null;let m=n.get(p);return m?m.hi??m.base:null},requestUpgrade(p,m){if(a)return;let g=n.get(p);!g||!g.isResizable||(m<g.distance&&(g.distance=m),M(g,p,u(g,m)))},drainPromotions(){if(a||i.size===0)return;let p=0,m=0,g=Math.min(uh,i.size);for(;p<g;){let b,x=1/0;for(let D of i)D.distance<x&&(x=D.distance,b=D);if(b==null)break;let S=Og(b.ready);if(m>0&&m+S>ph)break;let C=b.hi;b.hi=b.ready,b.hiLod=b.readyLod,f(b),C?.dispose(),m+=S,p++}i.size>0&&r()},effectiveLOD(p){return n.get(p)?.hiLod??Jn},residentResolutionBucket(p){let m=n.get(p),g=m?.hi??m?.base;return Lg(Ig(g))},dispose(){a=!0;for(let p of n.values())p.base?.dispose(),p.hi?.dispose(),p.ready?.dispose();n.clear(),i.clear()},getCacheEntries(){let p=new Map;for(let[m,g]of n)p.set(m,{url:g.url,base:g.base,hi:g.hi,hiLod:g.hiLod,isResizable:g.isResizable,maxLongEdge:g.maxLongEdge});return p}}}function yh(o,e,t,r){let n=i=>new Promise((s,a)=>{if(r.isDisposed()){a(new Error("LOD control disposed"));return}er.getLoader().load(i,l=>{if(r.isDisposed()){l.dispose(),a(new Error("LOD control disposed"));return}try{s(e(l))}catch(c){R.error("Failed to process image texture",{url:i,error:c}),t(c),a(c)}},void 0,l=>{if(r.isDisposed()){a(new Error("LOD control disposed"));return}R.error("Failed to load image",{url:i,error:l}),t(l),a(l)})});return r.transformImageRequest?r.transformImageRequest(o).then(i=>n(i.url),i=>(r.isDisposed()||(R.error("Failed to transform image request",{url:o,error:i}),t(i)),Promise.reject(i))):n(o)}var Ir={w:0,h:0};function vh(o){let e=o?.image;return e?e instanceof HTMLImageElement?(Ir.w=e.naturalWidth||0,Ir.h=e.naturalHeight||0):(Ir.w=e.width||0,Ir.h=e.height||0):(Ir.w=0,Ir.h=0),Ir}function Ig(o){let{w:e,h:t}=vh(o);return Math.max(e,t)}function Og(o){let{w:e,h:t}=vh(o);return e*t*4}function Lg(o){return o>=pe[le.HIGH]?pe[le.HIGH]:o>=pe[le.MEDIUM]?pe[le.MEDIUM]:o>=pe[le.LOW]?pe[le.LOW]:Jn}function Ag(o,e){let t=o.image,r=t instanceof HTMLImageElement?t.naturalWidth:t.width,n=t instanceof HTMLImageElement?t.naturalHeight:t.height,i=Math.max(r,n);if(i<=e)return o.colorSpace=br,o;o.dispose();let s=e/i,a=Math.max(1,Math.floor(r*s)),l=Math.max(1,Math.floor(n*s)),c;typeof window<"u"&&window.OffscreenCanvas!=null&&!kc()&&!vd()?c=new OffscreenCanvas(a,l):(c=document.createElement("canvas"),c.width=a,c.height=l);let d=Lo(c);if(!d)throw new Error("Failed to get 2D context for texture capping");d.drawImage(t,0,0,a,l);let u=new td(c);return u.colorSpace=br,u.needsUpdate=!0,u}var Kn=Math.PI*2,Rg=Math.PI/2,Fg=Math.PI*1.5,_g=Si(Rg,2),Bg=Si(Fg,2),ki=class extends q{rendererState;convertTo3DMapPosition;projectToScreen;initialBearing=0;naturalBearing=0;imagePlacementOptions;cameraFrustum=new Nr;cameraWorldPosition=new O;debug={lod:!1,imageContainers:!1};get debugLOD(){return this.debug.lod}set debugLOD(e){let t=this.debug.lod!==e;this.debug.lod=e,t&&(e?this.applyDebugLODColors():this.resetDebugLODColors())}lod;constructor(e,t,r,n=0,i=0,s={},a){super(),this.rendererState=e,this.convertTo3DMapPosition=t,this.projectToScreen=r,this.initialBearing=n,this.naturalBearing=i,this.imagePlacementOptions=s,this.lod=bh({transformImageRequest:a,getMaxTextureSize:()=>this.rendererState.renderer?.capabilities?.maxTextureSize??dh,publish:()=>this.publish("image-loaded")})}createImageMesh(e,t,r,n=0,i,s,a=qn){let l={width:r.width,height:r.height,center:this.convertTo3DMapPosition(i),rotation:r.rotation??0},c=this.imagePlacementOptions.mode??"default",d=(()=>{switch(c){case"fit-nearest-90":let x=(this.initialBearing-this.naturalBearing+360)%180;return x>=45&&x<=135?pl(l,s,l.rotation+90,this.imagePlacementOptions):l;case"fit-initial-bearing":return pl(l,s,this.initialBearing,this.imagePlacementOptions);case"default":case"none":default:return l}})();if(this.debug.imageContainers&&d.polygonCenter){let x=new X(new Vr(1),new Yt({color:65280}));x.position.set(d.polygonCenter.x,d.polygonCenter.y,n),this.rendererState.geometryScene.add(x)}let u=new Yt({transparent:!0,depthWrite:!1,side:Vt}),h=new We(d.width,d.height),v=new Fi(h);v.visible=!1,v.renderOrder=ye.IMAGE_MESH;let f=gl(t),M=n+fl,p=this.rendererState.cameraObject.position.z,m=Math.abs(p-M),g=gh(t,a),b=Math.max(d.width,d.height);if(this.lod.register(g,t,a??qn,f,m,b),v.userData.entityId=e,v.userData.cacheKey=g,v.userData.isResizable=f,v.material=u,this.debug.imageContainers){let x=new X(new We(r.width,r.height),new Yt({color:"gray"}));v.add(x);let S=new ud;v.add(S),S.scale.set(10,10,10)}return v.position.set(d.center.x,d.center.y,n+fl),v.rotation.z=(-W.degToRad(d.rotation)+Kn)%Kn,v}applyDebugLODColors(){this.rendererState.cameraObject.getWorldPosition(this.cameraWorldPosition);for(let e of this.rendererState.geometry3DsInScene)if(e.type==="image"){let t=e.components[0];if(t?.imageMesh?.material instanceof Yt){let{cacheKey:r,isResizable:n}=t.imageMesh.userData;n===!0?Bi(t.imageMesh.material,this.lod.residentResolutionBucket(r)):Gi(t.imageMesh.material)}}else if(e.type==="geometry"){let t=e.components[0];if(Array.isArray(t?.feature))continue;if(t?.imageMesh?.material instanceof Yt){let{cacheKey:r,isResizable:n}=t.imageMesh.userData;n===!0?Bi(t.imageMesh.material,this.lod.residentResolutionBucket(r)):Gi(t.imageMesh.material)}}}resetDebugLODColors(){for(let e of this.rendererState.geometry3DsInScene){let t;e.type==="image"?t=e.components[0]:e.type==="geometry"&&(t=e.components[0]),t?.imageMesh?.material instanceof Yt&&Gi(t.imageMesh.material)}}flipIfNeeded(e,t){if(e.imageMesh==null)return;let r=-t,n=e.imageMesh.rotation.z,i=Si((n-r+Kn)%Kn,2);if(i>_g&&i<Bg){let s=e.imageMesh.matrixWorldAutoUpdate===!1;s&&$o(e.imageMesh),e.imageMesh.rotation.z=(n+Math.PI)%Kn,e.imageMesh.updateMatrixWorld(),s&&Od(e.imageMesh)}}currentImageScreenBBoxes=[];viewProjectionMatrix=new K;lastLODUpdateTime=-1;reconcileMaterialTexture(e,t,r){let n=this.lod.get(t);return e.map!==n&&(e.map=n,e.needsUpdate=!0,this.debug.lod&&r&&Bi(e,this.lod.residentResolutionBucket(t))),n!=null}update(e,t,r){this.currentImageScreenBBoxes=[],this.viewProjectionMatrix.identity().multiply(this.rendererState.cameraObject.projectionMatrix).multiply(this.rendererState.cameraObject.matrixWorldInverse),this.cameraFrustum.setFromProjectionMatrix(this.viewProjectionMatrix),this.rendererState.cameraObject.getWorldPosition(this.cameraWorldPosition);let n=!t&&r!==this.lastLODUpdateTime;n&&(this.lastLODUpdateTime=r),this.lod.drainPromotions();let i,s;for(let a of this.rendererState.geometry3DsInScene)if(a.type==="image"){if(i=a.components[0],s=a.components[1],s.url&&i.imageMesh==null){let l=this.convertTo3DMapPosition(i.feature.geometry.coordinates),c={x:l.x,y:l.y};i.imageMesh=this.createImageMesh(a.id,s.url,i.feature.properties,i.feature.properties.verticalOffset,i.feature.geometry.coordinates,[c],s.maxImageSize),i.mesh.add(i.imageMesh),i.position.copy(i.imageMesh.position)}if(i.imageMesh){let{cacheKey:l,isResizable:c}=i.imageMesh.userData;if(n&&s.url){let d=Math.abs(this.cameraWorldPosition.z-i.position.z);this.lod.requestUpgrade(l,d)}if(s.url){let d=i.imageMesh.material;this.reconcileMaterialTexture(d,l,c)&&!i.imageMesh.visible&&(i.imageMesh.visible=!0)}s.flipImageToFaceCamera&&this.flipIfNeeded(i,e),i.imageMesh.material instanceof Yt&&s.dirty&&i.imageMesh.material.opacity!==s.opacity&&(i.imageMesh.material.opacity=s.opacity)}}else if(a?.type==="geometry"){if(i=a.components[0],s=a.components[1],Array.isArray(i.feature))continue;if(s.showImage&&i.feature.properties?.image&&i.imageMesh==null&&i.visible&&i.mesh!=null&&i.mesh.parent!=null&&i.feature.properties?.image.position!=null&&i.feature.geometry.coordinates!=null&&i.feature.geometry.coordinates.length>0){let l=i.feature.geometry.coordinates[0].map(d=>{let u=this.convertTo3DMapPosition(d);return{x:u.x,y:u.y}}),c=this.createImageMesh(a.id,i.feature.properties?.image.path,i.feature.properties?.image,s.height+s.altitude,i.feature.properties?.image.position,l,s.maxImageSize);i.mesh.parent.add(c),i.imageMesh=c}if(i.imageMesh){let l=i.feature.properties?.image?.path,{cacheKey:c,isResizable:d}=i.imageMesh.userData,u=!1;if(n&&l){let h=Math.abs(this.cameraWorldPosition.z-i.imageMesh.position.z);this.lod.requestUpgrade(c,h)}if(l){let h=i.imageMesh.material;u=this.reconcileMaterialTexture(h,c,d)}i.visible?s.showImage&&!i.imageMesh.visible?l?u&&(i.imageMesh.visible=!0):i.imageMesh.visible=!0:!s.showImage&&i.imageMesh.visible&&(i.imageMesh.visible=!1):i.imageMesh.visible=!1,s.flipImageToFaceCamera&&this.flipIfNeeded(i,e),s.enableImageCollisions===!0&&this.updateImageScreenBBoxes(i)}}}destroy(){this.lod.dispose(),super.destroy()}getCacheStats(){return this.lod.getCacheEntries()}updateImageScreenBBoxes(e){if(e.imageMesh==null||!e.imageMesh.visible)return;let t=e.imageMesh.geometry.boundingBox;if(t==null&&(e.imageMesh.geometry.computeBoundingBox(),t=e.imageMesh.geometry.boundingBox),t){let r=new O;if(e.imageMesh.getWorldPosition(r),!this.cameraFrustum.containsPoint(r))return;let n=new V;this.projectToScreen(n,r);let i=[new O(t.min.x,t.min.y,t.min.z),new O(t.max.x,t.min.y,t.min.z),new O(t.min.x,t.max.y,t.min.z),new O(t.max.x,t.max.y,t.min.z),new O(t.min.x,t.min.y,t.max.z),new O(t.max.x,t.min.y,t.max.z),new O(t.min.x,t.max.y,t.max.z),new O(t.max.x,t.max.y,t.max.z)],s=[];for(let h of i){let v=h.clone().applyMatrix4(e.imageMesh.matrixWorld),f=new V;this.projectToScreen(f,v),s.push(f)}let a=1/0,l=1/0,c=-1/0,d=-1/0;for(let h of s)a=Math.min(a,h.x),l=Math.min(l,h.y),c=Math.max(c,h.x),d=Math.max(d,h.y);let u=new qt(n.x,n.y,c-a,d-l);this.currentImageScreenBBoxes.push(u)}else R.warn("Bounding box for imageMesh does not exist.")}};y();y();function bl(o){let e=1/0,t=1/0,r=-1/0,n=-1/0;for(let i of o)i.x<e&&(e=i.x),i.x>r&&(r=i.x),i.y<t&&(t=i.y),i.y>n&&(n=i.y);return{minX:e,minY:t,maxX:r,maxY:n}}function Gg(o,e){return!(o.maxX<e.minX||o.minX>e.maxX||o.maxY<e.minY||o.minY>e.maxY)}function kg(o,e){if(!Gg(o,e))return 0;let t=Math.max(o.minX,e.minX),r=Math.min(o.maxX,e.maxX),n=Math.max(o.minY,e.minY),i=Math.min(o.maxY,e.maxY),s=r-t,a=i-n;return s*a}function xh(o,e){let t=kg(o,e);if(t===0)return 0;let r=e.maxX-e.minX,n=e.maxY-e.minY,i=r*n;return i===0?0:t/i}y();function Ng(o){let e=0;for(let t=1;t<o.length;t++)(o[t].y<o[e].y||o[t].y===o[e].y&&o[t].x<o[e].x)&&(e=t);return e}function zg(o,e){let t=[...o];return t.sort((r,n)=>{let i=r.point.x-e.x,s=r.point.y-e.y,a=n.point.x-e.x,l=n.point.y-e.y,c=i*l-s*a;if(c===0){let d=i*i+s*s,u=a*a+l*l;return d-u}return c>0?-1:1}),t}function Ug(o,e){let t=[e];for(let r=0;r<o.length;r++){for(;t.length>1;){let n=t[t.length-2].point,i=t[t.length-1].point,s=o[r].point,a=i.x-n.x,l=i.y-n.y,c=s.x-i.x,d=s.y-i.y;if(a*d-l*c<=0)t.pop();else break}t.push(o[r])}return t}function Sh(o){if(o.length<3)return o.map((i,s)=>({point:i,index:s}));let e=Ng(o),t=o.map((i,s)=>({point:i,index:s})),r=t[e];t.splice(e,1);let n=zg(t,r.point);return Ug(n,r)}function Qn(o,e,t,r){if(o.length===0)return[];let n=[],i=o[o.length-1],s=e*i.x+t*i.y+r;for(let a=0;a<o.length;a++){let l=o[a],c=e*l.x+t*l.y+r;if(c>=0){if(s<0){let d=s/(s-c);n.push({x:i.x+d*(l.x-i.x),y:i.y+d*(l.y-i.y)})}n.push(l)}else if(s>=0){let d=s/(s-c);n.push({x:i.x+d*(l.x-i.x),y:i.y+d*(l.y-i.y)})}i=l,s=c}return n}y();var Hg="2",Wg="1000",Vg="1002";function jg(o,e){let t=document.createElement("div");return t.id=`focus-bbox-${o}`,t.style.position="absolute",t.style.pointerEvents="none",t.style.overflow="hidden",t.style.zIndex=Wg,e.appendChild(t),t}function Zg(o,e){let t=e.maxX-e.minX,r=e.maxY-e.minY;o.style.left=e.minX+"px",o.style.top=e.minY+"px",o.style.width=t+"px",o.style.height=r+"px"}function Xg(o,e){e?(o.style.border="2px solid green",o.style.backgroundColor="rgba(0, 255, 0, 0.1)"):(o.style.border="2px solid red",o.style.backgroundColor="rgba(255, 0, 0, 0.1)")}function Yg(o){let e=o.querySelector(".entity-id-label");return e||(e=document.createElement("div"),e.className="entity-id-label",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.padding="2px 4px",e.style.color="white",e.style.fontSize="10px",e.style.fontWeight="bold",e.style.fontFamily="monospace",e.style.zIndex="1001",o.appendChild(e)),e}function $g(o){let e=o.querySelector(".score-label");return e||(e=document.createElement("div"),e.className="score-label",e.style.position="absolute",e.style.bottom="0",e.style.right="0",e.style.padding="2px 4px",e.style.color="white",e.style.fontSize="12px",e.style.fontWeight="bold",e.style.fontFamily="monospace",e.style.zIndex="1001",o.appendChild(e)),e}function qg(o,e,t,r,n){r?o.style.backgroundColor="green":o.style.backgroundColor="red",o.textContent=t,n!==void 0?(e.style.backgroundColor=r?"green":"red",e.textContent=n.toFixed(3)):(e.style.backgroundColor=r?"green":"red",e.textContent="")}function Mh(o,e){for(let[t,r]of o)e.has(t)||(r.remove(),o.delete(t))}function Ch(o,e,t,r,n,i){let s=t.get(o);s||(s=jg(o,r),t.set(o,s)),Zg(s,e.clippedScreenBBox??e.screenBBox),Xg(s,n);let a=Yg(s),l=$g(s);return qg(a,l,o,n,i),s}function wh(){let o=document.createElement("div");return Object.assign(o.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",overflow:"hidden",zIndex:Hg}),document.body.append(o),o}function Eh(o,e){let t=document.createElement("div");t.style.position="absolute",t.style.top=o.minY+"px",t.style.left=o.minX+"px",t.style.width=o.maxX-o.minX+"px",t.style.height=o.maxY-o.minY+"px",t.style.border="2px solid gray",t.style.backgroundColor="rgba(128, 128, 128, 0.1)",t.style.pointerEvents="none",t.style.zIndex=Vg,e.append(t);let r=document.createElement("div");r.textContent="viewfinder",r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.padding="2px 4px",r.style.backgroundColor="gray",r.style.color="white",r.style.fontSize="12px",r.style.fontWeight="bold",r.style.fontFamily="monospace",r.style.zIndex="1001",t.appendChild(r);let n=document.createElement("div");return n.textContent="",n.style.position="absolute",n.style.bottom="0",n.style.right="0",n.style.padding="2px 4px",n.style.backgroundColor="gray",n.style.color="white",n.style.fontSize="12px",n.style.fontWeight="bold",n.style.fontFamily="monospace",n.style.zIndex="1001",t.appendChild(n),{squareEl:t,labelEl:r,scoreLabelEl:n}}function Dh(o,e){o.textContent=e}function Th(o,e){e!==void 0?o.textContent=`Score: ${e.toFixed(3)}`:o.textContent=""}y();function Ph(o,e,t){if(!o.visible)return;let r=o;if(r.isMesh||r.isLine||r.isPoints){let n=r.geometry;if(n?.isBufferGeometry){let i=n.attributes.position;if(i)for(let s=0;s<i.count;s++)t.fromBufferAttribute(i,s),t.applyMatrix4(o.matrixWorld),e.push(t.clone())}}for(let n of o.children)Ph(n,e,t)}function Ih(o,e){let t=[];return o instanceof Je&&Ph(o,t,e),t}var en=.001;function Oh(o){if(o.length===0)return[];let e=[],t=o[o.length-1],r=t.w>en;for(let n=0;n<o.length;n++){let i=o[n],s=i.w>en;if(s){if(!r){let a=(en-t.w)/(i.w-t.w);e.push({x:t.x+a*(i.x-t.x),y:t.y+a*(i.y-t.y),z:t.z+a*(i.z-t.z),w:en})}e.push(i)}else if(r){let a=(en-t.w)/(i.w-t.w);e.push({x:t.x+a*(i.x-t.x),y:t.y+a*(i.y-t.y),z:t.z+a*(i.z-t.z),w:en})}t=i,r=s}return e}function Lh(o,e,t){if(o.length===0)return[];let r=o;return r=Qn(r,1,0,0),r=Qn(r,-1,0,e),r=Qn(r,0,1,0),r=Qn(r,0,-1,t),r}y();var Ni=class{bbox;center;el=null;labelEl=null;scoreLabelEl=null;create(e,t,r,n,i){this.labelEl&&(this.labelEl.remove(),this.labelEl=null),this.scoreLabelEl&&(this.scoreLabelEl.remove(),this.scoreLabelEl=null),this.el&&(this.el.remove(),this.el=null);let s=Qt(r,e,t),a=s.left,l=s.top,c=e-s.left-s.right,d=t-s.top-s.bottom,u=new V(a+c/2,l+d/2),v=c/2*(2-2/1.2)/2,f=Math.max(a,u.x-v),M=Math.min(e-s.right,u.x+v),p=Math.max(l,u.y-v),m=Math.min(t-s.bottom,u.y+v),g=(f+M)/2,b=(p+m)/2;if(this.bbox={minX:f,maxX:M,minY:p,maxY:m},this.center=new V(g,b),n&&i){let{squareEl:x,labelEl:S,scoreLabelEl:C}=Eh(this.bbox,i);this.el=x,this.labelEl=S,this.scoreLabelEl=C}}updateLabel(e){this.labelEl&&Dh(this.labelEl,e)}updateScore(e){this.scoreLabelEl&&Th(this.scoreLabelEl,e)}destroy(){this.labelEl&&(this.labelEl.remove(),this.labelEl=null),this.scoreLabelEl&&(this.scoreLabelEl.remove(),this.scoreLabelEl=null),this.el&&(this.el.remove(),this.el=null)}};var Jg=250,zi=class extends q{cameraDirty=!0;focusablesDirty=!0;state;camera;cameraFrustum=new Nr;viewProjectionMatrix=new K;tempScreenPos=new O;debugEl=null;collisions=new Map;focusableEntities=new Map;debug=!1;debugBBoxElements=new Map;viewfinder=new Ni;screenBoundsMap=new Map;screenDiagonal=1;lastPublishedEntities;constructor(e,t){super(),this.state=e,this.camera=t,this.resize()}resize(){this.screenDiagonal=Math.sqrt(this.state.canvasWidth*this.state.canvasWidth+this.state.canvasHeight*this.state.canvasHeight),this.createViewfinder()}createViewfinder(){this.debugEl&&this.debugEl.remove();for(let e of this.debugBBoxElements.values())e.remove();this.debugBBoxElements.clear(),this.debug&&(this.debugEl=wh()),this.viewfinder.create(this.state.canvasWidth,this.state.canvasHeight,this.state.insetsPadding,this.debug,this.debugEl)}simplifyVertices(e){return e.length<3?e:Sh(e).map(t=>e[t.index])}computeScreenSpaceBounds(e){let{vertices:t,boundingBox:r}=e;if(t==null||t.length<3||r==null||r.isEmpty()||!this.cameraFrustum.intersectsBox(r))return;let n=this.viewProjectionMatrix.elements,i=t.map(d=>({x:n[0]*d.x+n[4]*d.y+n[8]*d.z+n[12],y:n[1]*d.x+n[5]*d.y+n[9]*d.z+n[13],z:n[2]*d.x+n[6]*d.y+n[10]*d.z+n[14],w:n[3]*d.x+n[7]*d.y+n[11]*d.z+n[15]})),s=Oh(i);if(s.length<3)return;let a=1/0,l=[];for(let d of s){let u=d.x/d.w,h=d.y/d.w;l.push({x:(u+1)/2*this.state.canvasWidth,y:(-h+1)/2*this.state.canvasHeight}),d.w<a&&(a=d.w)}let c=Lh(l,this.state.canvasWidth,this.state.canvasHeight);if(!(c.length<=0))return{screenBBox:bl(l),clippedScreenBBox:this.debug?bl(c):void 0,closestZ:a}}updateFocusableEntities(){this.focusableEntities.clear();let e;for(let t of this.state.geometry3DsInScene){if(t==null)continue;let r;if(t.type==="group-container"||t.type==="feature-collection"?r=t.visible:r=t.components[1]?.visible??!0,!!r&&(e=t.type==="group-container"?t.components[1]:t.components[4],e!==void 0&&e.type==="focusable")){let n=String(t.type==="group-container"?t.userData.entityId:t.id);if(e.dirty===!0){let i=null;t instanceof Je?i=t:"object3d"in t&&t.object3d instanceof Je&&(i=t.object3d),i&&(e.boundingBox=new de().setFromObject(i),e.vertices=this.simplifyVertices(Ih(i,this.tempScreenPos)),e.dirty=!1)}this.focusableEntities.set(n,e)}}this.focusablesDirty=!1}#e=void 0;update=(e=!1,t=Date.now())=>{this.focusablesDirty&&this.updateFocusableEntities(),!e&&(Date.now()-t>Jg||(this.#e&&cancelAnimationFrame(this.#e),this.#e=requestAnimationFrame(()=>{this.updateRaf()})))};updateRaf(){if(this.focusableEntities.size===0){this.lastPublishedEntities?.length!==0&&(this.lastPublishedEntities=[],this.publish("geometry-in-focus",[]));return}this.cameraDirty&&this.compute()}updateDebugBBoxes(e,t){if(!(!this.debug||!this.debugEl)){Mh(this.debugBBoxElements,e);for(let[r,n]of e){let i=t.has(r),s=this.collisions.get(r);Ch(r,n,this.debugBBoxElements,this.debugEl,i,s)}}}compute(){if(this.collisions.clear(),this.screenBoundsMap.clear(),!this.viewfinder.center)return;this.viewProjectionMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.cameraFrustum.setFromProjectionMatrix(this.viewProjectionMatrix);let e=[];for(let[i,s]of this.focusableEntities){let a=this.computeScreenSpaceBounds(s);if(!a)continue;this.screenBoundsMap.set(i,a);let{screenBBox:l}=a,c=xh(l,this.viewfinder.bbox);if(c>0){e.push(i);let d=(l.minX+l.maxX)/2,u=(l.minY+l.maxY)/2,h=d-this.viewfinder.center.x,v=u-this.viewfinder.center.y,M=1/(1+Math.sqrt(h*h+v*v)/this.screenDiagonal),p=1/(1+Math.abs(a.closestZ)),m=M*.5+c*.35+p*.15;this.collisions.set(i,m)}}let t=Array.from(this.collisions.keys()).sort((i,s)=>(this.collisions.get(s)??0)-(this.collisions.get(i)??0)),r=this.lastPublishedEntities,n=t.length!==r?.length;if(!n&&r){for(let i=0;i<t.length;i++)if(t[i]!==r[i]){n=!0;break}}if(this.debug){let i=t[0];this.viewfinder.updateLabel(i||"viewfinder");let s=i?this.collisions.get(i):void 0;this.viewfinder.updateScore(s);let a=new Set(e);this.updateDebugBBoxes(this.screenBoundsMap,a)}this.cameraDirty=!1,n&&(this.lastPublishedEntities=t,this.publish("geometry-in-focus",t))}showDebug(){this.debug||(this.debug=!0,this.cameraDirty=!0,this.createViewfinder())}hideDebug(){this.debug&&(this.debug=!1,this.createViewfinder())}destroy(){this.#e&&cancelAnimationFrame(this.#e),this.debugEl&&this.debugEl.remove();for(let e of this.debugBBoxElements.values())e.remove();this.debugBBoxElements.clear(),this.collisions.clear(),this.focusableEntities.clear(),this.viewfinder.destroy()}};y();y();y();y();y();function Ui(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return o.geometry.coordinates;if(o.type==="Point")return o.coordinates}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return o;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Or(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function tn(o){return o.type==="Feature"?o.geometry:o}function NE(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}function Lr(o,e,t){if(t===void 0&&(t={}),!o)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=Ui(o),n=tn(e),i=n.type,s=e.bbox,a=n.coordinates;if(s&&Kg(r,s)===!1)return!1;i==="Polygon"&&(a=[a]);for(var l=!1,c=0;c<a.length&&!l;c++)if(Ah(r,a[c][0],t.ignoreBoundary)){for(var d=!1,u=1;u<a[c].length&&!d;)Ah(r,a[c][u],!t.ignoreBoundary)&&(d=!0),u++;d||(l=!0)}return l}function Ah(o,e,t){var r=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var n=0,i=e.length-1;n<e.length;i=n++){var s=e[n][0],a=e[n][1],l=e[i][0],c=e[i][1],d=o[1]*(s-l)+a*(l-o[0])+c*(o[0]-s)===0&&(s-o[0])*(l-o[0])<=0&&(a-o[1])*(c-o[1])<=0;if(d)return!t;var u=a>o[1]!=c>o[1]&&o[0]<(l-s)*(o[1]-a)/(c-a)+s;u&&(r=!r)}return r}function Kg(o,e){return e[0]<=o[0]&&e[1]<=o[1]&&e[2]>=o[0]&&e[3]>=o[1]}y();y();function Qg(o){if(!o)throw new Error("geojson is required");var e=[];return Ut(o,function(t){ey(t,e)}),fr(e)}function ey(o,e){var t=[],r=o.geometry;if(r!==null){switch(r.type){case"Polygon":t=Or(r);break;case"LineString":t=[Or(r)]}t.forEach(function(n){var i=ty(n,o.properties);i.forEach(function(s){s.id=e.length,e.push(s)})})}}function ty(o,e){var t=[];return o.reduce(function(r,n){var i=Po([r,n],e);return i.bbox=ry(r,n),t.push(i),n}),t}function ry(o,e){var t=o[0],r=o[1],n=e[0],i=e[1],s=t<n?t:n,a=r<i?r:i,l=t>n?t:n,c=r>i?r:i;return[s,a,l,c]}var vl=Qg;var cp=Cn(ap(),1);function tb(o,e){var t={},r=[];if(o.type==="LineString"&&(o=oa(o)),e.type==="LineString"&&(e=oa(e)),o.type==="Feature"&&e.type==="Feature"&&o.geometry!==null&&e.geometry!==null&&o.geometry.type==="LineString"&&e.geometry.type==="LineString"&&o.geometry.coordinates.length===2&&e.geometry.coordinates.length===2){var n=lp(o,e);return n&&r.push(n),fr(r)}var i=(0,cp.default)();return i.load(vl(e)),aa(vl(o),function(s){aa(i.search(s),function(a){var l=lp(s,a);if(l){var c=Or(l).join(",");t[c]||(t[c]=!0,r.push(l))}})}),fr(r)}function lp(o,e){var t=Or(o),r=Or(e);if(t.length!==2)throw new Error("<intersects> line1 must only contain 2 coordinates");if(r.length!==2)throw new Error("<intersects> line2 must only contain 2 coordinates");var n=t[0][0],i=t[0][1],s=t[1][0],a=t[1][1],l=r[0][0],c=r[0][1],d=r[1][0],u=r[1][1],h=(u-c)*(s-n)-(d-l)*(a-i),v=(d-l)*(i-c)-(u-c)*(n-l),f=(s-n)*(i-c)-(a-i)*(n-l);if(h===0)return null;var M=v/h,p=f/h;if(M>=0&&M<=1&&p>=0&&p<=1){var m=n+M*(s-n),g=i+M*(a-i);return To([m,g])}return null}var $i=tb;y();function qi(o,e){e===void 0&&(e={});var t=tn(o);switch(!e.properties&&o.type==="Feature"&&(e.properties=o.properties),t.type){case"Polygon":return rb(t,e);case"MultiPolygon":return nb(t,e);default:throw new Error("invalid poly")}}function rb(o,e){e===void 0&&(e={});var t=tn(o),r=t.coordinates,n=e.properties?e.properties:o.type==="Feature"?o.properties:{};return dp(r,n)}function nb(o,e){e===void 0&&(e={});var t=tn(o),r=t.coordinates,n=e.properties?e.properties:o.type==="Feature"?o.properties:{},i=[];return r.forEach(function(s){i.push(dp(s,n))}),fr(i)}function dp(o,e){return o.length>1?Rc(o,e):Po(o[0],e)}function ob(o,e){var t=!0;return Ut(o,function(r){Ut(e,function(n){if(t===!1)return!1;t=ib(r.geometry,n.geometry)})}),t}function ib(o,e){switch(o.type){case"Point":switch(e.type){case"Point":return!cb(o.coordinates,e.coordinates);case"LineString":return!up(e,o);case"Polygon":return!Lr(o,e)}break;case"LineString":switch(e.type){case"Point":return!up(o,e);case"LineString":return!sb(o,e);case"Polygon":return!hp(e,o)}break;case"Polygon":switch(e.type){case"Point":return!Lr(e,o);case"LineString":return!hp(o,e);case"Polygon":return!ab(e,o)}}return!1}function up(o,e){for(var t=0;t<o.coordinates.length-1;t++)if(lb(o.coordinates[t],o.coordinates[t+1],e.coordinates))return!0;return!1}function sb(o,e){var t=$i(o,e);return t.features.length>0}function hp(o,e){for(var t=0,r=e.coordinates;t<r.length;t++){var n=r[t];if(Lr(n,o))return!0}var i=$i(e,qi(o));return i.features.length>0}function ab(o,e){for(var t=0,r=o.coordinates[0];t<r.length;t++){var n=r[t];if(Lr(n,e))return!0}for(var i=0,s=e.coordinates[0];i<s.length;i++){var a=s[i];if(Lr(a,o))return!0}var l=$i(qi(o),qi(e));return l.features.length>0}function lb(o,e,t){var r=t[0]-o[0],n=t[1]-o[1],i=e[0]-o[0],s=e[1]-o[1],a=r*s-n*i;return a!==0?!1:Math.abs(i)>=Math.abs(s)?i>0?o[0]<=t[0]&&t[0]<=e[0]:e[0]<=t[0]&&t[0]<=o[0]:s>0?o[1]<=t[1]&&t[1]<=e[1]:e[1]<=t[1]&&t[1]<=o[1]}function cb(o,e){return o[0]===e[0]&&o[1]===e[1]}var pp=ob;function Bl(o,e){var t=!1;return Ut(o,function(r){Ut(e,function(n){if(t===!0)return!0;t=!pp(r.geometry,n.geometry)})}),t}var gp=Cn(Ki());var Gl="outdoor-system-debug-container",mp=!1;function db(o,e,t){let r=Math.pow(2,o),n=new xr(e/r,t/r).toLngLat(),i=new xr((e+1)/r,(t+1)/r).toLngLat();return[n.lng,i.lat,i.lng,n.lat]}function ub(o,e){return o[0]<=e[2]&&o[2]>=e[0]&&o[1]<=e[3]&&o[3]>=e[1]}var hb=15e-6;function pb(o,e){if(o.length<=5)return o;let t=(0,gp.default)(o.map(s=>({x:s[0],y:s[1]})),e,!0);if(t.length<4)return o;let r=t.map(s=>[s.x,s.y]),n=r[0],i=r[r.length-1];return(n[0]!==i[0]||n[1]!==i[1])&&r.push([n[0],n[1]]),r}function fp(o){return{bbox:_c(ia(o)),simplified:ia(o.map(e=>pb(e,hb)))}}function mb(o,e){let t=1/0,r=1/0,n=-1/0,i=-1/0,s=o.type==="MultiPolygon"?o.coordinates.length:1;for(let a=0;a<s;a++){let l=o.type==="MultiPolygon"?o.coordinates[a]:o.coordinates;for(let c=0;c<l.length;c++){let d=l[c];for(let u=0;u<d.length;u++){let h=d[u];h[0]<t&&(t=h[0]),h[0]>n&&(n=h[0]),h[1]<r&&(r=h[1]),h[1]>i&&(i=h[1])}}}return t<=e[2]&&n>=e[0]&&r<=e[3]&&i>=e[1]}var fb=500,Qi=class extends q{#e;idleQueue;#n="";#i=new Set;#o=[];#s=new Set;#a;#l=[];#d=gb();#f;#t=e=>{if(!this.#e)throw new Error("Map not initialized");let r=[[e[0],e[1]],[e[2],e[1]],[e[2],e[3]],[e[0],e[3]]].map(l=>this.#e.project(l)),n=Math.max(...r.map(l=>l.x)),i=Math.min(...r.map(l=>l.x)),s=Math.max(...r.map(l=>l.y)),a=Math.min(...r.map(l=>l.y));return[new ba(i,a),new ba(n,s)]};#u=(e,t)=>{if(!this.#e)return;let r=this.#e.on(e,t);r?.unsubscribe&&this.onAbort(()=>r.unsubscribe())};#r=()=>{this.#y.clear(),this.#v.clear()};#b=()=>{this.#f&&(this.#f.controller.abort(),this.#f=void 0)};#g=()=>{this.#b();let e=new Set(this.#y),t=new AbortController;t.signal.addEventListener("abort",()=>{this.#y.clear();for(let n of e)this.#y.add(n);this.idleQueue.clearAll()},{once:!0});let r={controller:t};return this.#f=r,r};hideLayersIntersectingPolygons(e,t){this.#b(),this.#r(),this.#d.buildStart();let r=[];for(let n of e)if(n.geometry.type==="Polygon")r.push(fp(n.geometry.coordinates));else if(n.geometry.type==="MultiPolygon")for(let i of n.geometry.coordinates)r.push(fp(i));this.#a=r,this.#l=r.map((n,i)=>()=>this.#m(i)),this.#d.buildDone(this.#a.length);for(let n of t)this.#i.add(n);this.#M(),this.#p()}#c=zt(()=>{this.#p()},fb);constructor(e,t=3e3){super(),this.idleQueue=new Pr(t),e&&(this.#e=e,this.#u("styledata",this.#T),this.#u("sourcedata",r=>{this.#s.size>0&&!this.#s.has(r.sourceId)||r.tile!=null&&this.#S(r.tile)&&this.#C(r.tile)&&this.#c()})),mp&&this.#R()}#S(e){let t=e.tileID?.canonical;if(!t)return!0;let r=db(t.z,t.x,t.y),n=this.#a;if(n){for(let i=0;i<n.length;i++)if(ub(r,n[i].bbox))return!0}return!1}#C(e){let t=e.tileID?.canonical;if(!t)return!0;let r=`${t.z}/${t.x}/${t.y}`;return this.#v.has(r)?!1:(this.#v.add(r),!0)}#M(){let e=new Set,t=new Set;if(this.#e)for(let r of this.#i){let n=this.#e.getLayer(r);n&&(e.add(r),n.source&&t.add(n.source))}this.#o=Array.from(e),this.#s=t}#p=async()=>{if(mp&&this.#a&&this.#F(),!this.#e||!this.#o||this.#o.length===0||!this.#a||this.#a.length===0)return;let e=this.#g(),t=this.#y.size;this.#d.computeStart();let r=()=>{if(this.#f!==e)return;let n=this.#y.size-t;if(n>0){this.#d.beginSpan();let i=[];for(let a of this.#y)i.push(a);let s=["!",["in",["id"],["literal",i]]];this.#o.forEach(a=>{this.#e?.setFilter(a,s)}),this.#d.endSpan()}this.#d.computeDone(this.#l.length,n,this.#y.size),this.#f=void 0};for(let n=0;n<this.#l.length;n++)this.idleQueue.add(this.#l[n]);this.idleQueue.onComplete(r)};#m=e=>{if(!this.#e||!this.#a)return;this.#d.beginSpan();let t=this.#a[e],r=t.simplified,n=t.bbox,i=this.#t(n),s=this.#e.queryRenderedFeatures(i,{layers:this.#o});for(let a=0;a<s.length;a++){let l=s[a],c=l.id;if(c==null||this.#y.has(c))continue;let d=l.geometry;d==null||!("coordinates"in d)||d.type!=="Polygon"&&d.type!=="MultiPolygon"||mb(d,n)&&Bl(r,d)&&this.#y.add(c)}this.#d.endSpan()};#y=new Set;#v=new Set;get#A(){return this.idleQueue.size!==0}#T=e=>{if(this.#e&&e&&e.dataType==="style"&&e.type==="styledata"&&this.#i.size>0){let t=e?.style?.stylesheet?.id;if(!t||t!==this.#n){let r=this.#n;this.#d.styleLatch(r||"",t||""),this.#b(),this.#r(),this.#n=t,this.#M(),this.#c()}}};#R(){if(!document.getElementById(Gl)&&this.#e){let e=document.createElement("div");e.id=Gl,e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.bottom="0",e.style.right="0",e.style.pointerEvents="none",e.style.zIndex="1000",this.#e.getContainer().appendChild(e)}}#F(){let e=document.getElementById(Gl);if(!e||!this.#a||!this.#e)return;let t=e.querySelectorAll('[id^="polygon-box-"]');for(let r=0;r<t.length;r++)t[r].remove();for(let r=0;r<this.#a.length;r++){let n=this.#t(this.#a[r].bbox),i=document.createElement("div");i.id=`polygon-box-${r}`,i.style.position="absolute",e.appendChild(i);let s=[Math.min(n[0].x,n[1].x),Math.min(n[0].y,n[1].y)],a=[Math.max(n[0].x,n[1].x),Math.max(n[0].y,n[1].y)];i.style.top=s[1]+"px",i.style.left=s[0]+"px",i.style.width=a[0]-s[0]+"px",i.style.height=a[1]-s[1]+"px",i.style.border=`2px solid ${this.#A?"red":"blue"}`}}destroy(){this.#c.cancel(),this.#b(),super.destroy()}};function Ar(){return R.logState<=0}function gb(){let o=0,e=0,t=0;return{buildStart(){Ar()&&(t=performance.now())},buildDone(r){Ar()&&R.debug(`[OutdoorLayers] built ${r} footprints in ${(performance.now()-t).toFixed(1)}ms`)},computeStart(){Ar()&&(o=0)},beginSpan(){Ar()&&(e=performance.now())},endSpan(){Ar()&&(o+=performance.now()-e)},computeDone(r,n,i){Ar()&&R.debug(`[OutdoorLayers] compute cpu ${o.toFixed(1)}ms | polys=${r} added=${n} matched=${i}`)},styleLatch(r,n){Ar()&&R.debug(`[OutdoorLayers] styledata stylesheet id "${r}" => "${n}"${!r&&n?" (initial id latch)":""}`)}}}y();y();y();y();var es=class extends jt{tangentData;parameters;constructor(e,t={}){super(),Object.defineProperty(this,"type",{value:"RibbonGeometry"}),this.parameters={path:e};let r=t.segments??64,n=new O,i=new O,s=new O(0,0,1),a=(r+1)*2,l=new Float32Array(a*3),c=new Float32Array(a*3),d=new Float32Array(a*2),u=new Float32Array(a),h=[];this.tangentData=new Float32Array((r+1)*3);let v=0,f=0,M=0;for(let p=0;p<=r;p++){let m=p/r;e.getPointAt(m,n),e.getTangentAt(m,i);let g=p*3;this.tangentData[g]=i.x,this.tangentData[g+1]=i.y,this.tangentData[g+2]=i.z,l[v++]=n.x,l[v++]=n.y,l[v++]=n.z,l[v++]=n.x,l[v++]=n.y,l[v++]=n.z,u[M++]=-1,u[M++]=1,d[f++]=0,d[f++]=m,d[f++]=1,d[f++]=m;let b=p*2*3;c[b]=s.x,c[b+1]=s.y,c[b+2]=s.z,c[b+3]=s.x,c[b+4]=s.y,c[b+5]=s.z}for(let p=0;p<r;p++){let m=p*2;h.push(m,m+2,m+1),h.push(m+1,m+2,m+3)}this.setIndex(h),this.setAttribute("position",new At(l,3)),this.setAttribute("normal",new At(c,3)),this.setAttribute("uv",new At(d,2)),this.setAttribute("side",new At(u,1))}};y();var ts=class extends nd{innerCurve;tStart;tEnd;constructor(e,t,r=!1){super(),this.innerCurve=e,r&&t>=4?(this.tStart=1/(t-1),this.tEnd=(t-2)/(t-1)):(this.tStart=0,this.tEnd=1)}get points(){return this.innerCurve.points}get tension(){return this.innerCurve.tension}get isTrimmed(){return this.tStart!==0||this.tEnd!==1}getPoint(e,t=new O){let r=this.tStart+e*(this.tEnd-this.tStart);return this.innerCurve.getPoint(r,t)}};y();y();var yb=[0,0,1,0,1,1,0,1],bb=[0,1,2,0,2,3],rs=new O,ns=new O;function bp(o,e){let t=Math.max(1,Math.floor(e)),r=new Float32Array(t*3),n=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t);for(let l=0,c=0;l<t;l++,c+=3){let d=(l+.5)/t;o.getPointAt(d,rs),o.getTangentAt(d,ns),r[c]=rs.x,r[c+1]=rs.y,r[c+2]=rs.z,n[c]=ns.x,n[c+1]=ns.y,n[c+2]=ns.z,i[l]=d,s[l]=l}let a=new ld;return a.instanceCount=t,a.setIndex(new De(new Uint16Array(bb),1)),a.setAttribute("uv",new At(new Float32Array(yb),2)),a.setAttribute("position",new In(r,3)),a.setAttribute("pathTangent",new In(n,3)),a.setAttribute("pathDistance",new In(i,1)),a.setAttribute("dashIndex",new In(s,1)),a}var yp=128,nn=2048,Bt=.6;function os(o,e,t){return o.dashAbsolute?o.dashMeters+o.gapMeters:o.dashRelativeToWidth?(o.dashSize+o.gapSize)*t:(o.dashLength+o.dashGap)*e}function vp(o,e,t){let r=os(o,e,t);if(r<=0)return yp;let n=Math.ceil(e/r),i=yp;for(;i<n&&i<nn;)i*=2;return Math.min(i,nn)}function on(o,e,t,r){let n=o.screenSpace?Math.max(t*2*r,Bt):t*2,i=os(o,e,n);return i>0?Math.max(1,Math.min(e/i,o.maxDashCount)):o.maxDashCount}var vb=8,xb=2048,kl=new Pn,xp=new K,Sp=new qc,is=new O,Mp=new O,Nl=new O,Cp=new O,wp=new O,ss=new O,as=new O,Ep="centerlineRaycast";function zl(o,e,t,r,n){if(o===e)return o;let i=r!==t?Math.max(0,Math.min(1,(n-t)/(r-t))):0;return o+(e-o)*i}function Sb(o){let e=o.nearRadius.value,t=o.farRadius.value,n=zl(e,t,o.nearZoom.value,o.farZoom.value,o.cameraParameters.value.x)*(o.screenSpace.value?o.metersPerPixel.value:1);return o.screenSpace.value?Math.max(n,Bt/2):n}function Mb(o,e){let t=new Float32Array(e*3),r=new Float32Array(e*3),n=1/(e-1);for(let i=0;i<e;i++){o.getPointAt(i*n,ss),o.getTangentAt(i*n,as);let s=i*3;t[s]=ss.x,t[s+1]=ss.y,t[s+2]=ss.z,r[s]=as.x,r[s+1]=as.y,r[s+2]=as.z}return{positions:t,tangents:r}}function Dp(o){let e=o.getLength(),t=Math.max(2,Math.min(xb,Math.ceil(e*vb))),{positions:r,tangents:n}=Mb(o,t),i=Cb(r,t);return{positions:r,tangents:n,size:t,bounds:i}}function Cb(o,e){let t=1/0,r=1/0,n=1/0,i=-1/0,s=-1/0,a=-1/0;for(let h=0;h<e;h++){let v=h*3,f=o[v],M=o[v+1],p=o[v+2];f<t&&(t=f),M<r&&(r=M),p<n&&(n=p),f>i&&(i=f),M>s&&(s=M),p>a&&(a=p)}let l=(t+i)/2,c=(r+s)/2,d=(n+a)/2,u=0;for(let h=0;h<e;h++){let v=h*3,f=o[v]-l,M=o[v+1]-c,p=o[v+2]-d,m=f*f+M*M+p*p;m>u&&(u=m)}return new Pn(new O(l,c,d),Math.sqrt(u))}function wb(o){return o.userData[Ep]}function Eb(o,e){let t=wb(this.geometry);if(!t)return;let r=this.matrixWorld,n=this.material.uniforms,{centerline:i}=t,{positions:s,count:a,stride:l}=i;if(a<2)return;let c=t.bounds;if(c===null&&(this.geometry.boundingSphere===null&&this.geometry.computeBoundingSphere(),c=this.geometry.boundingSphere),c===null)return;let u=Sb(n)*Math.max(1,n.highlightWidthMultiplier.value);if(kl.copy(c).applyMatrix4(r),kl.radius+=u,!o.ray.intersectsSphere(kl))return;xp.copy(r).invert(),Sp.copy(o.ray).applyMatrix4(xp);let h=r.getMaxScaleOnAxis(),v=h!==0?u/h:u,f=v*v,M=1/0,p=1/0,m=-1;is.set(s[0],s[1],s[2]);for(let g=1;g<a;g++){Mp.copy(is);let b=g*l;is.set(s[b],s[b+1],s[b+2]);let x=Sp.distanceSqToSegment(Mp,is,Nl,Cp);if(x>f)continue;Nl.applyMatrix4(r);let S=o.ray.origin.distanceTo(Nl);S<o.near||S>o.far||!(S<M-u)&&!(S<=M+u&&x<p)||(M=S,p=x,m=g-1,wp.copy(Cp))}m!==-1&&e.push({distance:M,point:wp.clone().applyMatrix4(r),index:m,face:null,faceIndex:null,object:this})}function Ul(o,e,t){o.geometry.userData[Ep]={centerline:e,bounds:t},o.raycast=Eb}function Tp(o){let e=o.geometry.attributes.position;if(e===void 0)return;let t={positions:e.array,count:e.count>>>1,stride:6};Ul(o,t,null)}y();function Db(o,e,t){let r=new Float32Array(t*2*4),n=0,i=t*4;for(let a=0;a<t;a++){let l=a*3;r[n]=o[l],r[n+1]=o[l+1],r[n+2]=o[l+2],r[n+3]=1,r[i]=e[l],r[i+1]=e[l+1],r[i+2]=e[l+2],r[i+3]=0,n+=4,i+=4}let s=new Qc(r,t,2,_o,Vc);return s.minFilter=fa,s.magFilter=fa,s.wrapS=ma,s.wrapT=ma,s.needsUpdate=!0,{texture:s,size:t}}function Pp({component:o,curve:e,baked:t,nearRadius:r,metersPerPixel:n,uniforms:i}){let s=e.getLength(),a=o.screenSpace?Bt:r*2,l=vp(o,s,a);o.maxDashCount=l,o.curveLength=s;let c=bp(e,l);i.dashCount.value=on(o,s,r,n);let{texture:d,size:u}=Db(t.positions,t.tangents,t.size);return i.curveTexture.value=d,i.curveTextureSize.value=u,{geometry:c}}y();var ls=`// Force the compiler to compute gl_Position the same way across all shader
156
- // programs that share this vertex transform. Without this, Apple Silicon /
157
- // iOS GPU drivers may use different optimized FP paths between shader
158
- // variants, producing precision drift that shows up as Z-fighting and path
159
- // micro-jitter. See https://bugs.webkit.org/show_bug.cgi?id=237434
160
- invariant gl_Position;
161
-
162
- attribute float pathDistance;
163
- attribute vec3 pathNormal;
164
- attribute vec3 pathTangent;
165
- attribute float side;
166
- // Stable per-dash identity (discrete-dash geometry only). Drives formula placement
167
- // and surplus-instance culling (see the isDiscreteDash block in main()).
168
- attribute float dashIndex;
169
-
170
-
171
- uniform vec2 uvScale;
172
- uniform float vertexes;
173
- uniform float complete;
174
- uniform float nearRadius;
175
- uniform float farRadius;
176
- uniform float nearZoom;
177
- uniform float farZoom;
178
- uniform float pulse;
179
- uniform float pulseLength;
180
- uniform bool pathIsVertical;
181
- uniform bool displayArrowsOnPath;
182
- uniform vec2 cameraParameters;
183
- uniform bool isRibbon;
184
- uniform bool isDiscreteDash;
185
- uniform float pathLength;
186
- uniform float dashCount;
187
-
188
- // A discrete-dash path is a dashed path whose dashes are separate primitives, so the
189
- // dash's along-path extent is the dash "on" size in whichever mode is active \u2014
190
- // there is no separate dash-length option. These mirror the fragment shader's
191
- // dash uniforms; only the "on" side is needed here (the gap is already baked
192
- // into dashCount as spacing).
193
- uniform bool dashRelativeToWidth;
194
- uniform bool dashAbsolute;
195
- uniform float dashSize;
196
- uniform float dashMeters;
197
- uniform float dashLength;
198
- uniform sampler2D curveTexture;
199
- uniform float curveTextureSize;
200
- uniform float billboardThreshold;
201
- uniform mat4 cameraViewMatrix;
202
- uniform bool screenSpace;
203
- uniform float metersPerPixel;
204
- uniform float minPathWidthMeters;
205
-
206
- varying float zoomLevel;
207
- varying float radius;
208
- varying vec2 fragTexcoord;
209
- varying float fragTopTextureU;
210
- varying float fragPathDistance;
211
- // Dash length \xF7 dash width. Derived here rather than passed as a uniform because
212
- // the absolute and length-scaling modes divide a world length by the dash's
213
- // width, and that width is only known after the screen-space px\u2192meters
214
- // conversion below. The fragment shader needs the same ratio to keep the corner
215
- // radius and the arrow isotropic in world space.
216
- varying float fragDashAspect;
217
-
218
- uniform float highlightStartFraction;
219
- uniform float highlightEndFraction;
220
- uniform float highlightCompleteFraction;
221
- uniform float highlightWidthMultiplier;
222
- uniform vec3 highlightColor;
223
-
224
- uniform float travelledEndFraction;
225
- uniform vec3 travelledColor;
226
-
227
- float flattenFactor = 0.0;
228
-
229
- // Map the x value from the range [xMin, xMax] to the range [yMin, yMax] using
230
- // linear interpolation/extrapolation.
231
- //
232
- // This performs a pure linear mapping y = mx + b where
233
- // 'm = (yMax - yMin) / (xMax - xMin)',
234
- // 'b = -xMin * (yMax - yMin) / (xMax - xMin) + yMin'.
235
- float remap(float x, float xMin, float xMax, float yMin, float yMax) {
236
- return (x - xMin) / (xMax - xMin) * (yMax - yMin) + yMin;
237
- }
238
-
239
- // Map the x value from [xMin, xMax] to the range [yMin, yMax] using linear
240
- // interpolation, clamping result values outside [yMin, yMax].
241
- float clampRemap(float x, float xMin, float xMax, float yMin, float yMax) {
242
- return clamp(remap(x, xMin, xMax, yMin, yMax), yMin, yMax);
243
- }
244
-
245
- // Sample the baked curve texture at arc-length fraction s (row 0 = positions,
246
- // row 1 = tangents). Float textures aren't guaranteed to support hardware
247
- // linear filtering, so we fetch the two neighbouring texels (Nearest) and lerp
248
- // manually. This keeps flowing dashes smooth between samples on any GPU.
249
- vec3 sampleCurveRow(float s, float row) {
250
- float fu = clamp(s, 0.0, 1.0) * (curveTextureSize - 1.0);
251
- float i0 = floor(fu);
252
- float frac = fu - i0;
253
- float u0 = (i0 + 0.5) / curveTextureSize;
254
- float u1 = (i0 + 1.5) / curveTextureSize;
255
- vec3 a = texture2D(curveTexture, vec2(u0, row)).xyz;
256
- vec3 b = texture2D(curveTexture, vec2(u1, row)).xyz;
257
- return mix(a, b, frac);
258
- }
259
-
260
- // Sample a discrete dash's arc-length fraction, centre, and tangent from the
261
- // baked curve. Returns false when the instance is surplus (beyond the per-frame
262
- // effective count), so the caller writes an off-screen vertex for the cost of a
263
- // compare + branch rather than a texture fetch. The +0.5 mirrors the
264
- // (dashIndex + 0.5) / dashCount placement: a dash is visible while its centre
265
- // lands before s = 1, so a non-integer count never wraps its last visible dash
266
- // back over dash 0.
267
- bool sampleDiscreteDash(out vec3 center, out vec3 tangent, out float s) {
268
- if (dashIndex + 0.5 >= dashCount) {
269
- return false;
270
- }
271
- // Formula placement: every dash's arc-length position is derived from its
272
- // index and the effective count (a per-frame uniform), not from a baked
273
- // position. Each dash sits at (dashIndex + 0.5) / dashCount \u2014 its cell.
274
- s = fract((dashIndex + 0.5) / dashCount);
275
- center = sampleCurveRow(s, 0.25);
276
- tangent = sampleCurveRow(s, 0.75);
277
- return true;
278
- }
279
-
280
- // The dash's along-path half-extent relative to its width. Width-scaling is
281
- // already a multiple of the width, so it *is* the aspect; the other two modes
282
- // produce a world length that must be divided by the (possibly screen-space)
283
- // width here, which is why this can't be a CPU-side uniform.
284
- float computeDashAspect(float dashWorldRadius) {
285
- float dashWorldLength;
286
- if (dashRelativeToWidth) {
287
- dashWorldLength = dashSize * dashWorldRadius * 2.0;
288
- } else if (dashAbsolute) {
289
- dashWorldLength = dashMeters;
290
- } else {
291
- dashWorldLength = dashLength * pathLength;
292
- }
293
- return max(dashWorldLength / max(dashWorldRadius * 2.0, 1e-4), 0.01);
294
- }
295
-
296
- // A unit vector perpendicular to along. Prefer the axis in the preferred plane
297
- // (the billboard width axis) when it's well-defined; otherwise fall back to the
298
- // world axis least parallel to along. A vector is parallel to at most one world
299
- // axis, so the select always resolves \u2014 no nested near-zero cascade.
300
- vec3 perpendicular(vec3 along, vec3 preferred) {
301
- vec3 r = cross(along, preferred);
302
- float lenSq = dot(r, r);
303
- if (lenSq < 1e-6) {
304
- r = cross(along, abs(along.z) < 0.9 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0));
305
- lenSq = dot(r, r);
306
- }
307
- return r * inversesqrt(lenSq);
308
- }
309
-
310
- // Build the (right, up) basis for one dash. Steep (near-vertical) sections
311
- // billboard so dashes on connection paths keep their shape instead of flattening
312
- // into ellipses. The long axis (up) always stays on the real 3D tangent so the
313
- // dash \u2014 and its arrow \u2014 keeps tracking the travel direction; only the width
314
- // (right) rolls toward the camera via cross(tangent, viewDir), the same
315
- // tangent-aligned billboard the ribbon branch uses. Returns false only when no
316
- // travel direction survives (near-vertical tangent with billboarding off), so the
317
- // caller draws the dash square rather than along an arbitrary world axis.
318
- bool computeDashBasis(vec3 tangent, out vec3 right, out vec3 up) {
319
- bool billboard = billboardThreshold >= 0.0 && abs(tangent.z) >= billboardThreshold;
320
- if (billboard) {
321
- // Keep the dash's long axis on the real 3D tangent so its orientation (and
322
- // arrow) tracks the travel direction rather than rolling with the camera's
323
- // pitch/roll. Only the width billboards, via cross(tangent, viewDir) \u2014 the
324
- // same tangent-aligned form the ribbon branch uses, so discrete dashes and
325
- // the ribbon can't disagree on how a steep section faces.
326
- up = normalize(tangent);
327
- vec3 viewDir = -vec3(cameraViewMatrix[0][2], cameraViewMatrix[1][2], cameraViewMatrix[2][2]);
328
- right = perpendicular(up, viewDir);
329
- return true;
330
- }
331
- // Orient the dash along the full 3D tangent so its long axis (and arrow) tilts
332
- // with the path slope instead of lying flat on the ground plane. right stays
333
- // horizontal \u2014 perpendicular to both world-up and the tangent \u2014 so a flat path
334
- // (tangent.z \u2248 0) keeps its existing orientation.
335
- up = normalize(tangent);
336
- right = cross(vec3(0.0, 0.0, 1.0), up);
337
- float rightLen = length(right);
338
- if (rightLen > 0.001) {
339
- right /= rightLen;
340
- return true;
341
- }
342
- // Near-vertical tangent with billboarding off: fall back to world axes.
343
- up = vec3(0.0, 1.0, 0.0);
344
- right = vec3(1.0, 0.0, 0.0);
345
- return false;
346
- }
347
-
348
- void main() {
349
- // Defensive guard: if the position attribute is NaN (which can happen
350
- // transiently after a WebGL context loss + restore on iOS Safari, before
351
- // per-vertex buffers have been re-uploaded), output a vertex outside the
352
- // clip volume so the GPU discards it cleanly. Without this, the ribbon
353
- // expansion below produces a "fan of lines" artifact emanating from a
354
- // single point on the map. NaN is the only value where x != x.
355
- if (position.x != position.x || position.y != position.y || position.z != position.z) {
356
- gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
357
- return;
358
- }
359
-
360
- fragPathDistance = pathDistance;
361
- // Written unconditionally: the fragment shader's reads are all guarded by
362
- // isDiscreteDash today, but an unwritten varying is undefined behaviour and this
363
- // costs nothing.
364
- fragDashAspect = 1.0;
365
-
366
- vec3 adjustedPosition = position;
367
- zoomLevel = clampRemap(cameraParameters.x, nearZoom, farZoom, 0.0, 1.0);
368
-
369
- // Screen-space-aware half-radii in world units. In screen-space mode
370
- // nearRadius/farRadius are pixel half-widths (and equal), so scale by
371
- // metersPerPixel to keep a constant pixel width on screen regardless of zoom.
372
- // Shared by the discrete-dash and ribbon branches below.
373
- // Floored at minPathWidthMeters * 0.5 so zoom-in (metersPerPixel -> 0) never
374
- // shrinks the width below 0.6m \u2014 bounds the dash count and keeps the path
375
- // visible. See ADR 0005.
376
- float effNear = screenSpace ? max(nearRadius * metersPerPixel, minPathWidthMeters * 0.5) : nearRadius;
377
- float effFar = screenSpace ? max(farRadius * metersPerPixel, minPathWidthMeters * 0.5) : farRadius;
378
-
379
- // Only apply normal-based expansion for TubeGeometry
380
- // Ribbons have normal=(0,0,1) which would shift them up incorrectly
381
- if (!isRibbon && !isDiscreteDash) {
382
- float expansionFactor = (farRadius - nearRadius) * zoomLevel;
383
- adjustedPosition += normal * expansionFactor;
384
- }
385
-
386
- // Animate the reveal endpoint from highlightStartFraction to highlightEndFraction
387
- // so the width expansion follows the same reveal as the fragment shader.
388
- float revealedHighlightEnd = mix(highlightStartFraction, highlightEndFraction, highlightCompleteFraction);
389
- bool isHighlighted = fragPathDistance > highlightStartFraction && fragPathDistance <= revealedHighlightEnd;
390
-
391
- // For TubeGeometry: apply highlight width expansion using normal
392
- if (!isRibbon && !isDiscreteDash && isHighlighted) {
393
- adjustedPosition += normal * (highlightWidthMultiplier - 1.) / 2.;
394
- }
395
-
396
- // Discrete dashes: rebuild each dash's quad around its center. The local
397
- // unit-quad corner is encoded in uv, so the size can scale with zoom and the
398
- // highlight without touching the buffer; the fragment shader carves the
399
- // rounded rectangle out of the quad.
400
- //
401
- // discUp is always the travel direction (tangent, or its screen projection
402
- // when billboarding) and discRight is perpendicular to it. Unlike the circle
403
- // this replaced, a rectangle is not rotationally symmetric, so the basis has
404
- // to track the path even when no arrow is drawn \u2014 otherwise an elongated dash
405
- // would point along a world/screen axis instead of along the path.
406
- if (isDiscreteDash) {
407
- vec2 discOffset = (uv - 0.5) * 2.0;
408
-
409
- vec3 dashCenter;
410
- vec3 dashTangent;
411
- float s;
412
- if (!sampleDiscreteDash(dashCenter, dashTangent, s)) {
413
- gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
414
- return;
415
- }
416
- // Downstream reveal/highlight/travelled coloring follows the dash.
417
- fragPathDistance = s;
418
-
419
- float dashWorldRadius = mix(effNear, effFar, zoomLevel);
420
- float dashAspect = computeDashAspect(dashWorldRadius);
421
-
422
- vec3 discRight;
423
- vec3 discUp;
424
- if (!computeDashBasis(dashTangent, discRight, discUp)) {
425
- dashAspect = 1.0;
426
- }
427
- fragDashAspect = dashAspect;
428
-
429
- // discRadius is the half-width across the path; the along-path half-extent
430
- // is stretched by dashAspect.
431
- float discRadius = dashWorldRadius;
432
- if (isHighlighted) {
433
- discRadius *= highlightWidthMultiplier;
434
- }
435
- adjustedPosition = dashCenter + (discRight * discOffset.x + discUp * discOffset.y * dashAspect) * discRadius;
436
- }
437
-
438
- // Unified ribbon width handling for both billboarded and non-billboarded
439
- if (isRibbon && !isDiscreteDash) {
440
- vec3 right;
441
-
442
- // Determine if this vertex should billboard
443
- // billboardThreshold < 0: off, == 0: unconditional, > 0: precomputed sin(angle)
444
- bool shouldBillboard = billboardThreshold >= 0.0
445
- && abs(pathTangent.z) >= billboardThreshold;
446
-
447
- if (shouldBillboard) {
448
- // Camera-facing right vector
449
- vec3 viewDir = -vec3(cameraViewMatrix[0][2], cameraViewMatrix[1][2], cameraViewMatrix[2][2]);
450
- right = perpendicular(pathTangent, viewDir);
451
- } else {
452
- // Flat world-space right vector (perpendicular in XY plane)
453
- right = vec3(-pathTangent.y, pathTangent.x, 0.0);
454
- float rightLen = length(right);
455
- if (rightLen > 0.001) {
456
- right /= rightLen;
457
- } else {
458
- right = vec3(1.0, 0.0, 0.0);
459
- }
460
- }
461
-
462
- // Apply base half-width (geometry stores centerline only)
463
- adjustedPosition += right * effNear * side;
464
-
465
- // Shared: zoom-based expansion
466
- float expansionFactor = (effFar - effNear) * zoomLevel;
467
- adjustedPosition += right * expansionFactor * side;
468
-
469
- // Shared: highlight width expansion (using right instead of normal)
470
- if (isHighlighted) {
471
- float highlightExpansion = effNear * (highlightWidthMultiplier - 1.0);
472
- adjustedPosition += right * highlightExpansion * side;
473
- }
474
- }
475
-
476
- // For TubeGeometry: flatten the bottom half of the tube
477
- if (!isRibbon && !isDiscreteDash && !pathIsVertical) {
478
- // We can get an origin point for the cross-section of the path by
479
- // subtracting the surface normal times the radius, since the surface normal
480
- // points strictly away from the centre.
481
- vec3 origin = position - nearRadius * normal;
482
-
483
- // Determine how far the path extends "up" or "down" in the direction of the
484
- // path normal.
485
- float height = dot(adjustedPosition - origin, pathNormal);
486
-
487
- // For horizontal paths, flatten the bottom half entirely so that it's flat
488
- // against the floor. This makes the path look nicer when it's
489
- // semitransparent behind opaque geometry, so you don't see it
490
- // peeking through.
491
- float desiredHeight = max(height, 0.0);
492
- desiredHeight = desiredHeight * flattenFactor;
493
- float flattenMagnitude = height - desiredHeight;
494
- adjustedPosition = adjustedPosition - pathNormal * flattenMagnitude;
495
- }
496
-
497
- // Transform the vertices into NDC.
498
- vec4 mvPosition = modelViewMatrix * vec4(adjustedPosition, 1.0);
499
- gl_Position = projectionMatrix * mvPosition;
500
-
501
- fragTexcoord = uv;
502
-
503
- // Compute fragTopTextureU for arrow texture mapping
504
- if (isRibbon) {
505
- // For RibbonGeometry: uv.x is already 0-1 across ribbon width
506
- fragTopTextureU = uv.x;
507
- } else {
508
- // For TubeGeometry: compute texture coordinate to handle tube twisting
509
- // We want the arrow texture to always be on the top of the path
510
- vec3 bitangent = cross(normal, pathTangent);
511
- fragTopTextureU = -dot(bitangent, pathNormal) * 0.5 + 0.5;
512
- if (isHighlighted) {
513
- fragTopTextureU = -dot(bitangent, pathNormal * highlightWidthMultiplier) * 0.5 + 0.5;
514
- }
515
- }
516
-
517
- // For ribbon paths this equals mix(effNear, effFar, zoomLevel); tube geometry
518
- // keeps its radius un-scaled, hence the explicit gate below.
519
- radius = mix(nearRadius, farRadius, zoomLevel);
520
- if (screenSpace && isRibbon) {
521
- radius = radius * metersPerPixel;
522
- }
523
- }
524
- `;y();var Hl=`#define ARROW_FADING_POINT 0.15
525
-
526
- uniform float complete;
527
- uniform float nearRadius;
528
- uniform float farRadius;
529
- uniform vec2 resolution;
530
- uniform vec2 cameraParameters;
531
- uniform vec3 color;
532
- uniform float pathLength;
533
- uniform bool showPulse;
534
- uniform vec3 pulseColor;
535
- uniform float pulse;
536
- uniform float pulseLength;
537
- uniform bool pathIsVertical;
538
- uniform bool displayArrowsOnPath;
539
- uniform float arrowAnimationTimer;
540
- uniform float opacityMultiplier;
541
- uniform bool dashed;
542
- uniform float xrayDithering;
543
- uniform float dashLength;
544
- uniform float dashGap;
545
- uniform bool dashRelativeToWidth;
546
- uniform float dashSize;
547
- uniform float gapSize;
548
- uniform bool dashAbsolute;
549
- uniform float dashMeters;
550
- uniform float gapMeters;
551
- uniform sampler2D arrowTexture;
552
-
553
- varying float zoomLevel;
554
- varying float radius;
555
- varying vec2 fragTexcoord;
556
- varying float fragTopTextureU;
557
- varying float fragPathDistance;
558
- // Dash length \xF7 dash width, derived in the vertex shader from the dash "on" size
559
- // (see fragDashAspect there). Only meaningful when isDiscreteDash.
560
- varying float fragDashAspect;
561
-
562
-
563
- uniform float highlightStartFraction;
564
- uniform float highlightEndFraction;
565
- uniform float highlightCompleteFraction;
566
- uniform vec3 highlightColor;
567
- uniform bool highlightDisplayArrowsOnPath;
568
-
569
- uniform float travelledEndFraction;
570
- uniform vec3 travelledColor;
571
-
572
- // Border uniforms for ribbon geometry
573
- uniform bool borderEnabled;
574
- uniform vec3 borderColor;
575
- uniform float borderWidth;
576
- uniform bool borderUseDarken;
577
- uniform bool isRibbon;
578
- uniform bool isDiscreteDash;
579
- // Corner rounding of a dash, 0 = sharp rectangle, 1 = fully rounded (a circle
580
- // when fragDashAspect is 1.0, a stadium when it is larger). Fraction of the short
581
- // half-side, like a CSS border-radius in percent, so it stays proportional as
582
- // the dash resizes with zoom.
583
- uniform float dashCornerRadius;
584
-
585
- // Endcap uniforms for ribbon geometry
586
- // x = start cap enabled (>0), y = end cap enabled (>0)
587
- uniform vec2 endcapEnabled;
588
-
589
- // How long the arrow should be, as a factor of pathRadius. Since we've
590
- // mostly flattened the top of the path, values near 2.0 (the diameter)
591
- // will probably look best.
592
- const float arrowLength = 2.0;
593
-
594
- // How much of a relative margin the arrow texture should have inside the
595
- // area laid out for it. Useful to pull the arrow away from the edges of the
596
- // path, which slope down.
597
- const float arrowMargin = 0.1;
598
-
599
- // Fraction of a dash's width the per-dash arrow occupies. The arrow texture is
600
- // mapped onto this centred fraction of the dash's uv square; the rest of the dash
601
- // stays plain. Lower = smaller arrow inside the dash.
602
- const float dashArrowFill = 0.55;
603
-
604
- // How many arrow-lengths of space should be between arrows on a short path.
605
- const float arrowSpacingOnShortPath = 6.0;
606
-
607
- // How many arrow-lengths of space should be between arrows on a long path.
608
- const float arrowSpacingOnLongPath = 7.5;
609
-
610
- // How long a path must be to be considered "long", as a factor of
611
- // the path radius.
612
- const float longPathLength = 200.;
613
-
614
- // How long a path must be to be considered "short", as a factor of the
615
- // path radius.
616
- const float shortPathLength = 75.;
617
-
618
- // How much of the path's length the fade-in should comprise when going from
619
- // zero opacity to full opacity.
620
- const float completeLength = 0.1;
621
-
622
- // Map the x value from the range [xMin, xMax] to the range [yMin, yMax] using
623
- // linear interpolation/extrapolation.
624
- //
625
- // This performs a pure linear mapping 'y = mx + b' where
626
- // 'm = (yMax - yMin) / (xMax - xMin)',
627
- // 'b = -xMin * (yMax - yMin) / (xMax - xMin) + yMin'.
628
- float remap(float x, float xMin, float xMax, float yMin, float yMax) {
629
- return (x - xMin) / (xMax - xMin) * (yMax - yMin) + yMin;
630
- }
631
-
632
- // Map the x value from [xMin, xMax] to the range [yMin, yMax] using linear
633
- // interpolation, clamping result values outside [yMin, yMax].
634
- float clampRemap(float x, float xMin, float xMax, float yMin, float yMax) {
635
- return clamp(remap(x, xMin, xMax, yMin, yMax), yMin, yMax);
636
- }
637
-
638
- // Signed distance to a rounded rectangle centred on the origin. Negative
639
- // inside, zero on the edge. The standard construction: shrink the box by r,
640
- // measure the distance to that inner box, then subtract r to round it back out.
641
- //
642
- // p - offset from the rectangle centre
643
- // b - half-extents
644
- // r - corner radius (must not exceed min(b.x, b.y))
645
- float sdRoundBox(vec2 p, vec2 b, float r) {
646
- vec2 q = abs(p) - b + r;
647
- return min(max(q.x, q.y), 0.0) + length(max(q, vec2(0.0))) - r;
648
- }
649
-
650
- // Signed distance from a point in a dash's uv square to the dash's rounded-
651
- // rectangle edge, in units of the across-path half-width.
652
- //
653
- // uv.y spans the length, which the vertex shader already stretched by
654
- // fragDashAspect, so it is scaled back up here to put both axes in the same world
655
- // units. Without that the corner radius would stretch along with the dash
656
- // instead of staying circular.
657
- //
658
- // fragDashAspect 1 + dashCornerRadius 1 reduces to length(p) - 1: exactly the circle
659
- // this shape replaced.
660
- float dashSignedDistance(vec2 texcoord) {
661
- vec2 p = (texcoord - 0.5) * 2.0;
662
- p.y *= fragDashAspect;
663
- vec2 b = vec2(1.0, fragDashAspect);
664
- float r = clamp(dashCornerRadius, 0.0, 1.0) * min(b.x, b.y);
665
- return sdRoundBox(p, b, r);
666
- }
667
-
668
- void main(void) {
669
- // Compute the opacity of the path based on the distance from the current
670
- // fragment to the 'complete' value as it varies from 0.0 to 1.0.
671
- // Fragments that are at the 'complete' value or past it will be fully
672
- // transparent, while fragments that are at 'complete - completeLength'
673
- // or before it will be fully opaque. However, we adjust the 'complete'
674
- // value here so that it overshoots by one full 'completeLength', so that
675
- // the entire path will be opaque when the 'complete' value is at 1.0.
676
- float completeLocation = complete * (1.0 + completeLength);
677
- float completeAmount = clampRemap(
678
- fragPathDistance,
679
- completeLocation - completeLength,
680
- completeLocation,
681
- 0.0,
682
- 1.0
683
- );
684
- float opacity = 1.0 - smoothstep(0.0, 1.0, completeAmount);
685
-
686
- // 2020/01/09 Terence Dickson
687
- // When we render the background and overlay for the mapbox outdoor context
688
- // behind everything else in single-buffer rendering, the fact that the path
689
- // writes to the depth buffer means that the background and overlay will not
690
- // be drawn behind the path even when the path is still fading in. The effect
691
- // is subtle and is only visible in single-buffer rendering so this quick fix
692
- // prevents writes to the depth buffer for zero opacity fragments, which gets
693
- // rid of the most visually-offensive ghosting.
694
- if (opacity <= 0.0) {
695
- discard;
696
- }
697
-
698
-
699
- // Carve the dash's rounded rectangle out of its quad. The geometry is only a
700
- // bare quad, so this discard is what gives a dash its shape at all \u2014 unlike
701
- // the ribbon endcaps below, it is not an optional refinement. The SDF is
702
- // reused for the border ring below, so compute it once here.
703
- float dashSDF = isDiscreteDash ? dashSignedDistance(fragTexcoord) : 0.0;
704
- if (isDiscreteDash && dashSDF > 0.0) discard;
705
-
706
- // Apply rounded endcaps for ribbon geometry using SDF
707
- // endcapEnabled.x = start cap (>0 enabled), endcapEnabled.y = end cap (>0 enabled)
708
- // Creates semicircular caps at start and/or end; disabled caps are square
709
- float startCapOn = step(0.5, endcapEnabled.x);
710
- float endCapOn = step(0.5, endcapEnabled.y);
711
- if ((startCapOn > 0.5 || endCapOn > 0.5) && isRibbon) {
712
- float endcapRadius = radius / pathLength;
713
- float xDist = abs(fragTexcoord.x - 0.5);
714
- float scaledXSq = xDist * xDist * 4.0;
715
-
716
- // Start cap: only apply SDF when enabled
717
- float startT = clamp(1.0 - fragPathDistance / endcapRadius, 0.0, 1.0);
718
- float startSDF = startT * startT + scaledXSq - 1.0;
719
- float inStartCap = step(fragPathDistance, endcapRadius);
720
- float outsideStart = inStartCap * step(0.0, startSDF) * startCapOn;
721
-
722
- // End cap: only apply SDF when enabled
723
- float endCapPos = min(completeLocation, 1.0);
724
- float endCapStart = endCapPos - endcapRadius;
725
- float endT = clamp(1.0 - (endCapPos - fragPathDistance) / endcapRadius, 0.0, 1.0);
726
- float endSDF = endT * endT + scaledXSq - 1.0;
727
- float inEndCap = step(endCapStart, fragPathDistance);
728
- float outsideEnd = inEndCap * step(0.0, endSDF) * endCapOn;
729
-
730
- // Discard if outside semicircle in enabled cap region
731
- if (max(outsideStart, outsideEnd) > 0.5) discard;
732
- }
733
-
734
- // Push in the texture coordinates so that they ramp up
735
- // at 'arrowMargin' instead of at zero; this remapping looks somewhat
736
- // like this:
737
- // 1 ^ ___
738
- // | /
739
- // | /
740
- // | /
741
- // | /
742
- // |___/
743
- // 0 +---------->
744
- // 0 ^ 1
745
- // arrowMargin
746
- // Making the arrows narrower on the path.
747
- float u = fragTopTextureU;
748
- u = clamp(
749
- u * (1. / (1. - arrowMargin * 2.)) - (1. / (1. - arrowMargin * 2.) - 1.) / 2.,
750
- 0.0,
751
- 1.0
752
- );
753
-
754
- float arrowSpacing = clampRemap(
755
- pathLength,
756
- shortPathLength * radius,
757
- longPathLength * radius,
758
- arrowSpacingOnShortPath,
759
- arrowSpacingOnLongPath
760
- );
761
-
762
- // Reduce the spacing between arrows when the camera zooms out, as increasing
763
- // the path radius will increase the arrow size and thus be able to fit
764
- // fewer arrows on in total, and this secondary movement of the arrows
765
- // "zooming off" the end of the path is unpleasant
766
- float expandAmount = mix(1.0, farRadius / nearRadius, zoomLevel);
767
- float effectiveArrowSpacing =
768
- arrowSpacing * 1.0 / expandAmount +
769
- arrowMargin * 2.0;
770
-
771
- float effectiveArrowLength = arrowLength * radius * (1. - arrowMargin * 2.0);
772
-
773
- // Adjust the slope of the vertical texture coordinate so that it goes
774
- // from 0 to 1 along the length of the arrow plus the spacing between
775
- // arrows, and adjust its x-intercept so that one arrow moves to the
776
- // exact position of the next arrow as 'arrowAnimationTimer' goes
777
- // from 0 to 1
778
- // Note: Using fragPathDistance (0-1 along path) for RibbonGeometry
779
- float v = (
780
- fragPathDistance * (pathLength / effectiveArrowLength)
781
- - arrowAnimationTimer * (1. + effectiveArrowSpacing)
782
- );
783
-
784
- // Compute a "looping sawtooth" wave for determining the vertical texture
785
- // coordinates of the arrow texture, roughly as follows:
786
- // 3 ^ /
787
- // | ___/
788
- // 2 | /
789
- // | ___/
790
- // 1 | /
791
- // |___/
792
- // 0 +--------------->
793
- // 0 ^ ^
794
- // ^ |_|
795
- // | effectiveArrowLength
796
- // |___|
797
- // effectiveArrowSpacing
798
- //
799
- // This is effectively equivalent to this sort of sawtooth wave:
800
- // ^
801
- // 1 | / / /
802
- // |___/ ___/ ___/
803
- // 0 +--------------->
804
- //
805
- // Causing the image of the arrow to repeat, with dead space (the bottom
806
- // edge of the texture stretched out) between the arrows at the provided
807
- // spacing. The reason why the "looping" design is preferred is because
808
- // it takes advantage of WebGL's 'GL_REPEAT' texture wrapping behaviour
809
- // to avoid the discontinuity that can end up causing visual artifacts.
810
- if (mod(v, (1. + effectiveArrowSpacing)) < 1.) {
811
- v = v - effectiveArrowSpacing * floor(v / (1. + effectiveArrowSpacing));
812
- } else {
813
- v = ceil(v / (1. + effectiveArrowSpacing));
814
- }
815
-
816
- // Use the r-component of the texture to determine whether the arrow covers
817
- // this fragment or not.
818
- //
819
- // Discrete dashes draw one complete arrow per dash: the dash's own uv square
820
- // is mapped straight onto the arrow texture instead of the path-length
821
- // sawtooth, so every dash carries a single chevron. The arrow is centred and
822
- // scaled to dashArrowFill of the dash's width so it sits comfortably inside
823
- // the edge; fragments outside that region clamp to the (empty) texture edge.
824
- // The vertex shader aligns the dash's up axis (uv.y) to the path tangent, so
825
- // the arrow points in the direction of travel.
826
- //
827
- // The along-path axis is scaled by fragDashAspect so the chevron stays square
828
- // in world space: on an elongated dash the arrow keeps its proportions and
829
- // sits centred in the pill rather than stretching to fill it.
830
- float arrowAmount = 0.0;
831
- vec3 secondColor = pulseColor;
832
-
833
- vec3 finalColor = color;
834
-
835
- // Apply travelled color to the portion of the path that has been travelled.
836
- if (fragPathDistance < travelledEndFraction) {
837
- finalColor = travelledColor;
838
- }
839
-
840
- // Adjust the color based on the highlight but only if the fragment is within
841
- // the highlight start and the currently revealed end. The revealed end animates
842
- // from highlightStartFraction to highlightEndFraction so the reveal starts at
843
- // the highlight's beginning regardless of where it sits along the path.
844
- // [Anzor] 0.005 smooths the transition when the width multiplier is large.
845
- float revealedHighlightEnd = mix(highlightStartFraction, highlightEndFraction, highlightCompleteFraction);
846
- bool inHighlight = fragPathDistance > highlightStartFraction - 0.005 && fragPathDistance <= revealedHighlightEnd;
847
- if (inHighlight) {
848
- finalColor = highlightColor;
849
- }
850
-
851
- // Arrows can be toggled independently inside vs outside the highlight.
852
- bool effectiveDisplayArrows = inHighlight ? highlightDisplayArrowsOnPath : displayArrowsOnPath;
853
-
854
- // Apply border effect for ribbon geometry
855
- // fragTexcoord.x: 0\u21921 across ribbon width; edgeDist = distance to nearest edge
856
- if (borderEnabled && isRibbon) {
857
- float edgeDist = min(fragTexcoord.x, 1.0 - fragTexcoord.x);
858
-
859
- // For endcaps, compute radial distance from semicircle edge instead
860
- float endcapRadius = radius / pathLength;
861
- float endCapPos = min(completeLocation, 1.0);
862
- float endCapStart = endCapPos - endcapRadius;
863
-
864
- // Check each cap region independently
865
- bool inStartRegion = fragPathDistance <= endcapRadius && startCapOn > 0.5;
866
- bool inEndRegion = fragPathDistance > endCapStart && endCapOn > 0.5;
867
-
868
- if (inStartRegion || inEndRegion) {
869
- float xDist = abs(fragTexcoord.x - 0.5);
870
- float scaledXSq = xDist * xDist * 4.0;
871
-
872
- if (inStartRegion) {
873
- float startT = 1.0 - fragPathDistance / endcapRadius;
874
- float r = sqrt(startT * startT + scaledXSq);
875
- edgeDist = 0.5 * (1.0 - r);
876
- } else {
877
- float endT = 1.0 - (endCapPos - fragPathDistance) / endcapRadius;
878
- float r = sqrt(endT * endT + scaledXSq);
879
- edgeDist = 0.5 * (1.0 - r);
880
- }
881
- }
882
-
883
- if (edgeDist < borderWidth) {
884
- finalColor = borderUseDarken ? finalColor * 0.6 : borderColor;
885
- }
886
- }
887
-
888
- // Apply the border ring for discrete-dash paths. Reuse the same SDF that carved the
889
- // shape so the border follows the rounded corners exactly instead of
890
- // approximating them. The distance is negative inside and measured in
891
- // across-path half-widths, so -d converts to the ribbon's edge-distance units
892
- // (0 at the edge, 0.5 at the centre of a square dash) and borderWidth keeps
893
- // behaving consistently across geometries.
894
- if (borderEnabled && isDiscreteDash) {
895
- float edgeDist = -dashSDF * 0.5;
896
- if (edgeDist < borderWidth) {
897
- finalColor = borderUseDarken ? finalColor * 0.6 : borderColor;
898
- }
899
- }
900
-
901
- if (effectiveDisplayArrows) {
902
- vec2 sampleTexcoord;
903
- if (isDiscreteDash) {
904
- vec2 dashOffset = fragTexcoord - 0.5;
905
- dashOffset.y *= fragDashAspect;
906
- sampleTexcoord = clamp(dashOffset / dashArrowFill + 0.5, 0.0, 1.0);
907
- } else {
908
- sampleTexcoord = vec2(u, v);
909
- }
910
- arrowAmount = texture2D(arrowTexture, sampleTexcoord).r;
911
- float delta = 1.0 - abs(fragPathDistance * 2.0 - 1.0);
912
- secondColor = mix(finalColor, pulseColor, 1.0 - smoothstep(ARROW_FADING_POINT, 0.0, delta));
913
- }
914
-
915
- if (dashed) {
916
- float effectiveDashLength;
917
- float effectiveGapLength;
918
-
919
- if (dashAbsolute) {
920
- // Absolute mode: dashMeters/gapMeters are in meters
921
- // Convert to path-distance fraction using pathLength
922
- effectiveDashLength = dashMeters / pathLength;
923
- effectiveGapLength = gapMeters / pathLength;
924
- } else if (dashRelativeToWidth) {
925
- // Width-relative mode: dashSize/gapSize are multiples of path width
926
- // Convert to path-distance fraction using radius
927
- effectiveDashLength = (dashSize * radius * 2.0) / pathLength;
928
- effectiveGapLength = (gapSize * radius * 2.0) / pathLength;
929
- } else {
930
- // Length-fraction mode: use dashLength/dashGap directly as path fractions
931
- effectiveDashLength = dashLength;
932
- effectiveGapLength = dashGap;
933
- }
934
-
935
- float totalLength = effectiveDashLength + effectiveGapLength;
936
- float numSegments = ceil(1.0 / totalLength);
937
- float adjustedTotalLength = 1.0 / numSegments;
938
- float adjustedDashLength = adjustedTotalLength * (effectiveDashLength / totalLength);
939
- float pattern = mod(fragPathDistance, adjustedTotalLength);
940
- opacity = pattern < adjustedDashLength ? 1.0 : 0.0;
941
- }
942
-
943
-
944
-
945
- if (showPulse) {
946
- // Add the pulse color to the path by determining how far the current fragment
947
- // is from 'pulse'
948
- float pulseLocation = remap(
949
- pulse,
950
- 0.0,
951
- 1.0,
952
- -pulseLength,
953
- 1.0 + pulseLength
954
- );
955
- float pulseDistance = smoothstep(
956
- 0.0,
957
- pulseLength,
958
- abs(fragPathDistance - pulseLocation)
959
- );
960
-
961
- // Blend the pulse color to the path based on how close this fragment is to
962
- // the 'pulse' value and whether it's covered by an arrow -- but if it's
963
- // covered by *both*, then we go back to using the regular path color
964
- // (making arrows look like "holes" when they're overlapping the pulse.)
965
- float pulseLevel = abs(1.0 - pulseDistance - arrowAmount);
966
-
967
-
968
- gl_FragColor = vec4(mix(finalColor, secondColor, pulseLevel), opacity * opacityMultiplier);
969
- } else if (effectiveDisplayArrows) {
970
- gl_FragColor = vec4(mix(finalColor, pulseColor, arrowAmount), opacity * opacityMultiplier);
971
- } else {
972
-
973
- gl_FragColor = vec4(finalColor, opacity * opacityMultiplier);
974
- }
975
- // Checkerboard discard for x-ray effect. xrayDithering is a uniform so
976
- // the outer branch is warp-coherent (zero cost when disabled).
977
- if (xrayDithering > 0.0) {
978
- float cx = floor(gl_FragCoord.x / xrayDithering);
979
- float cy = floor(gl_FragCoord.y / xrayDithering);
980
- if (mod(cx + cy, 2.0) < 0.5) discard;
981
- }
982
- #include <colorspace_fragment>
983
- }
984
- `;y();var Ip=`uniform float complete;
985
- uniform float nearRadius;
986
- uniform float farRadius;
987
- varying float fragPathDistance;
988
- const float completeLength = 0.1;
989
-
990
- // Map the x value from the range [xMin, xMax] to the range [yMin, yMax] using
991
- // linear interpolation/extrapolation.
992
- //
993
- // This performs a pure linear mapping 'y = mx + b' where
994
- // 'm = (yMax - yMin) / (xMax - xMin)',
995
- // 'b = -xMin * (yMax - yMin) / (xMax - xMin) + yMin'.
996
- float remap(float x, float xMin, float xMax, float yMin, float yMax) {
997
- return (x - xMin) / (xMax - xMin) * (yMax - yMin) + yMin;
998
- }
999
-
1000
- // Map the x value from [xMin, xMax] to the range [yMin, yMax] using linear
1001
- // interpolation, clamping result values outside [yMin, yMax].
1002
- float clampRemap(float x, float xMin, float xMax, float yMin, float yMax) {
1003
- return clamp(remap(x, xMin, xMax, yMin, yMax), yMin, yMax);
1004
- }
1005
-
1006
- void main(void) {
1007
- // this ensures that the stencil mask moves along with the path above it, to avoid the progress bar effect
1008
- float completeLocation = complete * (1.0 + completeLength);
1009
- float completeAmount = clampRemap(
1010
- fragPathDistance,
1011
- completeLocation - completeLength,
1012
- completeLocation,
1013
- 0.0,
1014
- 1.0
1015
- );
1016
- float opacity = 1.0 - smoothstep(0.0, 1.0, completeAmount);
1017
-
1018
- // 2020/01/09 Terence Dickson
1019
- // When we render the background and overlay for the mapbox outdoor context
1020
- // behind everything else in single-buffer rendering, the fact that the path
1021
- // writes to the depth buffer means that the background and overlay will not
1022
- // be drawn behind the path even when the path is still fading in. The effect
1023
- // is subtle and is only visible in single-buffer rendering so this quick fix
1024
- // prevents writes to the depth buffer for zero opacity fragments, which gets
1025
- // rid of the most visually-offensive ghosting.
1026
- if (opacity <= 0.0) {
1027
- discard;
1028
- }
1029
-
1030
- gl_FragColor = vec4(0.0, 1.0, 0.0, opacity);
1031
- }`;var Op="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAAAAAB5Gfe6AAAQkHpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZpZciQ7rkT/uYpeAicQ5HI4mr0dvOX3ATOl0li3q3SVJkUqFMEBcHc4IuX2///fcf/hK7cSXRatpZXi+cott9h5U/3j63EMPt+fL1/h+fPdeff6NnJMHNPjD2U/7+qcl183aH6eH+/PO52PN7E+B3qZ+Tlgspkjb57X1edAKT7Oh+fvrj3v6/nNdp7ftd057abHnz78npVgLGG8FF3cKSTPz2oXJFaQWuocCz9D0mhnEu8Tx54k6dexc98F77vY+f48n96HwvnyvKB8iNHzfJCvY3cj9HZF4dfM7/6QZ4j+7deb2J2z6jn7sbueC5Eq7rmpl63cd1w4GCrd2wov5Vt4r/fVeFW2OMnYIpuD13ShhUi0T8hhhR5O2Pc4w2SJOe5IuGOMM6Z7rhL+FudNSrZXOFFJz3KpkqtJ1hKn4+tawp233flmqMy8AlfGwGCBOz693Fcn/+b1OtA5Bt0QfH2NFeuKFnCWYZmzn1xFQsJ5xlRufO/LvcGNf5PYRAblhrmywe7HY4gh4Re20s1z4jrx2fkHNYKu5wCEiLmFxYREBnwJSUIJXmPUEIhjJT+dlceU4yADQSSu4A65SamQnBptbu7RcK+NEh+nkRYSIZBGSQ0EIlk5C/jRXMFQlyTZiUgRlSpNekklFymlaDGN6po0q2hR1apNe001V6mlaq211d5iS0iYtNLUtdpa651JO0N37u5c0fuII408ZJSho442+gQ+M0+ZZeqss82+4koL+q+y1K262uo7bKC085Zdtu662+4HrJ108pFTjp562umvWXtm9X3WwofM/T5r4Zk1y1i+1+mvrHFa9WWIYHIiljMyFnMg42oZANDRcuZryDla5ixnvkVIIZGsBbHkrGAZI4N5hygnvObuV+Z+mzcn+Y/yFr/LnLPU/RuZc5a6Z+Y+5+2LrK1+K0q6CTIWWkx9OggbF+zaY+1Wk/766H46wF8ONFY+O8hBMEc7oc4Vdh+8JsE+PUSrVjr70Zz1+H56PH3o9sRR1ql5Ha8bUMQxpe89Tki8Sb0tE23cw3DcfEo+ugnj2G3WEmononVfoag71pVjR+EmAE53eT5tqYfEHl/7ThMusaI+St0jktFa9gKnreiQqCNpZ2mJdSkbaiK6DrovYR4/JhJfRsx5d5EVZnEIPetHnU5KynJPTSuCPuC0lOuXH7n1DNq7DpUtHbhM5lDA0c2bnDCJoOObMnyj+aPjPwx0yiDUxKKsg35VnRnBEVhonKwK5hOk5NttUrhr2+tMOXkPJb1RZ+iAelYjL2MuO3pGRQ78GdxwOOaTAcJZcewq7ilB1RJCSozUdSEdwVJVb6asiBsHH1Bqgbiv3Cmkkis6ktVnZGRRwMNJjUA3Ao2127YWdhAIblxF51hzMcZsVZc0r0dJo5Liqfn41Q+q193SGhhkMkgaLJRNnEpqBtyVvbcVffIk+LE9QPFBTMTQe0aWkMXMnx3dy5sfHreDE60Ql50E+SqRcmfK16L2p0Ol8JFATu3qASXy7SvmiGW2cdMBxsty44CvtLogfGlv7WkCSV0WId2270EaD5Ym40cs+SAwZuNjPSTywAvEfLmzQhtLDntfCnhl/fNmUNnzyA2g76Zn0SP+c+I6bCC0FONUQ4L50e95dif+DH/m9htQjBEhPPpOjYjmm2ChbfEMIUaYtAIxmWJHlilLU8ZRs9pCsHbDpFaRgZljz2QandjDIBPZDGTuoZW1KdlYh52ALzisKJRNWSQmLAWx8iv9mGttT15bBc2oxd57bZtVF98CYtK3UH22Yd/A7WaKa+ZjNTOXEzNhMJ5kmQOvfzsbxbZALJ2xwGBjX2HFQybhi7kpbA7DVpS3RxMJwFyHwGk5gs6a4lrRHVqhYT0QTJC9UZcC9Yrelkn6yXch68NKNtG7CiU3vf/zMZAYXPWdrR9XZ/ctMV1sJQ2wJEGxzaHs7LmmHIwnUwbwnNAapBY9xhE19DNJW3ua0dDk/AjwITacR0PqZxkbyJ+E5jYbxI84x1TBE+y90hwDCYZIM0tqAKPZfCzFrbH8kYCm3eqQkZ2+2GovcL8Suokyg8yyCJes6dcouSLiNSLb0ETJU+/N/WFsBBSOXBbm9Cwp4CzlOag7ro7R2vC19nSsCPmAjIEMiobFwaoVXhjTU2XMpgEsDH/L3Sx54OCTMUSXI/IIA2V4QcLQpwVz12pInI0bY56pIQ2BSGRLL+yLfZ7JkiimbK+aepsbwRStpokx5gCqe1hjdMAwcINbkk5jmedrNRAG5pUXPe0sZIoXy1h7lSDxApzheg24JeDNtDS1oBDBUC4iWZFilBPhZx0Kqx2lihpbG9q4sYidksCN4yRYhNM4nxfBbTi4E3AT6B3igbvs9Gv8ZkHsIfdlep+2HelEDbkJdNjqZQ90B7k6OIoFfkkPNoY+z0gzACa1f2qcBYxVJpT2QQgS19dKQlbC24S92xiEAFRKB5Uy1qrBgOtwIge55G0kRPfIytGx0tMOrGfrijB2FHOk/TKcMjDTMPeBo4FnXD5cQ8vtdgoAN0yuzZQHQI09wm/5vAB6RHyI9rYKiZ6YWC6rbaiLmDtoaToC1bViXQFNtgWsOfEEKCleC3GWPSfgQWRQWMgw/9FDgvOZrFAT3SmsA3DLbqlsSppQG5QeOjPXavUUkxF/qgLM05vW5o7UakuBqo2ZW8Nj0LB7imVJC9QSA+wd7RPztIUZ80xQZq0ROrc8CSVncWzkTA/RwmunldCPAQKjqVC7bhRuTIv0plbk7gOX4m5OAi2YesYZ0KBQRToG8iv9x8dgGtgECYRBeEU87OxoSc8epu+s7Mq/MN0VbBT19dii7ekO66UZwdAMtoAVQd13J5nwZe98OgGslmVqAGBkeLZNVNVlWpV18qihntXKnBZvrDIVgFpx4q5poLqREOVplMPSpTF2KvjBAzDpprkruXIaaUmUD4Xo2yrGWcYlixKIwRFjl0jPQhKznUXZAoSjlg9c/NwAI4p3Q/w5bCNfhUZS7bGfqesHqKAlyZZxZgNrhGevZXccaqBys4NEqB3Vqfptji9uUrhCL6yXFqxtm0hhLyYU3Tjd8I/HZaWD1oyVjnG5hhpCN5yHSf8BQUZlVNd00OP4M0TK+JSM7iqWi01SinFkCQXWxiZJLqqAHiEt3G3I2WYd46KU9pIJIOkoRQYCcEAAPguHo0Y4k8Hl6SW50MoW0uZU8jJOUghKo38Nl5ZSwsJNAUC2/lFZWkfMjrU8dFrTjHpJnUrLCILQIxINiYdQlDXaE/razQ4jjQluN5jW1Eh/S7yYvI5gigSjdLYU9TiFXAcHjISiLhQd9obb3OQmwY+YqVwiBMCkOGLXaK/ljBShh56c1g0uyIb2lBRKO7ZTAFncw5c5UGjGSy3CsI1Jt2mtruZkfhBZmbR+842Yu1eDiWEl0V6LZcGem6Ct+LW4Wy3oAjyNObazKBHomhJ3HMKEKHgiGksH+Ig1nTidfNMyA+oYHqVFaRGLiQreVLc9GvQgftKjW9cfUSKNYL80rqU7Um2rwqQJR1ai31Wq7vzKJEsFHDj0bAEMUKXgvfD5bWbaLPBTKz1Nk/Fg+GUZvUzFw80CLaKtPAACVAWrismh863FU4IJ0716SXBUNVb/SDMVvZgDt34CXoOq1JKvg0n08gPHTwXBNgD5W8pZZ8E9EVWcv1DZMB2NFysIwkqBSaH5QRmsAHdkHB+UANvLJvFpQKAahSmYTLEd2AFO+5rsqRRU6sVv5IP0wsSPLcWsbC1Y95mte71CUm6RJJWwkg6Q4k+xWMM0ByElJPQ6j2ED5hY42ALpZRytx9RlgQlJLijzhKi5eX5JBSIRGfo9o2xhd/0aWku8OS+4D9ZnovHDQMPaYo4qm2mlZbUnd7pR6oQj29Z2BqJ9n3LRT+MTLu3IR+ZP2TCPh3EDw8H1NHpoT7FibNYU8WHd9ESHcY12aDOQCUBddi4Ucp+4yuzz8ybcCCu1h8zvzXhDN4HYLq1R+U0xzUqg5QSA3iSBgdDouy55Ifx0DaeEhgezxBRGmoEJ6AJitVuzwtKPlUskHgU2F0LS7AFIwW5jPu0RUL7sp+fkNk0ee8P6uXYgl40WM+cdCOW21r13e0ivt0ff/mYcUfrQZWs2BiN6G+MDTGz1BKORmUTNQp9YGSHFxAeTkQrKd6FoVUogyytW25OLy3OpaO5oZCQp46aPzb5LnJiFEIwAKkmbYVYIjzVv3vj7rA6HignEeQAXTAHKDhoD7Uujh0QjtsB6fTP1NzO7T1Nzq4F1GnfHdXCG1Yxjwdtjf+PGRGTzEtEAUCz7KLfTdItLwCXuSOAzVjaZB6LvbUZhYGWmifSZlcMDnGHPd6gPeiK9erhpiw7ZP9ahTrMhFDa1J53m9ri2DloziqGETTcVSppCbTDDjExg6RrZ6cPEzB8XArEjQSB29odrUoLyoS/65RfM9fprGGjlHpbhGgbYD8MtmW1eFcAWX5dbcMHcl8sUI2k+H7GPW9VrArw3G+BefcCrCaAT/N53YLvP26Uy0kMFnDEZz0DJkmQqEOlL7SlKweYhH8gxpYeAYi0f9magqPbMYZuUI6007lSZQoyoGfYQHsNRzHXR3MMINTSMZpq1KD2A5MDJgtMLdRU6R4CEOJcKGiIJ7K6P/vAM6xpECHI8rRHsaEj6smkngAUjXTzrRoSI48ZpHOqgOY5OejKVdpnmiYUChQnVdIPa6ekGqRSRgEO119oDHOiIUQ5ciYVgaF1oG8Udo8WYtD+DEi8D/w8rAJE2k2PoyV0oMtpauxreaFjpujAvxFlwBhjuNqM9P0IfI5iD8Nh8y1kG4igjJkDNkOijnlLhItAd9lhRd670yNRTu95cR/Xuu0c5WO4DEFk5YQAPtLvU4TYPGRh4APPEDNiuuwR6SC21JoFbQBBMr+zJmT32QplNI6p16PbculN/pCX1wAyTWGTeJ774aln0gvQikw7TmkfsNbdQNs0adutYUDqNtGc0RqngUYdhUYuHSL1/eLrgvqDTC5neu++vufRkEgP9D2T64Kg/c4n+s7k3dDr3me8nOr0c72MRNmgF7D4WySPP0YAI/bI4eixwc7K13QiRiL85A8fnSsUj+mvTrsZtVUEQZ6sTpVafW8nYJZyaZS0U+0xIb6et9PhhtoObozQbjKAoDf6eiFgx1UUvpUYj1GweH0MNMrofhynfWn7+KYu7n5r83hN9aqm+6qjcH7dUlgvZVLV3xqq4fbP16qv+eofuTz43eomAqfS7GBAB9zEE31WJ37eVIPtdGN5A8nMYPvvLt8t2/V/6gM19G4g/hIL7UXf9JgbuLRZ+AoW//AzyMxTcWyz8BAruLRZ+AgX3r3y2+mT/PwfiN1DoVI+QT3CZDmvb8022JeYb6HiQPQpPPvboFB+i1MZdcqWZqthHmix6vttw0UAI1z8oEnGwVe++c7JamxslC+8xKJE41XJmug1npz+6CUAKyURd9gSxo+kWxvtZth848GBlws/0SKjYhmbZ9IiV+mcGBSdWHk8sqSr2zz5J7QME/0yD+z4Pe+JuGn1MV/vUyZwOHojWPlmPXgf9CuoeN9UAT+FGwaLg44v3dWe6QpvuL3Ln/p3k/2AgqNDcfwHgqUmIIqn+hwAAAAJiS0dEAACqjSMyAAAACXBIWXMAAAsSAAALEgHS3X78AAAAB3RJTUUH4wYRESAMujenGAAAB9FJREFUeNrtnWlsFVUUx899fS1gUoKioEY+WBRUEohGkUhAKxgEjSgGoRGB4AJCNKAIJBJZJSiyGYMKKkIoLlEUKhUraxFkKUE2kU1aCrRgW2jpg9f29R2/sBTo67v3zL2zvfP73MzM+XU6mf+5504BGIZhGIZhGIZhGIZhGMZGGq3JvSmR62++BXHH7Ylbf9ouRMT99yVq/e0PICIiHumUmPV3PooXOf5EItafXoCXOdUn8ep/pgjrUDY40ervX4JXUTEiocoXL5/FawiNEwlU/6hzeB3hqQljQIwJYT3UzEkQA2JiGOslsiAhDIgZ1RiD6NIEMBD8NIKxyQr6vv7FtdgQa31uILg0ig2zsZmv4//yePUj7rjNv/U3yUEJ/r7Xr/XfvBmlOPKwT+vfhpIUdvdj/Wm7UZpTz/mv/g4HUYGyQb5r/+SjEhXD/VV/j5OoSGisj16LRe9iVCY8xTcGxIulSKBmtk8MiKHlSMIn8ViMqkQivojHgfcuIJ0VAc/XPzmMVljrcQOBmdVojY1NvVx/8mcRtEqeh+NxypJatM6+ezxb/7Io6uBwR4/e/1moicJunvz956A2ip/1Xv3Nt6JGSgd6rf47/0KtlHssHrfZi5rxVDwWDx5C7XgoHotHC9AANbO8YqBXERohMt8bv/8X/kNDRDM9cA+IgWVojhWuNxAYXo4mWePyeBwYHUKz5Lo6HidNvICmybvVxfXPqEbz7Gvr2vrn1KAdHH7IpX//8yNoD8dcGY+TM6NoF26MxzLTL26Mx0majtM4q5ed7yhNulVsd5WAxqset/mGS6/d5CIBLXI62/7I6ZKyzjUC0rIfsP+hE3zkxt9c8vy7tPnJbiKfuyP+Xdn8ZDeuiMei+zF0juWOGyBNv+iMxw4bEBkl6CzOxmPx6ll0mryWDtb/ViU6z17H4rEYG0I3cMiheByYFEZ34Ew8Dn5UjW7BiXisY/rFDfGYmgWCCwcngXto0q08z1YBSUsy3NWgb5Qe2WSjgJRlfdy2RJPcNXm9bQIarexpsP5VdxHjcbMcm2Q3/5P64i71U8k/ELuLNsVjcct2cnST+rGg+Jo4XmhLPBZ376GOfoOkAIB5NWTHxuu/nzj9ElkA8gLgA+pLlvF43IU4/VI9G1QEAHnIPjfVaP1PnqRdVngKqAkActDMa2Hw/u9zijjjNg5UBcBr1FbD3jbG6h9QSruk8ovfyFESABnUWSNT8VgMI06/lF7aBqomAJ4n3m+G4nHgbeJfZfHljcCKAqDHcWo87m2g/gnE53LhlS+lqQqATv9S4/FL2u//qcT2T34XoAuAdvuJBspf11z/LOKbyYG6q4bqAqDVTqKByjFa21/U6ZfdaWBNADTdTDQQnqSv/pRMYjrZevVLCUUAiF+JBqpnaqv/J2I+zb3mxZwkAMTPDq8ep1A3P/1y3ZOEJABgiaPxuOnvxLN/B7oEwELq/sPl1utvSdz8VPsl6BMAn1AbBKut1t96F+3ENXOFTgFiehXRwAZL8Vi0JW5+qppW7+HIAgDGnyca2G4hHouOh2knvTARdAuAkedsj8cinTj9Ujka9AuAV87YHI/F08TNT2eHgQkB0I/aIDhGmuIU/YnnKxkAZgTAU8SGHC0eDyJufiqKfTKrAqBrPtFAiXo8HlFBO1VBA7ebZQHQifhUVo7H4p2QgQeOdQHQbp8t8Tg4idj+2dPgwJIGAdBqhw3xmDz9EuelQ4cASP3DeDwOziW+ecdbldEiACDbcDxOWkBs/8QNHpoEAPXjLNFMmfpv+IZ4+PjRU5cAWGwwHqcQNz/J2NUmAMgjavHjMfEPTGpvvz4BQH1MrzMkoHoW2CsAppEaBFskemQUA+HJYLcAeJfQINgpNVuvbiA0FuwXAG8qNwh2S07WqxqQ/saPXgEwRDGu7W8te2Q1A6XSH0HWLAD6nVa5zoPS9asZKJb/DLZuAdDzhPx1Hu2gkobkDRQq/J8w7QJAfstevuI3+WQN1F39dkAAtP9H7jpPdFVtiMgZOKC0Z9aAAEiT+mrbScLQjIyBXWngtABokRf/kKefonRF4xvYqrjmYEQApG6Md8SyvrS+eDwDG5QbzUYExL3QMxnUlZGGD5wFbhEADQ7YVwyhr401YCD6LbhHACyK3SA4N9TK6mhMA5EvwE0CYF6sBkFopLXl8exYq9/gLgHwYf3x+PxoqwMC9RoIvw9uE1D/gH3VeOsjItnSq9/OCqhvwL5qAoABA5XU28qsAHjj2tW8mukABgzEXP12WgAMvrpBEPkYwICB2KvfjguAvnUH7GvnARgwUGRhEt24gLoD9tGvAAwYKLDyySzzAqDzpQH76CIAAwYOWtqNYoMAaH9xwP57AAMG9ljbj2SHALhjJyLijwAGDGyzuCPNFgGQuhlxpfw1yR94dfAxi5cmojI/lRyx+rtaX9XDhADr2CVABc//JycWwAJYAAtgASyABbAAFsACWAALYAEsgAWwABbAAlgAC2ABLIAFsAAWwAJYAAtgASyABbAAFsACWAALYAEsgAWwABbAAlgAC2ABLIAFsAAWwAJYAAtgASyABbAAFsACWAALYAEsgAWwABbAAlgAC2ABLIAFsAAWwAJYAAtgASyABbAAFsACWIDToH8FyJUWtVWAALedDoFhGIZhGIZhGIZhGIYxyf+YwEMsIhMo/AAAAABJRU5ErkJggg==";y();var cs=new O,ds=new O,sn=new O,Lp=new O,nr=new O,Pb=.5,Ib=2;function Ob(o,e,t){let r=o.x-e.x,n=o.y-e.y,i=o.z-e.z,s=t.x-e.x,a=t.y-e.y,l=t.z-e.z,c=r*s+n*a+i*l,d=Math.sqrt(r*r+n*n+i*i),u=Math.sqrt(s*s+a*a+l*l);if(d===0||u===0)return 0;let h=c/(d*u),v=Math.max(-1,Math.min(1,h));return Math.acos(v)}function Rp(o,e=20){if(o.length<3||e<=0)return o;let t=e,r=e/2,n=[o[0]];for(let i=1;i<o.length-1;i++){let s=o[i],a=o[i-1],l=o[i+1],c=s.distanceTo(a),d=s.distanceTo(l);c>t&&(nr.subVectors(s,a).normalize(),sn.set(s.x-nr.x*r,s.y-nr.y*r,s.z-nr.z*r),n.push(sn.clone())),n.push(s),d>t&&(nr.subVectors(l,s).normalize(),sn.set(s.x+nr.x*r,s.y+nr.y*r,s.z+nr.z*r),n.push(sn.clone()))}return n.push(o[o.length-1]),n}var Ap=.0025;function Fp(o,e,t,r=Math.PI*2/3){if(o.length<3||e<=0||t<=0)return o;let n=[o[0]];for(let i=1;i<o.length-1;i++){let s=o[i-1],a=o[i],l=o[i+1],c=a.distanceToSquared(s),d=a.distanceToSquared(l);if(c<Ap||d<Ap){n.push(a);continue}if(Ob(s,a,l)<r){cs.subVectors(a,s).normalize(),ds.subVectors(l,a).normalize();let h=Math.sqrt(c),v=Math.sqrt(d),f=Math.max(Pb,Math.min(Ib,e)),M=Math.min(f,h*.5),p=Math.min(f,v*.5);sn.set(a.x-cs.x*M,a.y-cs.y*M,a.z-cs.z*M),Lp.set(a.x+ds.x*p,a.y+ds.y*p,a.z+ds.z*p),n.push(sn.clone(),Lp.clone())}else n.push(a)}return n.push(o[o.length-1]),n}var Rr=8,Wl=Vt,Lb=new Uo,us=new O,_p={h:0,s:0,l:0};function jl(o,e,t=.2){return o.getHSL(_p),e.copy(o).offsetHSL(0,-_p.s*t,0)}function Vl(o){o.addEventListener("dispose",()=>{let e=o.uniforms.curveTexture?.value;e&&(e.dispose(),o.uniforms.curveTexture.value=null)})}function Zl(o){return o===!1?-1:o===!0?0:Math.sin(o*Math.PI/180)}function Gp(o,e,t){if(o.length<2){let U=new nt;return U.userData={entityId:"",type:"path"},{mesh:U,material:null,center:new O}}let{breakpoint:r,width:n,accentColor:i,completeFraction:s,isVertical:a,visibleThroughGeometry:l,highlightCompleteFraction:c,highlightStartFraction:d,highlightEndFraction:u,highlightColor:h,highlightWidthMultiplier:v,highlightDisplayArrowsOnPath:f,travelledEndFraction:M,travelledColor:p,xrayOpacity:m,xrayStyle:g,billboarding:b}=e,{color:x,metersPerPixel:S=1}=t,C=!0,D=0,w=1/0,P=e.displayArrowsOnPath,T=!0,I,L;if(gr(n)){let U=Ht(n)/2;I=U,L=U}else if(typeof n=="object"){let U=e.parsedOutputValues;I=U[r]/2,L=(U[r+1]??U[r])/2}else I=n/2,L=n/2;let A=e.dashDiscrete,F=e.isFlat,k=F?Zl(b):-1,_=Ab,j=0;o[0].z+=_;for(let U=1;U<o.length;++U){o[U].z+=_;let ge=o[U].x-o[U-1].x,Se=o[U].y-o[U-1].y,mt=o[U].z-o[U-1].z;j+=Math.sqrt(ge*ge+Se*Se+mt*mt)}let G=o,Z=e.smoothingCornerRadius??Ft.cornerRadius,se=e.smoothingTension??Ft.tension,xe=Z>0&&se>0;xe&&(G=Rp(G),G=Fp(G,Z,se));let[oe,ie]=e.endcapExtension;if((oe>0||ie>0)&&!a&&!F){let U=G[0],ge=G[G.length-1],Se=xe?.01:-.01;G.push(ge.clone().setZ(ge.z+Se)),G.unshift(U.clone().setZ(U.z+Se))}if(F&&!a&&G.length>=2){if(oe>0){let U=G[0],ge=G[1];us.subVectors(ge,U).normalize();let Se=U.clone().addScaledVector(us,-oe);G.unshift(Se)}if(ie>0){let U=G[G.length-1],ge=G[G.length-2];us.subVectors(U,ge).normalize();let Se=U.clone().addScaledVector(us,ie);G.push(Se)}}let ze=Lb.load(Op);ze.colorSpace=br;let H=new z(x),fe=new z(i),Ye=e.border,pt=Ye?.enabled??!1,_e=Ye?.color==="darken",$e=Ye?.width??.1,Oe=_e?H.clone().multiplyScalar(.6):new z(Ye?.color??"#000000"),te={vertexes:{type:"f",value:1},resolution:{type:"v2",value:new V(1,1)},cameraParameters:{type:"v2",value:new V(D,0)},complete:{type:"f",value:C?0:1},color:{type:"c",value:H},pathLength:{type:"f",value:j},nearRadius:{type:"f",value:I},farRadius:{type:"f",value:L},nearZoom:{type:"f",value:D},farZoom:{type:"f",value:w},pulseColor:{type:"c",value:fe},pulse:{type:"f",value:0},pulseLength:{type:"f",value:.075},pathIsVertical:{type:"b",value:a},arrowAnimationTimer:{type:"f",value:0},arrowTexture:{type:"t",value:ze},displayArrowsOnPath:{type:"b",value:P},showPulse:{type:"b",value:T},opacityMultiplier:{type:"f",value:1},dashed:{type:"b",value:e.dashedMask},xrayDithering:{type:"f",value:0},highlightCompleteFraction:{type:"f",value:c},highlightStartFraction:{type:"f",value:d},highlightEndFraction:{type:"f",value:u},highlightColor:{type:"c",value:new z(h)},highlightWidthMultiplier:{type:"f",value:v},highlightDisplayArrowsOnPath:{type:"b",value:f},travelledEndFraction:{type:"f",value:M},travelledColor:{type:"c",value:new z(p)},dashLength:{type:"f",value:e.dashLength},dashGap:{type:"f",value:e.dashGap},dashRelativeToWidth:{type:"b",value:e.dashRelativeToWidth},dashSize:{type:"f",value:e.dashSize},gapSize:{type:"f",value:e.gapSize},dashAbsolute:{type:"b",value:e.dashAbsolute},dashMeters:{type:"f",value:e.dashMeters},gapMeters:{type:"f",value:e.gapMeters},isRibbon:{type:"b",value:F},isDiscreteDash:{type:"b",value:A},dashCornerRadius:{type:"f",value:Math.min(Math.max(e.dashCornerRadius,0),1)},curveTexture:{type:"t",value:null},curveTextureSize:{type:"f",value:0},dashCount:{type:"f",value:0},billboardThreshold:{type:"f",value:k},borderEnabled:{type:"b",value:pt},borderColor:{type:"c",value:Oe},borderWidth:{type:"f",value:$e},borderUseDarken:{type:"b",value:_e},endcapEnabled:{type:"v2",value:new V(F&&oe>0?1:0,F&&ie>0?1:0)},cameraViewMatrix:{type:"m4",value:new K},screenSpace:{type:"b",value:e.screenSpace},metersPerPixel:{type:"f",value:1},minPathWidthMeters:{type:"f",value:Bt}};if(xe&&G.length>=2){let U=G[0],ge=G[1],Se=G[G.length-1],mt=G[G.length-2],Nt=U.clone().sub(ge).normalize(),Ct=U.clone().add(Nt.multiplyScalar(Bp));G.unshift(Ct);let bn=Se.clone().sub(mt).normalize(),vn=Se.clone().add(bn.multiplyScalar(Bp));G.push(vn)}let Ue=new od(G);Ue.curveType="catmullrom",Ue.tension=xe?se:0;let Le=F&&xe,st=new ts(Ue,G.length,Le),Ae=Rb*G.length,ce,He;if(A?(He=Dp(st),{geometry:ce}=Pp({component:e,curve:st,baked:He,nearRadius:I,metersPerPixel:S,uniforms:te})):F?ce=new es(st,{segments:Ae,billboarded:k>=0}):ce=new id(st,Ae,I,Rr,!1),!A){let U=new Float32Array(ce.attributes.position.count),ge=new De(U,1);if(F)for(let Y=0;Y<=Ae;Y++){let $=Y/Ae;ge.setX(Y*2,$),ge.setX(Y*2+1,$)}else for(let Y=0;Y<=Ae;Y++){let $=Y/Ae;for(let gt=0;gt<=Rr;gt++)ge.setX(Y*(Rr+1)+gt,$)}ce.setAttribute("pathDistance",ge);let Se=new Float32Array(ce.attributes.position.count*3),mt=new De(Se,3),Nt,Ct,bn,vn,na;if(F){let Y=ce;for(let $=0;$<=Ae;$++)Ct=$*3,bn=Y.tangentData[Ct],vn=Y.tangentData[Ct+1],na=Y.tangentData[Ct+2],mt.setXYZ($*2,bn,vn,na),mt.setXYZ($*2+1,bn,vn,na)}else{let Y=ce;for(let $=0;$<=Ae;$++){Nt=Y.tangents[$];for(let gt=0;gt<=Rr;gt++)mt.setXYZ($*(Rr+1)+gt,Nt.x,Nt.y,Nt.z)}}ce.setAttribute("pathTangent",mt);let gf=new Float32Array(ce.attributes.position.count*3),wo=new De(gf,3),xn,Sn,Mn,ft=new O,Lc=Y=>{a?(xn=Y.x*Y.y,Sn=-1+Y.y*Y.y,Mn=Y.z*Y.y):(xn=-Y.x*Y.z,Sn=-Y.y*Y.z,Mn=1-Y.z*Y.z);let $=Math.sqrt(xn*xn+Sn*Sn+Mn*Mn);return $===0&&($=1),ft.set(xn/$,Sn/$,Mn/$),ft},Eo={x:0,y:0,z:0};if(F){let Y=ce;for(let $=0;$<=Ae;$++)Ct=$*3,Eo.x=Y.tangentData[Ct],Eo.y=Y.tangentData[Ct+1],Eo.z=Y.tangentData[Ct+2],Lc(Eo),wo.setXYZ($*2,ft.x,ft.y,ft.z),wo.setXYZ($*2+1,ft.x,ft.y,ft.z)}else{let Y=ce;for(let $=0;$<=Ae;$++){Nt=Y.tangents[$],Lc(Nt);for(let gt=0;gt<=Rr;gt++)wo.setXYZ($*(Rr+1)+gt,ft.x,ft.y,ft.z)}}ce.setAttribute("pathNormal",wo)}let pr=new lt({uniforms:te,vertexShader:ls,fragmentShader:Hl,side:Wl});Vl(pr),pr.transparent=!0,pr.alphaTest=.5,te.resolution.value.x=1,te.resolution.value.y=1,te.vertexes.value=ce.attributes.position.count,te.arrowTexture.value.wrapS=En,te.arrowTexture.value.wrapT=En,te.arrowTexture.value.anisotropy=16;let be=new X(ce,pr);be.name="path";let qe=be.clone();qe.name="xray";let ta=g?.color?new z(g.color):H,ra=jl(ta,new z,g?.tint),at={...te,color:{type:"c",value:ra},opacityMultiplier:{type:"f",value:m},pathIsVertical:{type:"b",value:a},xrayDithering:{type:"f",value:g?.dithering??0}};at.complete.value=1,qe.material=new lt({uniforms:at,vertexShader:ls,fragmentShader:Hl,side:Wl,transparent:!0}),Vl(qe.material),qe.material.alphaTest=.5,qe.material.depthWrite=!1,qe.material.depthTest=!1,at.resolution.value.x=1,at.resolution.value.y=1,at.vertexes.value=ce.attributes.position.count,at.arrowTexture.value.wrapS=En,at.arrowTexture.value.wrapT=En,at.arrowTexture.value.anisotropy=16,at.complete.value=s,be.userData=qe.userData=e.mesh.userData;let mr=e.mesh,Re=null;if(!l){let U=new lt({uniforms:te,vertexShader:ls,fragmentShader:Ip,side:Wl});Vl(U),Re=new X(ce,U),Re.name="stencil",Re.material.colorWrite=!1,Re.material.stencilWrite=!0,Re.material.stencilRef=bt.PATH,Re.material.stencilFunc=Gr,Re.material.stencilZPass=Bo,Re.material.stencilZFail=Me,Re.material.stencilFail=Me,Re.material.depthWrite=!1,Re.material.depthTest=!0,Re.userData=e.mesh.userData,Re.raycast=Fn,mr.add(Re),mr.add(qe),qe.renderOrder=ye.XRAY_PATH,be.renderOrder=ye.STENCIL_PATH}if(mr.add(be),F&&!A&&(Tp(be),qe.raycast=Fn),A){if(!He)throw new Error("Error processing discrete curve.");Ul(be,{positions:He.positions,count:He.size,stride:3},He.bounds),qe.raycast=Fn,Re&&(Re.raycast=Fn)}if(a&&!A){be.geometry.computeBoundingBox();let U=be.geometry.boundingBox,ge=new O;U.getCenter(ge),mr.children.forEach(Se=>{Se.geometry.center(),Se.position.copy(ge)})}l&&(be.material.stencilWrite=!0,be.material.stencilRef=bt.PATH,be.material.stencilFunc=Br,be.material.stencilZPass=Me,be.material.stencilZFail=Me,be.material.stencilFail=Me,be.material.needsUpdate=!0,be.layers.disableAll(),be.layers.enable(ye.ALWAYS_ON_TOP_PATHS)),ce.computeBoundingBox();let yn=new O;return ce.boundingBox.getCenter(yn),{mesh:mr,material:pr,center:yn}}var Ab=.15,Rb=30,Bp=.01;var Fb=.5,_b=30,Bb=1e3/_b,kp=new z,ro=class extends q{rendererState;verticalDistanceDirty=!0;#e;#n=0;convertTo3DMapPosition;getParentContainer;convertZoomLevelToAltitude;constructor(e,t,r,n){super(),this.rendererState=e,this.convertTo3DMapPosition=t,this.getParentContainer=r,this.convertZoomLevelToAltitude=n}update(e,t,r,n){let i=!1;for(let s of this.rendererState.geometry3DsInScene)if(s&&s.type==="path"&&s.components[0].type==="path"){let a=s.components[0],l=s.components[1],c=a.isVertical&&this.verticalDistanceDirty;if(!(a instanceof wr))continue;let d=[];if(a.dirty||l.dirty||c){if(a.mesh.parent!=null)for(let u=a.mesh.children.length-1;u>=0;u--)Ce(a.mesh.children[0]);if(a.feature.features.length===2&&a.feature.features[0].properties.parentId&&a.feature.features[1].properties.parentId){let u=a.feature.features[0],h=a.feature.features[a.feature.features.length-1],v,f,M=u.geometry.coordinates[2]||0,p=h.geometry.coordinates[2]||0;u.properties.parentId&&(v=this.getParentContainer(u.properties.parentId,!0),v!=null&&v.altitude!=null&&(M+=v.altitude,a.isVertical=!0)),h.properties.parentId&&(f=this.getParentContainer(h.properties.parentId,!0),f!=null&&f.altitude!=null&&(p+=f.altitude,a.isVertical=!0));let m=this.convertTo3DMapPosition(u.geometry.coordinates[1],u.geometry.coordinates[0],M),g=this.convertTo3DMapPosition(h.geometry.coordinates[1],h.geometry.coordinates[0],p);Math.abs(m.z-g.z)>Fb&&v!=null&&v.visible&&f!=null&&f.visible&&(d=[m,g])}else{let u=a.feature.features;for(let h=0;h<u.length;h++)if(h===0||!Ed(u[h].geometry.coordinates,u[h-1].geometry.coordinates)){let v=this.convertTo3DMapPosition(u[h].geometry.coordinates[1],u[h].geometry.coordinates[0],u[h].geometry.coordinates[2]||0);d.push(v)}}if(d.length>1){let{mesh:u,material:h,center:v}=Gp(d,a,{color:l.color,isVertical:a.isVertical,metersPerPixel:n});a.mesh=u,a.material=h,a.position=v}a.dirty&&typeof a.width=="object"&&a.width.on==="zoom-level"&&(a.altitudeBreakpoints=a.width.input.map(u=>this.convertZoomLevelToAltitude(u))),a.dirty=!1}l.dirty&&(a.mesh.children.forEach(u=>{u.name!=="stencil"&&(u.name==="xray"?zp(l.color,a,u.material.uniforms.color.value):u.material.uniforms.color.value.set(l.color),u.material.visible=l.visible,u.material.needsUpdate=!0,u.name!=="xray"&&a.border?.color==="darken"&&u.material.uniforms.borderColor.value.copy(u.material.uniforms.color.value).multiplyScalar(.6))}),a.mesh.position.z=l.altitude,l.dirty=!1),a.material&&(a.mesh.children.forEach(u=>{let h=u.material.uniforms;if(u.name==="stencil"){a.materialDirty&&Np(a,u.material);return}if(a.materialDirty&&u.name==="xray"&&h.opacityMultiplier&&(h.opacityMultiplier.value=a.xrayOpacity,h.xrayDithering.value=a.xrayStyle?.dithering??0,zp(l.color,a,h.color.value)),typeof a.width=="object"&&a.width.on==="zoom-level"){a.altitudeBreakpoints&&a.altitudeBreakpoints.length>2&&R.warn("Path width interpolation does not yet support more than 2 breakpoints! This will be added in a future version. Path width will only use the first two breakpoints.");let f=Bc(r,a.altitudeBreakpoints?.slice(0,2)??[e,t]);a.breakpoint=f,h.nearZoom.value=a.altitudeBreakpoints?.[f]??e,h.farZoom.value=a.altitudeBreakpoints?.[f+1]??t;let M=a.parsedOutputValues;h.nearRadius.value=M[f]/2,h.farRadius.value=(M[f+1]??M[f])/2}h.cameraParameters.value.x=r,h.metersPerPixel.value=n,h.cameraViewMatrix.value.copy(this.rendererState.cameraObject.matrixWorldInverse);let v=typeof a.width=="object"&&a.width.on==="zoom-level";if(a.dashDiscrete&&a.maxDashCount>0&&(a.screenSpace||v)){let f=zl(h.nearRadius.value,h.farRadius.value,h.nearZoom.value,h.farZoom.value,r);h.dashCount.value=on(a,a.curveLength,f,n)}if(a.materialDirty){let f=a.dashDiscrete;h.displayArrowsOnPath.value=a.displayArrowsOnPath,h.dashCornerRadius.value=Math.min(Math.max(a.dashCornerRadius,0),1),h.pulseColor.value.set(a.accentColor),h.complete.value=a.completeFraction,Np(a,u.material),h.dashed.value=a.dashedMask,h.dashLength.value=a.dashLength,h.dashGap.value=a.dashGap,h.dashRelativeToWidth.value=a.dashRelativeToWidth,h.dashSize.value=a.dashSize,h.gapSize.value=a.gapSize,h.dashAbsolute.value=a.dashAbsolute,h.dashMeters.value=a.dashMeters,h.gapMeters.value=a.gapMeters;let M=typeof a.width=="object"&&a.width.on==="zoom-level";if(f&&a.maxDashCount>0){let b=a.screenSpace?Math.max(h.nearRadius.value*2*n,Bt):h.nearRadius.value*2,x=os(a,a.curveLength,b);if(x>0){let S=a.curveLength/x;S>a.maxDashCount&&a.maxDashCount<nn&&(a.dirty=!0),S>nn&&!a.dashCapWarned&&(R.warn(`Discrete dash path needs more than ${nn} dashes; dash spacing is saturated.`),a.dashCapWarned=!0)}!a.screenSpace&&!M&&(h.dashCount.value=on(a,a.curveLength,h.nearRadius.value,n))}let p=a.border;h.borderEnabled.value=p?.enabled??!1,h.borderWidth.value=p?.width??.1,p?.color==="darken"?h.borderColor.value.copy(h.color.value).multiplyScalar(.6):h.borderColor.value.set(p?.color??"#000000"),h.borderUseDarken.value=p?.color==="darken",h.billboardThreshold.value=Zl(a.billboarding);let[m,g]=a.endcapExtension;if(h.endcapEnabled.value.set(f||m<=0?0:1,f||g<=0?0:1),h.screenSpace.value=a.screenSpace,gr(a.width)){h.nearZoom.value=e,h.farZoom.value=t;let b=Ht(a.width);h.nearRadius.value=b/2,h.farRadius.value=b/2}else typeof a.width=="number"&&(h.nearZoom.value=e,h.farZoom.value=t,h.nearRadius.value=Number(a.width)/2,h.farRadius.value=Number(a.width)/2)}}),(a.displayArrowsOnPath||a.highlightDisplayArrowsOnPath)&&a.animateArrowsOnPath&&(a.mesh.children.forEach(u=>{u.name!=="stencil"&&(u.material.uniforms.arrowAnimationTimer.value=performance.now()/3e3)}),i=!0),a.materialDirty=!1)}this.verticalDistanceDirty=!1,i&&this.#i()}#i(){if(this.#e!==void 0)return;let e=Math.max(0,this.#n+Bb-performance.now());this.#e=setTimeout(()=>{this.#e=void 0,this.#n=performance.now(),this.publish("animate:path")},e)}cancelScheduledAnimation(){clearTimeout(this.#e),this.#e=void 0}destroy(){this.cancelScheduledAnimation(),super.destroy()}};function Np(o,e){let t=e.uniforms;t.highlightCompleteFraction.value=o.highlightCompleteFraction,t.highlightStartFraction.value=o.highlightStartFraction,t.highlightEndFraction.value=o.highlightEndFraction,t.highlightWidthMultiplier.value=o.highlightWidthMultiplier,t.highlightColor.value.set(o.highlightColor),t.highlightDisplayArrowsOnPath.value=o.highlightDisplayArrowsOnPath,t.travelledEndFraction.value=o.travelledEndFraction,t.travelledColor.value.set(o.travelledColor)}function zp(o,e,t){let r=e.xrayStyle?.color?kp.set(e.xrayStyle.color):kp.set(o);jl(r,t,e.xrayStyle?.tint)}y();var hs=class{rendererState;dirty=!1;constructor(e){this.rendererState=e}#e;#n;#i;#o=new K;updateOne(e){if(e instanceof Q&&e.components[0]instanceof ue&&e.components[1]instanceof Dt&&e.parentObject3D instanceof Fe&&(this.#e=e.components[0],this.#i=e.components[1],!this.#e.detached&&this.#e.shouldDetach&&this.#e.mesh!=null&&this.#e.material instanceof ei&&this.#e.batchedProps!=null)){this.#n=e.parentObject3D,this.#e.visible=!1;let t=this.#i.color,r=this.#i.opacity*Yr(e),n=this.#e.material,i=r??1,s=n.clone({color:t,side:Hd(this.#i.side,i),opacity:i,transparent:i<1}),a=new Du(1,this.#e.batchedProps.positionCount,0,s);a.layers.enable(Ve.SHOULD_CAST_SHADOWS);let l=Au(this.#e,a,this.#o);if(l==null)return;a.userData={entities:{0:e.id},detached:!0},this.#e.instanceIndex=l,s.setColor(this.#e.instanceIndex,new z(t),this.#i.topColor?new z(this.#i.topColor):new z(t)),this.#e.mesh=a,this.#e.currentHeight=-1,this.#e.material=s,this.#n.add(a),this.#e.shouldDetach=!1,this.#e.detached=!0,this.#i.dirty=!0}}update(){if(!this.dirty)return;let e;for(let t of this.rendererState.geometry3DIdsInScene)e=this.rendererState.geometry3DMap.get(t),this.updateOne(e);this.dirty=!1,this.cleanup()}cleanup(){this.#e=void 0,this.#n=void 0,this.#i=void 0}};y();var ps=class{rendererState;dirty=!1;constructor(e){this.rendererState=e}#e;#n;#i;updateOne(e){if(e instanceof Q&&e.type==="geometry"&&e.components[1]?.dirty){this.#e=e.components[0],this.#n=e.components[1],this.#i=e.components[8];let t=this.#n.height*this.#n.heightScale;if(e.type==="geometry")if(this.#e.mesh instanceof $r){let r=!1;t!==this.#e.currentHeight&&(r=wa(this.#e,t,this.#n.initialHeight)),this.#n.altitude!==this.#e.altitude&&(r=Ea(this.#e,this.#n.altitude)||r),r=this.applySlope()||r,r&&this.#e.mesh!=null&&this.#e.mesh.geometry.computeBoundingSphere()}else{let r=!1;t!==this.#e.currentHeight&&(r=wa(this.#e,t,this.#n.initialHeight)),this.#n.altitude!==this.#e.altitude&&(r=Ea(this.#e,this.#n.altitude)),r=this.applySlope()||r,r&&this.#e.mesh!=null&&this.#e.mesh.computeBoundingSphere()}}}update(){for(let e of this.rendererState.geometry3DsInScene)this.updateOne(e);this.cleanup()}applySlope(){let e=this.#e,t=this.#n,r=this.#i;if(!e||!t||!r)return!1;let n=t.slope;if(n&&n.factor!==0)try{return Da(r,e,n,t.initialHeight)}catch(i){return R.warn("Failed to apply slope to entity:",i),!1}if(r.currentSlope)try{return Da(r,e,{bearing:0,factor:0},t.initialHeight)}catch(i){return R.warn("Failed to clear slope on entity:",i),!1}return!1}cleanup(){this.#e=void 0,this.#n=void 0,this.#i=void 0}};y();var Gb={showPolygonLabelTextAreaMesh:!1,showEnvMap:!1,showCollisionBoxes:!1,showGeometryInFocus:!1,showImageLOD:!1,showModelInstancingStats:!1,showScreenOffsets:!1,showCameraTargets:!1,focusOn:!1},ms=class{state=Gb;core;constructor(e){this.core=e}update(e){let t={};for(let r of Object.keys(e))r in this.state&&this.state[r]!==e[r]&&(Object.assign(this.state,{[r]:e[r]}),Object.assign(t,{[r]:e[r]}));this.handleUpdate(t)}handleUpdate(e){if(e.showPolygonLabelTextAreaMesh!=null&&(e.showPolygonLabelTextAreaMesh?this.core.getSystems().text3DSystem.showTextAreaMesh():this.core.getSystems().text3DSystem.hideTextAreaMesh()),e.showEnvMap!=null&&(e.showEnvMap?this.core.setEnvironment("basic"):this.core.setEnvironment(!1)),e.showCollisionBoxes!=null&&(e.showCollisionBoxes?this.core.showCollisionBoxes():this.core.hideCollisionBoxes()),e.showGeometryInFocus!=null&&(e.showGeometryInFocus?this.core.getSystems().geometryInFocusSystem.showDebug():this.core.getSystems().geometryInFocusSystem.hideDebug()),e.showImageLOD!=null&&(this.core.getSystems().imageSystem.debugLOD=e.showImageLOD,this.core.render()),e.showModelInstancingStats!=null&&(e.showModelInstancingStats?this.core.getSystems().modelSystem.showDebug():this.core.getSystems().modelSystem.hideDebug()),e.showScreenOffsets!=null&&(e.showScreenOffsets?this.core.camera.showScreenOffsetsDebug():this.core.camera.hideScreenOffsetsDebug()),e.showCameraTargets!=null&&(e.showCameraTargets?this.core.camera.showCameraTargetsDebug():this.core.camera.hideCameraTargetsDebug()),"focusOn"in e){let t=e.focusOn;t===!1||t==null?this.core.camera.hideFocusOnDebug():this.core.camera.showFocusOnDebug(t)}}};y();y();function Up(){return typeof window<"u"&&window.__MAPPEDIN_E2E__===!0}var no=9,kb=!1,Hp=.1,Wp=9;function Nb(o,e,t){for(let r=0;r<e;r++){let n=(t&16711680)>>16,i=(t&65280)>>8,s=t&255;o[r*3]=n/255,o[r*3+1]=i/255,o[r*3+2]=s/255}}var fs=class{state;renderer;renderService;pickingTexture;pickingMaterial;pixelBuffer;width=0;height=0;scale=1/2;color=1;convertTo3DMapPosition;destroyed=!1;enabled=!1;backgroundId=16777215;applyId(e,t){let r=e.attributes.position,n=new Float32Array(r.count*3);Nb(n,r.count,t),e.setAttribute("color",new De(n,3))}createOccluderMesh(e,t){let r=new X(e,this.pickingMaterial);return r.layers.set(no),this.applyId(r.geometry,t),r.userData.occluderId=t,r}constructor(e,t,r){if(this.state=e,this.convertTo3DMapPosition=t,r?.renderer==null)throw new Error("No Renderer");this.renderService=r,this.renderer=r.renderer,this.resize(),this.pickingMaterial=new lt({glslVersion:Yc,vertexShader:`
1032
- attribute vec3 color;
1033
- varying vec3 vColor;
1034
- void main() {
1035
- vColor = color;
1036
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1037
- }
1038
- `,fragmentShader:`
1039
- varying vec3 vColor;
1040
- out vec4 fragColor;
1041
-
1042
- void main() {
1043
- fragColor = vec4(vColor, 1.0);
1044
- }
1045
- `})}reserveOccluderId(){return this.color++,this.color}enable(){this.enabled=!0}disable(){this.enabled=!1}resize=()=>{let e=this.state.pixelRatio;this.width=Math.floor(this.renderer.domElement.width/e*this.scale),this.height=Math.floor(this.renderer.domElement.height/e*this.scale),this.pixelBuffer=new Uint8Array(4*this.width*this.height),this.pickingTexture=new Tn(this.width,this.height,{format:_o,type:Fo,internalFormat:"RGBA"})};shouldShowByXY=(e,t,r)=>{if(this.pixelBuffer==null)return!1;let n=e+(this.height-t-1)*this.width,i=this.pixelBuffer[n*4],s=this.pixelBuffer[n*4+1],a=this.pixelBuffer[n*4+2],l=i<<16|s<<8|a;return l===r||l===this.backgroundId};activeOccluders=new Set;framesSinceLastUpdate=Wp;update=()=>{if(Up()){this.updateImmediately();return}this.framesSinceLastUpdate++,this.framesSinceLastUpdate>=Wp&&(this.framesSinceLastUpdate=0,this.updateImmediately())};updateImmediately=()=>{if(!this.enabled||this.destroyed||(this.activeOccluders.clear(),this.activeOccluders.add(this.backgroundId),!this.pickingTexture||!this.pixelBuffer))return;let e,t;for(let n of this.state.geometry3DsInScene)if(n?.type==="group-container"&&n.userData.occluderFeature!=null&&n.userData.occluderId!=null&&(this.activeOccluders.add(n.userData.occluderId),n.userData.occluderDirty)){if(e=n.userData.occluderFeature,e.geometry.type==="Polygon"&&e.geometry.coordinates.length>0){let i=di(e,this.convertTo3DMapPosition,{color:"white",height:Hp});t=this.createOccluderMesh(i,n.userData.occluderId),n.add(t)}else if(e.geometry.type==="MultiPolygon"){let i=ui(e,this.convertTo3DMapPosition,{color:"white",height:Hp});t=this.createOccluderMesh(i,n.userData.occluderId),n?.add(t)}n.userData.occluderDirty=!1}this.renderer.setRenderTarget(this.pickingTexture);let r=new z(this.backgroundId);this.renderer.setClearColor(r),this.renderer.clear(),this.state.cameraObject.layers.disableAll(),this.state.cameraObject.layers.enable(no),this.renderService.renderScene(this.state.geometryScene.parent,this.state.cameraObject),this.renderer.setRenderTarget(null),this.state.cameraObject.layers.disable(no),kb?this.renderService.enabledLayers.add(no):this.renderService.enabledLayers.delete(no),this.renderer.readRenderTargetPixelsAsync(this.pickingTexture,0,0,this.width,this.height,this.pixelBuffer).then(()=>{if(!this.destroyed)for(let n of this.state.geometry2DsInScene){let i=n?.components[2];if(n&&i?.id!=null&&this.activeOccluders.has(i.id)&&i?.enabled){let s=n.components[0].projection,a=Math.floor(s.x*this.scale),l=Math.floor(s.y*this.scale),c=this.shouldShowByXY(a,l,i.id);n.components[0].isOccluded=!c}else n&&i&&!i.enabled&&(n.components[0].isOccluded=!1)}}).catch(n=>{this.destroyed||R.error(n)})};destroy(){this.destroyed=!0,this.pickingTexture?.dispose(),this.pickingMaterial.dispose(),this.pickingTexture=void 0,this.pixelBuffer=void 0}};y();var gs=class{constructor(e){this.state=e}dirty=!0;update(){if(this.dirty){for(let e of this.state.geometry3DIdsInScene){let t=this.state.geometry3DMap.get(e);if(t instanceof Q&&t.type==="geometry"&&t.components[0]?.geometry!=null){let r=t.components[0];if(r.mesh instanceof $r)continue;r.geometry&&(r.geometry.dispose(),r.geometry=void 0)}}this.dirty=!1}}};y();var ys=class extends q{dirty=!0;state;constructor(e){super(),this.state=e}texturePromiseCache=new Map;async loadTexture(e){if(this.texturePromiseCache.has(e))return this.texturePromiseCache.get(e);let t=new Promise((r,n)=>{er.getLoader().load(e,r,void 0,n)});return this.texturePromiseCache.set(e,t),t}update(){for(let e of this.state.geometry3DsInScene){if(!(e instanceof Q))continue;let t=e.components[6];if(!(t instanceof Mr))continue;let r=e.components[0];if(!(r instanceof ue)||!t.dirty)continue;let n=Bn(r);n!=null&&(t.texture!=null&&(t.texture.path===""?(n.texture=null,n.hideTextures(r.instanceIndex),t.dirty=!1):this.loadTexture(t.texture.path).then(i=>{i&&(t.textureInstance=i,n.texture=i,n.blendTexture=!0,n.showTextures(r.instanceIndex)),this.publish("texture-added")})),t.topTexture!=null&&(t.topTexture.path===""?(n.topTexture=null,n.hideTextures(r.instanceIndex),t.dirty=!1):this.loadTexture(t.topTexture.path).then(i=>{i&&(t.topTextureInstance=i,n.topTexture=i,n.blendTexture=!0,n.showTextures(r.instanceIndex)),this.publish("texture-added")})),t.dirty=!1)}}destroy(){this.texturePromiseCache.forEach(async e=>{(await e).dispose()}),this.texturePromiseCache.clear()}};y();var bs=class{currentOrder=ye.ALWAYS_ON_TOP_MODELS;assignedOrders=new WeakMap;state;constructor(e){this.state=e}assignOrder(e){return this.assignedOrders.has(e)?this.assignedOrders.get(e):(this.currentOrder+=1,this.assignedOrders.set(e,this.currentOrder),this.currentOrder)}releaseOrder(e){return this.assignedOrders.delete(e),ye.GEOMETRY}getHighestOrder(){return this.currentOrder}getOrder(e){return this.assignedOrders.get(e)}update(){let e,t;for(let r of this.state.geometry3DsInScene)if(r&&r.type==="model"&&(e=r.components[1],e?.renderOrderDirty)){if(t=r.components[0],!t.mesh)continue;if(t.visibleThroughGeometry=e.visibleThroughGeometry,e.visibleThroughGeometry===!0){let n=this.assignOrder(t);t.renderOrder=n,this.applyRenderOrder(t)}else t.renderOrder>ye.GEOMETRY&&(t.renderOrder=this.releaseOrder(t),this.applyRenderOrder(t));e.renderOrderDirty=!1}}applyRenderOrder(e){if(!e.mesh)return;let t=e.renderOrder,r=e.visibleThroughGeometry;if(e.mesh.children[0]instanceof re){e.mesh.renderOrder=t;for(let i of e.mesh.children)i instanceof re&&(i.renderOrder=t);if(e.mesh.userData?.detached)for(let i of e.mesh.children)i instanceof re&&(Array.isArray(i.material)?i.material.forEach(s=>{s.depthWrite=!r,s.depthTest=!r,r&&(s.transparent=!0),s.needsUpdate=!0}):(i.material.depthWrite=!r,i.material.depthTest=!r,r&&(i.material.transparent=!0),i.material.needsUpdate=!0))}else e.mesh.traverse(n=>{let i=n;"isMesh"in i&&i.isMesh===!0&&i.material&&(i.renderOrder=t,Array.isArray(i.material)?i.material.forEach(s=>{s.depthWrite=!r,s.depthTest=!r,r&&(s.transparent=!0),s.needsUpdate=!0}):(i.material.depthWrite=!r,i.material.depthTest=!r,r&&(i.material.transparent=!0),i.material.needsUpdate=!0))})}};y();var vs=class o{state;constructor(e){this.state=e}applyMask(e,t,r){this.disableMask(e,t),r.mode==="mask"&&r.maskId!=null&&r.enabled?this.enableMaskProducer(e,t,r):r.mode==="masked-object"&&r.maskId!=null&&r.enabled&&this.enableMaskReciever(e,r)}update(){let e;for(let t of this.state.geometry3DsInScene)t?.type==="feature-collection"&&(!Xn(t,this.state)||Zn(t)&&Xn(t,this.state))&&(e=t.components[0],e?.dirty&&(t.traverse(r=>{(r instanceof X||r instanceof Xt)&&r.material instanceof Jc&&e!=null&&!r.userData.detached&&(this.disableMask(r.material,r),this.applyMask(r.material,r,e))}),e.dirty=!1))}static MASK_RENDER_ORDER=-1e3;enableMaskProducer(e,t,r){e.stencilWrite=!0,e.colorWrite=!1,e.stencilRef=r.maskId,e.stencilFunc=Gr,e.stencilZPass=Bo,e.stencilZFail=Me,e.stencilFail=Me,e.needsUpdate=!0,e.depthWrite=!1,t.userData.originalTransparent===void 0&&(t.userData.originalTransparent=e.transparent),e.transparent=!1,t.layers.disableAll(),t.layers.set(ye.GEOMETRY),t.userData.originalRenderOrder===void 0&&(t.userData.originalRenderOrder=t.renderOrder),t.renderOrder=o.MASK_RENDER_ORDER}enableMaskReciever(e,t){e.stencilWrite=!0,e.stencilRef=t.maskId,e.stencilFunc=t.effect==="reveal"?Go:Br,e.stencilZPass=Me,e.stencilZFail=Me,e.stencilFail=Me,e.needsUpdate=!0}disableMask(e,t){e.stencilWrite=!1,e.colorWrite=!0,t.userData.originalTransparent!==void 0&&(e.transparent=t.userData.originalTransparent,delete t.userData.originalTransparent),e.needsUpdate=!0,t.layers.disableAll(),t.layers.set(ye.GEOMETRY),t.userData.originalRenderOrder!==void 0&&(t.renderOrder=t.userData.originalRenderOrder,delete t.userData.originalRenderOrder)}};y();var Vp=.5,xs=class{rendererState;dirty=!1;constructor(e){this.rendererState=e}update(){let e,t,r;for(let n of this.rendererState.geometry3DsInScene)if(t=n.components[0],r=n.components[1],e=n.components[7],n.type==="model"&&e!=null&&r?.EXPERIMENTAL_clippingEnabled&&(e.dirty&&t.mesh!=null&&(e.plane==null&&(e.plane=new ed(new O(0,0,-1),e.verticalOffset),this.process(t,e)),e.plane.constant!==e.verticalOffset&&(e.plane.constant=e.verticalOffset),e.topColor!=null&&e.holeFillMesh?.material instanceof On&&e.holeFillMesh.material.color.set(e.topColor),e.topVisible!=null&&e.holeFillMesh!=null&&(e.holeFillMesh.visible=e.topVisible,e.holeFillGroup!=null&&(e.holeFillGroup.visible=e.topVisible)),e.dirty=!1),e.plane!=null&&e.holeFillMesh!=null&&e.topVisible===!0)){let i=e.holeFillMesh,s=e.verticalOffset,a=e.bboxCenter?.x??0,l=e.bboxCenter?.y??0;i.position.set(a,l,s),i.lookAt(a,l,s+1)}}process(e,t){if(e.mesh==null)return;let r=e.mesh.parent,n=[];e.mesh.traverse(m=>{if(m instanceof X){let g=m.geometry.clone();if(m instanceof re){let b=e.instanceIndex??0,x=new K;m.getMatrixAt(b,x),g.applyMatrix4(x)}else m.updateWorldMatrix(!0,!1),g.applyMatrix4(m.matrixWorld);n.push(g),g.computeVertexNormals(),m.material.clippingPlanes=[t.plane]}});let i=Ke(n),s=new ko,a=new ko;i.computeBoundingBox();let l=i.boundingBox,c=(l.min.x+l.max.x)/2,d=(l.min.y+l.max.y)/2,u=l.max.x-l.min.x+Vp*2,h=l.max.y-l.min.y+Vp*2;t.bboxCenter={x:c,y:d};let v=new We(u,h),f=this.createHoleFillGeometry(i,t.plane,1);f.name="hole-fill-group",t.holeFillGroup=f;let M=new On({color:t.topColor??"#E67B5B",clippingPlanes:[],stencilWrite:!0,stencilRef:bt.CLIPPING_BIT,stencilFunc:Go,stencilFuncMask:bt.CLIPPING_BIT,stencilWriteMask:bt.CLIPPING_BIT,stencilFail:Me,stencilZFail:Me,stencilZPass:Xc}),p=new X(v,M);p.name="hole-fill-mesh",t.holeFillMesh=p,p.renderOrder=1.1,a.add(f),a.add(e.mesh),s.add(a),s.add(p),r?.add(s),e.mesh=s}createHoleFillGeometry(e,t,r=0){let n=new ko,i=new Be;i.depthWrite=!1,i.depthTest=!1,i.colorWrite=!1,i.stencilWrite=!0,i.stencilFunc=Gr,i.stencilWriteMask=bt.CLIPPING_BIT;let s=i.clone();s.side=zc,s.clippingPlanes=[t],s.stencilFail=vr,s.stencilZFail=vr,s.stencilZPass=vr;let a=new X(e,s);a.renderOrder=r,n.add(a);let l=i.clone();l.side=Ro,l.clippingPlanes=[t],l.stencilFail=vr,l.stencilZFail=vr,l.stencilZPass=vr;let c=new X(e,l);return c.renderOrder=r,n.add(c),n}};y();var Ss=class{plugins=new Set;registerPlugin(e){this.plugins.add(e)}unregisterPlugin(e){this.plugins.delete(e)}update(e,t){for(let r of this.plugins)r.update(e,t)}};y();var Ms=class{type="occlusion2d";enabled=!0;id;constructor(e){this.id=e}};y();y();y();var jp=`varying vec4 vWorldPosition;
1046
-
1047
- void main() {
1048
- vWorldPosition = modelMatrix * vec4(position, 1.0);
1049
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1050
- }
1051
-
1052
- `;y();var Xl=`uniform sampler2D shadowMap;
1053
- uniform mat4 lightMatrix;
1054
- uniform float shadowBias;
1055
- uniform float shadowOpacity;
1056
- uniform vec3 baseColor;
1057
- uniform float shadowMapSize;
1058
- uniform float pcfSpread;
1059
- uniform float depthRangeMax;
1060
- uniform bool shadowEnabled;
1061
- varying vec4 vWorldPosition;
1062
- float shadowThreshold = 0.05;
1063
- float shadowStrengthMultiplier = 0.6;
1064
-
1065
- /**
1066
- * Interleaved gradient noise for temporal/spatial dithering of shadow samples
1067
- */
1068
- float interleavedGradientNoise(vec2 position) {
1069
- vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
1070
- return fract(magic.z * fract(dot(position, magic.xy)));
1071
- }
1072
-
1073
- // Compile-time sample count for loop unrolling (injected via material)
1074
- #ifndef PCF_SAMPLES
1075
- #define PCF_SAMPLES 4
1076
- #endif
1077
-
1078
- // Poisson disk samples - only define what we need based on sample count
1079
- #if PCF_SAMPLES <= 4
1080
- const vec2 poissonDisk[4] = vec2[](
1081
- vec2(-0.94201624, -0.39906216),
1082
- vec2(0.94558609, -0.76890725),
1083
- vec2(-0.094184101, -0.92938870),
1084
- vec2(0.34495938, 0.29387760)
1085
- );
1086
- #elif PCF_SAMPLES <= 8
1087
- const vec2 poissonDisk[8] = vec2[](
1088
- vec2(-0.94201624, -0.39906216),
1089
- vec2(0.94558609, -0.76890725),
1090
- vec2(-0.094184101, -0.92938870),
1091
- vec2(0.34495938, 0.29387760),
1092
- vec2(-0.91588581, 0.45771432),
1093
- vec2(-0.81544232, -0.87912464),
1094
- vec2(-0.38277543, 0.27676845),
1095
- vec2(0.97484398, 0.75648379)
1096
- );
1097
- #else
1098
- const vec2 poissonDisk[16] = vec2[](
1099
- vec2(-0.94201624, -0.39906216),
1100
- vec2(0.94558609, -0.76890725),
1101
- vec2(-0.094184101, -0.92938870),
1102
- vec2(0.34495938, 0.29387760),
1103
- vec2(-0.91588581, 0.45771432),
1104
- vec2(-0.81544232, -0.87912464),
1105
- vec2(-0.38277543, 0.27676845),
1106
- vec2(0.97484398, 0.75648379),
1107
- vec2(0.44323325, -0.97511554),
1108
- vec2(0.53742981, -0.47373420),
1109
- vec2(-0.26496911, -0.41893023),
1110
- vec2(0.79197514, 0.19090188),
1111
- vec2(-0.24188840, 0.99706507),
1112
- vec2(-0.81409955, 0.91437590),
1113
- vec2(0.19984126, 0.78641367),
1114
- vec2(0.14383161, -0.14100790)
1115
- );
1116
- #endif
1117
-
1118
- /**
1119
- * Samples the shadow map using PCF (Percentage Closer Filtering)
1120
- * Uses compile-time loop count for GPU optimization
1121
- * @param lightSpacePos Position in light space coordinates
1122
- * @returns Visibility factor (1.0 = fully lit, 0.0 = fully shadowed)
1123
- */
1124
- float sampleShadow(vec3 lightSpacePos) {
1125
- float scaledTexelSize = (1.0 / shadowMapSize) * pcfSpread;
1126
- float currentDepth = lightSpacePos.z * depthRangeMax;
1127
-
1128
- // Rotation for temporal stability
1129
- float noise = interleavedGradientNoise(gl_FragCoord.xy) * 6.283185;
1130
- float cosNoise = cos(noise);
1131
- float sinNoise = sin(noise);
1132
- mat2 rotation = mat2(cosNoise, -sinNoise, sinNoise, cosNoise);
1133
-
1134
- float shadow = 0.0;
1135
-
1136
- // Compile-time unrolled loop - GPU can optimize this efficiently
1137
- for(int i = 0; i < PCF_SAMPLES; i++) {
1138
- vec2 offset = rotation * poissonDisk[i] * scaledTexelSize;
1139
- vec2 uv = clamp(lightSpacePos.xy + offset, 0.0, 1.0);
1140
-
1141
- float sampledDepth = texture2D(shadowMap, uv).r;
1142
- shadow += step(sampledDepth + shadowBias, currentDepth);
1143
- }
1144
-
1145
- return 1.0 - shadow / float(PCF_SAMPLES);
1146
- }
1147
-
1148
- void main() {
1149
- if (shadowEnabled) {
1150
- // Transform world position to light space
1151
- vec4 shadowCoord = lightMatrix * vWorldPosition;
1152
- vec3 projCoords = shadowCoord.xyz / shadowCoord.w;
1153
-
1154
- // Check if fragment is within shadow map bounds
1155
- bool inBounds = projCoords.x >= 0.0 && projCoords.x <= 1.0 &&
1156
- projCoords.y >= 0.0 && projCoords.y <= 1.0 &&
1157
- projCoords.z >= 0.0 && projCoords.z <= 1.0;
1158
-
1159
- if (inBounds) {
1160
- float visibility = sampleShadow(projCoords);
1161
- float shadowIntensity = 1.0 - visibility;
1162
-
1163
- if (shadowIntensity > shadowThreshold) {
1164
- float shadowStrength = shadowIntensity * shadowOpacity * shadowStrengthMultiplier;
1165
- gl_FragColor = vec4(baseColor, shadowStrength);
1166
- }
1167
- }
1168
- }
1169
- }
1170
-
1171
- `;var Cs=class extends lt{pcfSampleCount=4;constructor(){super({vertexShader:jp,fragmentShader:`#define PCF_SAMPLES 4
1172
- `+Xl,uniforms:{shadowMap:{value:null},lightMatrix:{value:new K},shadowBias:{value:8e-5},shadowOpacity:{value:.25},baseColor:{value:new z(8421504)},shadowMapSize:{value:4096},pcfSpread:{value:3.5},depthRangeMax:{value:1},shadowEnabled:{value:!1}},transparent:!0,depthWrite:!1,side:Vt,stencilWrite:!0,stencilFunc:Br,stencilRef:bt.UNDERGROUND_MASK,stencilFail:Me,stencilZFail:Me,stencilZPass:Me})}setShadowUniforms(e,t,r,n,i,s,a,l,c,d){this.uniforms.shadowMap.value=e,this.uniforms.lightMatrix.value.copy(t),this.uniforms.shadowBias.value=r,this.uniforms.shadowOpacity.value=n,this.uniforms.baseColor.value=i,this.uniforms.shadowMapSize.value=s,this.uniforms.pcfSpread.value=a,this.uniforms.depthRangeMax.value=c,this.uniforms.shadowEnabled.value=d,l!==this.pcfSampleCount&&(this.pcfSampleCount=l,this.fragmentShader=`#define PCF_SAMPLES ${l}
1173
- `+Xl,this.needsUpdate=!0)}};y();var Zp=1024,or={software:[/swiftshader/,/llvmpipe/,/software rasterizer/,/microsoft basic render/],weakMobile:[/adreno \(tm\) [345]\d\d/,/mali-4\d\d/,/mali-t\d/,/mali-g3\d/,/powervr ge/,/powervr rogue/,/vivante/],discrete:[/geforce/,/\brtx\b/,/\bgtx\b/,/arc\(tm\) [ab]\d/,/\barc [ab]\d/,/radeon rx(?! vega)/,/radeon pro/,/radeon r[579]/,/\brx \d{3,4}\b/,/vega (48|56|64)\b/,/apple m\d/],integrated:[/intel/,/radeon vega/,/radeon\(tm\) graphics/,/radeon graphics/,/vega (3|6|7|8|10|11)\b/,/gma/],appleGPU:[/apple gpu/],modernMobile:[/adreno \(tm\) [678]\d\d/,/mali-g[5-9]\d/,/immortalis/,/xclipse/],maskedPlaceholder:[/^mozilla$/,/^webkit webgl$/,/^webkit$/,/^google inc\.?$/,/^generic renderer$/]};function ir(o,e){return e!==void 0&&o.some(t=>t.test(e))}function Ub(o){let{hasContext:e,isMobile:t,maxTextureSize:r}=o,n=o.gpu?.trim().toLowerCase(),i=n===void 0||n===""||ir(or.maskedPlaceholder,n)?void 0:n;return e?ir(or.software,i)?{tier:"off",reason:`software renderer: "${i}"`}:r!==void 0&&r<Zp?{tier:"off",reason:`maxTextureSize ${r} is below ${Zp}`}:t?ir(or.weakMobile,i)?{tier:"off",reason:`weak mobile GPU: "${i}"`}:ir(or.modernMobile,i)||ir(or.appleGPU,i)?{tier:"medium",reason:`modern mobile GPU: "${i}"`}:{tier:"low",reason:"no decisive signal (mobile)"}:ir(or.discrete,i)||ir(or.appleGPU,i)?{tier:"high",reason:`desktop discrete GPU: "${i}"`}:ir(or.integrated,i)?{tier:"low",reason:`integrated desktop GPU: "${i}"`}:i===void 0?{tier:"medium",reason:"no decisive signal (desktop)"}:{tier:"low",reason:`unrecognised or old desktop GPU: "${i}"`}:{tier:"off",reason:"no WebGL context"}}var ws={low:{pcfSamples:1,pcfSpread:3,shadowBias:.001,normalBias:.2,visibleAtZoomLevel:19,ladder:{high:1024,low:512}},medium:{pcfSamples:2,pcfSpread:3,shadowBias:.001,normalBias:.15,visibleAtZoomLevel:18,ladder:{high:2048,low:1024}},high:{pcfSamples:4,pcfSpread:3,shadowBias:.001,normalBias:.12,visibleAtZoomLevel:18,ladder:{high:4096,low:2048}}};function Xp(o,e){return e===void 0?o:{high:Math.min(o.high,e),low:Math.min(o.low,e)}}var Hb=["low","medium","high"],Yp=o=>({pcfSamples:o.pcfSamples,pcfSpread:o.pcfSpread,shadowBias:o.shadowBias,normalBias:o.normalBias,visibleAtZoomLevel:o.visibleAtZoomLevel}),Wb=o=>{if(typeof o=="number")return Object.is(o,-0)?"-0":String(o);try{return JSON.stringify(o)??String(o)}catch{return String(o)}};function $p(o,e){if(o===void 0||o===!1)return{enabled:!1,logLines:[]};if(o==="auto"){let p=e(),{tier:m,reason:g}=Ub(p);if(m==="off")return{enabled:!1,logLines:[{level:"info",message:`Shadows: auto -> off (${g})`}]};let b=ws[m];return{enabled:!0,options:Yp(b),ladder:Xp(b.ladder,p.maxTextureSize),tier:m,logLines:[{level:"info",message:`Shadows: auto -> ${m} (mobile: ${p.isMobile}, gpu: ${JSON.stringify(p.gpu)}, maxTextureSize: ${p.maxTextureSize}, dpr: ${p.dpr})`}]}}let t=o,r=typeof t=="object"&&t!==null&&!Array.isArray(t);if(t!==!0&&!r)return{enabled:!1,logLines:[{level:"error",message:`Shadows: unrecognised value ${Wb(t)} - expected true, 'auto', an options object, or false. Shadows are off.`}]};let n=t===!0?{}:t,i=e(),s=[],a=n.quality,l=a===void 0||Hb.includes(a);l||s.push({level:"error",message:`Shadows: unknown quality "${a}" - falling back to 'high'.`});let c=l&&a!==void 0,d=c?a:"high",u=!c&&i.isMobile;u&&s.push({level:"warn",message:"Shadows: 'high' is capped to 'medium' on mobile to bound VRAM - pass { quality: 'high' } to force it."});let h=u?"medium":d,{quality:v,...f}=n,M=ws[h];return{enabled:!0,options:{...Yp(M),...f},ladder:Xp(M.ladder,i.maxTextureSize),tier:h,logLines:s}}function qp(o){let e=o?.renderer??void 0,t=e!==void 0,r=!1,n;try{r=jo().isMobile,n=bd()?.toLowerCase()}catch{}return{hasContext:t,isMobile:r,gpu:n,maxTextureSize:e?.capabilities?.maxTextureSize,dpr:o?.pixelRatio}}var Vb=.001,dt={quality:"high",debug:!1,baseColor:"#a0a0a0",shadowOpacity:.25,pcfSamples:4,pcfSpread:3,shadowBias:Vb,normalBias:.12,shadowMapSize:"auto",sunAzimuth:225,sunElevation:45,visibleAtZoomLevel:18},Es=1e4,Jp=-.05,jb=999,Zb=.05,Xb=ws.high.ladder,Yb=20.5,$b=19.5,qb=5,Kp=.001,Jb=2,Qp=.1,em=1,Kb=400,Qb=-200,ev=50,tv=100,rv=-50,nv=40,an=15,Gt=22,ov=100,iv=5,sv=50,av=50,lv=40,cv=5,dv=.5,Yl=1,tm=1,uv=5,Te=256,hv=65535,pv=.5,Ds=.1,mv=1e3,fv=16737792,gv=.2,rm=.2,yv=1001,bv=8900331,$l=!0,Ts=class o{state;rendererService;depthMaterial;cameraOrbit;lightCamera;shadowRenderTarget;lightMatrix=new K;currentSnapX=0;currentSnapY=0;shadowCenter=new O;shadowMapStale=!0;uniformsDirty=!0;scratchVector=new O;scratchCorner=new O;uniformMaterialsSeen=new Set;casterBounds=new de;castersDirty=!0;depthScale=1;scratchBox=new de;shadowPlane=null;shadowPlaneMaterial=null;shadowPlaneEnabled=!0;visibleAtCurrentZoom=!0;zoomOpacityFactor=1;lightCameraHelper=null;debugEnabled=!1;debugGrid=null;debugCurrentCell=null;debugCurrentCellMaterial=null;debugCanvas=null;debugCanvasCtx=null;debugRenderTarget=null;debugDepthMaterial=null;debugDepthQuad=null;debugDepthScene=null;debugDepthCamera=null;options;internal;shadowResolutionSizes;shadowResolutionZoomThresholds={high:Yb,low:$b};constructor(e,t,r,n,i=Xb){this.state=e,this.cameraOrbit=r,this.rendererService=t,this.shadowResolutionSizes=i,this.options=Object.freeze({quality:n?.quality??dt.quality,debug:n?.debug??dt.debug,baseColor:n?.baseColor??dt.baseColor,shadowOpacity:n?.shadowOpacity??dt.shadowOpacity,pcfSamples:n?.pcfSamples??dt.pcfSamples,pcfSpread:n?.pcfSpread??dt.pcfSpread,shadowBias:n?.shadowBias??dt.shadowBias,normalBias:n?.normalBias??dt.normalBias,shadowMapSize:n?.shadowMapSize??dt.shadowMapSize,sunAzimuth:n?.sunAzimuth??dt.sunAzimuth,sunElevation:n?.sunElevation??dt.sunElevation,visibleAtZoomLevel:n?.visibleAtZoomLevel??dt.visibleAtZoomLevel});let s=this.options.shadowMapSize==="auto"?this.shadowResolutionSizes.high:this.options.shadowMapSize;this.internal={baseColor:new z(this.options.baseColor),lightOrthoSize:ev,sunDistance:tv,groundZPosition:rv,snapGridSize:nv,currentShadowMapSize:s,currentShadowResolutionMode:(this.options.shadowMapSize==="auto",null),sunDirection:new O,sunAzimuth:this.options.sunAzimuth,sunElevation:this.options.sunElevation},this.updateSunDirection(),this.lightCamera=new ya(-this.internal.lightOrthoSize,this.internal.lightOrthoSize,this.internal.lightOrthoSize,-this.internal.lightOrthoSize,Qp,Kb),this.lightCamera.layers.disableAll(),this.lightCamera.layers.enable(Ve.SHOULD_CAST_SHADOWS),this.lightCamera.position.copy(this.internal.sunDirection.clone().multiplyScalar(Qb)),this.lightCamera.lookAt(new O(0,0,0)),this.lightCamera.updateMatrixWorld(),this.lightCamera.updateProjectionMatrix(),this.shadowRenderTarget=this.createShadowRenderTarget(s),this.depthMaterial=o.createDepthMaterial(),this.createShadowPlane(),this.options.debug&&this.setDebugEnabled(!0)}static createDepthMaterial(){let e=new sd;return e.depthPacking=Zc,e.blending=Uc,e.colorWrite=!1,e}createShadowRenderTarget(e){let t=new Tn(e,e,{format:jc,type:Fo});return t.texture.minFilter=Dn,t.texture.magFilter=Dn,t.texture.generateMipmaps=!1,t.depthBuffer=!0,t.stencilBuffer=!1,t.depthTexture=new rd(e,e,Wc),t}resizeShadowRenderTarget(e){if(!(this.shadowRenderTarget.width===e&&this.shadowRenderTarget.height===e)&&(this.shadowRenderTarget.setSize(e,e),this.shadowRenderTarget.depthTexture)){let t=this.shadowRenderTarget.depthTexture;t.image.width=e,t.image.height=e,t.dispose(),t.needsUpdate=!0}}createShadowPlane(){let e=new We(1,1);this.shadowPlaneMaterial=new Cs,this.shadowPlane=new X(e,this.shadowPlaneMaterial),this.shadowPlane.position.set(0,0,Jp),this.shadowPlane.scale.set(Es,Es,1),this.shadowPlane.renderOrder=jb,this.shadowPlane.frustumCulled=!1,this.shadowPlane.name="ShadowPlane",this.shadowPlaneEnabled&&this.state.threeJSScene.add(this.shadowPlane)}setShadowPlaneEnabled(e){this.shadowPlaneEnabled!==e&&(this.shadowPlaneEnabled=e,this.shadowPlane&&(e?this.state.threeJSScene.add(this.shadowPlane):this.state.threeJSScene.remove(this.shadowPlane)))}isShadowPlaneEnabled(){return this.shadowPlaneEnabled}updateShadowPlanePosition(){if(!this.shadowPlane)return;this.shadowPlane.position.x=this.shadowCenter.x,this.shadowPlane.position.y=this.shadowCenter.y;let e=this.getShadowFootprintHalfExtent();this.shadowPlane.scale.set(e*2,e*2,1),this.shadowPlane.updateMatrix(),this.shadowPlane.updateMatrixWorld()}getShadowFootprintHalfExtent(){let e=this.internal.sunDirection;if(-e.z<Zb)return Es/2;let t=this.lightCamera,r=0;for(let n=0;n<4;n++){let i=this.scratchCorner.set(n&1?t.right:t.left,n&2?t.top:t.bottom,-t.near).applyMatrix4(t.matrixWorld),s=(Jp-i.z)/e.z,a=i.x+e.x*s-this.shadowCenter.x,l=i.y+e.y*s-this.shadowCenter.y;r=Math.max(r,Math.abs(a),Math.abs(l))}return Math.min(r,Es/2)}updateShadowPlaneVisibility(){this.shadowPlane&&(this.shadowPlane.visible=this.visibleAtCurrentZoom)}setDebugEnabled(e){this.debugEnabled!==e&&(this.debugEnabled=e,e?this.createDebugHelpers():this.disposeDebugHelpers())}isDebugEnabled(){return this.debugEnabled}createDebugHelpers(){this.debugEnabled=!0,!this.lightCameraHelper&&this.lightCamera&&(this.lightCameraHelper=new dd(this.lightCamera),this.lightCameraHelper.name="ShadowLightCameraHelper",this.state.threeJSScene.add(this.lightCameraHelper)),this.createDebugGrid(),this.createDebugCurrentCell(),this.createDebugCanvas()}createDebugGrid(){if(this.debugGrid)return;let e=this.internal.snapGridSize,t=uv,r=e*t*2,n=[];for(let a=-t;a<=t;a++){let l=a*e;n.push(l,-r/2,Ds),n.push(l,r/2,Ds)}for(let a=-t;a<=t;a++){let l=a*e;n.push(-r/2,l,Ds),n.push(r/2,l,Ds)}let i=new jt;i.setAttribute("position",new At(n,3));let s=new zr({color:hv,transparent:!0,opacity:pv,depthTest:!1});this.debugGrid=new Xt(i,s),this.debugGrid.name="ShadowDebugGrid",this.debugGrid.renderOrder=mv,this.debugGrid.frustumCulled=!1,this.state.threeJSScene.add(this.debugGrid)}createDebugCurrentCell(){if(this.debugCurrentCell)return;let e=this.internal.snapGridSize,t=new We(e,e);this.debugCurrentCellMaterial=new Be({color:fv,transparent:!0,opacity:gv,depthTest:!1,side:2}),this.debugCurrentCell=new X(t,this.debugCurrentCellMaterial),this.debugCurrentCell.name="ShadowDebugCurrentCell",this.debugCurrentCell.renderOrder=yv,this.debugCurrentCell.frustumCulled=!1,this.debugCurrentCell.position.set(this.currentSnapX+e/2,this.currentSnapY+e/2,rm),this.state.threeJSScene.add(this.debugCurrentCell)}createDebugCanvas(){if(this.debugCanvas)return;this.debugCanvas=document.createElement("canvas"),this.debugCanvas.width=Te,this.debugCanvas.height=Te,this.debugCanvas.style.cssText=`
1174
- position: fixed;
1175
- bottom: 16px;
1176
- transform: rotate(-270deg);
1177
- left: 16px;
1178
- width: ${Te}px;
1179
- height: ${Te}px;
1180
- border: 2px solid #00ffff;
1181
- border-radius: 4px;
1182
- background: #000;
1183
- z-index: 9999;
1184
- pointer-events: none;
1185
- `;let e=document.createElement("div");if(e.textContent=$l?"Shadow Depth Map":"Light Camera View",e.style.cssText=`
1186
- position: fixed;
1187
- bottom: ${Te+20}px;
1188
- left: 16px;
1189
- color: #00ffff;
1190
- font-family: monospace;
1191
- font-size: 12px;
1192
- z-index: 9999;
1193
- pointer-events: none;
1194
- `,e.id="shadow-debug-label",document.body.appendChild(this.debugCanvas),document.body.appendChild(e),this.debugCanvasCtx=Lo(this.debugCanvas),this.debugRenderTarget=new Tn(Te,Te),this.debugRenderTarget.texture.minFilter=Dn,this.debugRenderTarget.texture.magFilter=Dn,$l){this.debugDepthMaterial=new lt({uniforms:{depthTexture:{value:this.shadowRenderTarget.depthTexture}},vertexShader:`
1195
- varying vec2 vUv;
1196
- void main() {
1197
- vUv = uv;
1198
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1199
- }
1200
- `,fragmentShader:`
1201
- uniform sampler2D depthTexture;
1202
- varying vec2 vUv;
1203
- void main() {
1204
- float depth = texture2D(depthTexture, vUv).r;
1205
- // Invert so near is bright, far is dark
1206
- gl_FragColor = vec4(vec3(1.0 - depth), 1.0);
1207
- }
1208
- `});let t=new We(2,2);this.debugDepthQuad=new X(t,this.debugDepthMaterial),this.debugDepthScene=new Rt,this.debugDepthScene.add(this.debugDepthQuad),this.debugDepthCamera=new ya(-1,1,1,-1,0,1)}}debugPixelBuffer=null;updateDebugCanvas(){if(!this.debugCanvas||!this.debugCanvasCtx||!this.rendererService.renderer||!this.debugRenderTarget)return;let e=this.rendererService.renderer,t=Te*Te*4;(!this.debugPixelBuffer||this.debugPixelBuffer.length!==t)&&(this.debugPixelBuffer=new Uint8Array(t)),$l&&this.debugDepthScene&&this.debugDepthCamera&&this.debugDepthMaterial?(this.debugDepthMaterial.uniforms.depthTexture.value=this.shadowRenderTarget.depthTexture,e.setRenderTarget(this.debugRenderTarget),e.clear(),e.render(this.debugDepthScene,this.debugDepthCamera),e.setRenderTarget(null)):(e.setRenderTarget(this.debugRenderTarget),e.setClearColor(bv,1),e.clear(),e.render(this.state.threeJSScene,this.lightCamera),e.setRenderTarget(null)),e.readRenderTargetPixels(this.debugRenderTarget,0,0,Te,Te,this.debugPixelBuffer);let r=this.debugCanvasCtx.createImageData(Te,Te),n=r.data,i,s;for(let a=0;a<Te;a++)for(let l=0;l<Te;l++)i=((Te-1-a)*Te+l)*4,s=(a*Te+l)*4,n[s]=this.debugPixelBuffer[i],n[s+1]=this.debugPixelBuffer[i+1],n[s+2]=this.debugPixelBuffer[i+2],n[s+3]=255;this.debugCanvasCtx.putImageData(r,0,0)}disposeDebugHelpers(){this.lightCameraHelper&&(this.state.threeJSScene.remove(this.lightCameraHelper),this.lightCameraHelper.dispose(),this.lightCameraHelper=null),this.debugGrid&&(this.state.threeJSScene.remove(this.debugGrid),this.debugGrid.geometry.dispose(),this.debugGrid.material.dispose(),this.debugGrid=null),this.debugCurrentCell&&(this.state.threeJSScene.remove(this.debugCurrentCell),this.debugCurrentCell.geometry.dispose(),this.debugCurrentCell=null),this.debugCurrentCellMaterial&&(this.debugCurrentCellMaterial.dispose(),this.debugCurrentCellMaterial=null),this.debugCanvas&&(this.debugCanvas.remove(),this.debugCanvas=null,this.debugCanvasCtx=null),this.debugPixelBuffer=null,this.debugRenderTarget&&(this.debugRenderTarget.dispose(),this.debugRenderTarget=null),this.debugDepthQuad&&(this.debugDepthQuad.geometry.dispose(),this.debugDepthQuad=null),this.debugDepthMaterial&&(this.debugDepthMaterial.dispose(),this.debugDepthMaterial=null),this.debugDepthScene=null,this.debugDepthCamera=null;let e=document.getElementById("shadow-debug-label");e&&e.remove()}updateDebugHelpers(){if(this.debugEnabled&&(this.lightCameraHelper&&this.lightCameraHelper.update(),this.debugGrid&&this.debugGrid.position.set(this.currentSnapX,this.currentSnapY,0),this.debugCurrentCell)){let e=this.internal.snapGridSize;this.debugCurrentCell.position.set(this.currentSnapX+e/2,this.currentSnapY+e/2,rm)}}updateSunDirection(){let e=this.internal.sunAzimuth*Math.PI/180,t=this.internal.sunElevation*Math.PI/180,r=Math.cos(t);this.internal.sunDirection.set(r*Math.sin(e),r*Math.cos(e),-Math.sin(t)),this.internal.sunDirection.normalize()}updateLightCamera(){this.lightCamera&&(this.lightCamera.left=-this.internal.lightOrthoSize,this.lightCamera.right=this.internal.lightOrthoSize,this.lightCamera.top=this.internal.lightOrthoSize,this.lightCamera.bottom=-this.internal.lightOrthoSize,this.lightCamera.updateProjectionMatrix())}bias=new K().set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);matrix=new K;updateLightMatrix(){this.lightCamera.position.copy(this.shadowCenter).add(this.scratchVector.copy(this.internal.sunDirection).multiplyScalar(-this.internal.sunDistance)),this.lightCamera.lookAt(this.shadowCenter);let e=Qp,t=this.internal.sunDistance*2,r=e,n=t;if(!this.casterBounds.isEmpty()){let[i,s]=this.getCasterDepthRange();r=Math.min(r,i-em),n=Math.max(n,s+em)}this.lightCamera.near=r,this.lightCamera.far=n,this.depthScale=(t-e)/(n-r),this.lightCamera.left=-this.internal.lightOrthoSize,this.lightCamera.right=this.internal.lightOrthoSize,this.lightCamera.top=this.internal.lightOrthoSize,this.lightCamera.bottom=-this.internal.lightOrthoSize,this.lightCamera.updateMatrixWorld(!0),this.lightCamera.updateProjectionMatrix(),this.matrix.identity(),this.matrix.multiplyMatrices(this.lightCamera.projectionMatrix,this.lightCamera.matrixWorldInverse),this.lightMatrix.multiplyMatrices(this.bias,this.matrix)}getCasterDepthRange(){let{min:e,max:t}=this.casterBounds,r=this.internal.sunDirection,n=this.lightCamera.position,i=1/0,s=-1/0;for(let a=0;a<8;a++){let l=(a&1?t.x:e.x)-n.x,c=(a&2?t.y:e.y)-n.y,d=(a&4?t.z:e.z)-n.z,u=l*r.x+c*r.y+d*r.z;u<i&&(i=u),u>s&&(s=u)}return[i,s]}castersChanged(){this.castersDirty=!0,this.needsRender=!0}measureCasterBounds(){let e=this.casterBounds.makeEmpty(),t=this.lightCamera.layers,r=this.scratchBox;this.state.threeJSScene.updateMatrixWorld(),this.state.threeJSScene.traverseVisible(n=>{let i=n;if(!(!i.isMesh||!i.layers.test(t))){if(i.computeBoundingBox)i.computeBoundingBox(),r.copy(i.boundingBox);else{let s=i.geometry;s.boundingBox||s.computeBoundingBox(),r.copy(s.boundingBox)}r.isEmpty()||e.union(r.applyMatrix4(i.matrixWorld))}})}updateAutoSunDistance(e){let t=Math.max(an,Math.min(Gt,e)),r=(Gt-t)/(Gt-an),n=ov*Math.pow(iv,r);Math.abs(this.internal.sunDistance-n)>Yl&&(this.internal.sunDistance=n,this.updateSunDirection(),this.needsRender=!0)}updateAutoShadowResolution(e){if(this.options.shadowMapSize!=="auto")return;let t=this.internal.currentShadowResolutionMode;if(this.internal.currentShadowResolutionMode===null?e>=this.shadowResolutionZoomThresholds.high?t="high":t="low":this.internal.currentShadowResolutionMode==="low"?e>=this.shadowResolutionZoomThresholds.high&&(t="high"):this.internal.currentShadowResolutionMode==="high"&&e<=this.shadowResolutionZoomThresholds.low&&(t="low"),t!==this.internal.currentShadowResolutionMode&&t!==null){let r=this.shadowResolutionSizes[t];this.internal.currentShadowResolutionMode=t,this.internal.currentShadowMapSize=r,this.resizeShadowRenderTarget(r),this.needsRender=!0}}updateAutoLightSize(e){let t=Math.max(an,Math.min(Gt,e)),r=(Gt-t)/(Gt-an),n=sv*Math.pow(av,r);Math.abs(this.internal.lightOrthoSize-n)>Yl&&(this.internal.lightOrthoSize=n,this.updateLightCamera(),this.needsRender=!0)}updateZoomVisibility(e){let t=this.options.visibleAtZoomLevel-tm,r=this.options.visibleAtZoomLevel,n;e>=r?n=1:e<=t?n=0:n=(e-t)/tm;let i=n>0;(i!==this.visibleAtCurrentZoom||n!==this.zoomOpacityFactor)&&(this.visibleAtCurrentZoom=i,this.zoomOpacityFactor=n,this.uniformsDirty=!0)}isVisibleAtCurrentZoom(){return this.visibleAtCurrentZoom}updateAutoSnapGridSize(e){let t=Math.max(an,Math.min(Gt,e)),r=(Gt-t)/(Gt-an),n=lv*Math.pow(cv,r);Math.abs(this.internal.snapGridSize-n)>Yl&&(this.internal.snapGridSize=n,this.debugEnabled&&this.recreateDebugGrid())}recreateDebugGrid(){this.debugGrid&&(this.state.threeJSScene.remove(this.debugGrid),this.debugGrid.geometry.dispose(),this.debugGrid.material.dispose(),this.debugGrid=null),this.debugCurrentCell&&(this.state.threeJSScene.remove(this.debugCurrentCell),this.debugCurrentCell.geometry.dispose(),this.debugCurrentCell=null),this.createDebugGrid(),this.createDebugCurrentCell()}transparentGeometryVisibilityStateMap=new Map;renderShadowMap(){let e=this.state.threeJSScene.overrideMaterial;this.state.threeJSScene.overrideMaterial=this.depthMaterial,this.rendererService.renderer?.setRenderTarget(this.shadowRenderTarget),this.rendererService.clear(),this.rendererService.renderScene(this.state.threeJSScene,this.lightCamera),this.rendererService.renderer?.setRenderTarget(null),this.state.threeJSScene.overrideMaterial=e,this.debugEnabled&&this.updateDebugCanvas()}get effectiveShadowBias(){if(typeof this.options.shadowBias=="number")return this.options.shadowBias*this.depthScale;let e=this.internal.currentShadowMapSize,t=this.internal.lightOrthoSize,r=this.lightCamera.far-this.lightCamera.near;if(!(e>0)||!(t>0)||!(r>0))return Kp;let n=qb*(2*t)/e/r;return Number.isFinite(n)&&n>0?n:Kp}get effectiveNormalBias(){let e=2*this.internal.lightOrthoSize/this.internal.currentShadowMapSize,t=Jb*e;return Number.isFinite(t)&&t>0?Math.max(this.options.normalBias,t):this.options.normalBias}updateShadowUniforms(){let e=this.visibleAtCurrentZoom,t=this.options.shadowOpacity*this.zoomOpacityFactor,r=this.effectiveShadowBias,n=this.uniformMaterialsSeen;n.clear();let i;for(let s of this.state.geometry3DsInScene){i=s.components[0];let a=i?.mesh?.material;a instanceof ei&&!n.has(a)&&(n.add(a),a.setShadowUniforms(this.shadowRenderTarget.depthTexture,this.lightMatrix,this.lightCamera.near,this.lightCamera.far,r,t,this.internal.baseColor,this.internal.currentShadowMapSize,this.options.pcfSpread,this.options.pcfSamples,this.internal.sunDirection,this.effectiveNormalBias,this.state.depthRangeFor3D[1],e,pd*this.depthScale))}this.shadowPlaneMaterial&&this.shadowPlaneMaterial.setShadowUniforms(this.shadowRenderTarget.depthTexture,this.lightMatrix,r,t,this.internal.baseColor,this.internal.currentShadowMapSize,this.options.pcfSpread,this.options.pcfSamples,this.state.depthRangeFor3D[1],e)}lastZoomLevel=null;lastCameraElevation=null;zoomOrElevationChanged(e,t){if(this.lastZoomLevel===null||this.lastCameraElevation===null)return this.lastZoomLevel=e,this.lastCameraElevation=t,!0;let r=Math.abs(e-this.lastZoomLevel)>=dv,n=t!==this.lastCameraElevation;return r||n?(this.lastZoomLevel=e,this.lastCameraElevation=t,!0):!1}updateSnap(e){let t=this.cameraOrbit.position.x||0,r=this.cameraOrbit.position.y||0,n=Math.floor(t/this.internal.snapGridSize)*this.internal.snapGridSize,i=Math.floor(r/this.internal.snapGridSize)*this.internal.snapGridSize,s=(e||0)+this.internal.groundZPosition;(n!==this.currentSnapX||i!==this.currentSnapY||s!==this.shadowCenter.z)&&(this.currentSnapX=n,this.currentSnapY=i,this.shadowCenter.set(n,i,s),this.needsRender=!0)}needsRender=!0;needsCompute=!0;update(e,t){this.updateZoomVisibility(e);let r=this.zoomOrElevationChanged(e,t);(this.needsCompute||r)&&(this.updateAutoShadowResolution(e),this.updateAutoLightSize(e),this.updateAutoSunDistance(e),this.updateAutoSnapGridSize(e)),this.updateSnap(t),this.needsRender&&(this.castersDirty&&(this.measureCasterBounds(),this.castersDirty=!1),this.updateLightMatrix(),this.updateShadowPlanePosition(),this.shadowMapStale=!0,this.uniformsDirty=!0),this.shadowMapStale&&this.visibleAtCurrentZoom&&(this.renderShadowMap(),this.shadowMapStale=!1),this.uniformsDirty&&(this.updateShadowUniforms(),this.updateShadowPlaneVisibility()),this.updateDebugHelpers(),this.needsRender=!1,this.needsCompute=!1,this.uniformsDirty=!1}destroy(){this.disposeDebugHelpers(),this.shadowPlane&&(this.state.threeJSScene.remove(this.shadowPlane),this.shadowPlane.geometry.dispose(),this.shadowPlane=null),this.shadowPlaneMaterial&&(this.shadowPlaneMaterial.dispose(),this.shadowPlaneMaterial=null),this.shadowRenderTarget&&(this.shadowRenderTarget.dispose(),this.shadowRenderTarget.depthTexture&&this.shadowRenderTarget.depthTexture.dispose()),this.depthMaterial&&this.depthMaterial.dispose(),this.transparentGeometryVisibilityStateMap.clear()}};y();y();var vv=[100,500,2e3,1e4];function oo(o,e){return o.set(W.degToRad(e?.[0]??Kt[0]),W.degToRad(e?.[1]??Kt[1]),W.degToRad(e?.[2]??Kt[2]))}function io(o,e){return o.set(e?.[0]??Jt[0],e?.[1]??Jt[1],e?.[2]??Jt[2])}function so(o){let e=o.components[0],t=o.components[1];if(t.opacity!=null&&t.opacity!==e.opacity&&(e.opacity=t.opacity),!(e.mesh?.children[0]instanceof re)){let s=t.material,a=t.color;if(s||a){let l=nm(a,s);e.mesh?.traverse(c=>{c instanceof X&&c.material&&(Array.isArray(c.material)?c.material.forEach(d=>{l[d.name]?(d.color.set(l[d.name].color),d.vertexColors=!1):a&&d.color.set(a)}):l[c.material.name]?(c.material.color.set(l[c.material.name].color),c.material.vertexColors=!1):a&&c.material.color.set(a))})}}let n=e.feature.geometry.coordinates[2]??0,i=(t.verticalOffset??0)+n;e.altitude!==i&&(e.altitude=i),t.visible!==e.visible&&(e.visible=t.visible),t.visibleThroughGeometry!==e.visibleThroughGeometry&&(e.visibleThroughGeometry=t.visibleThroughGeometry)}function nm(o,e){let t={};if(e)for(let r in e)e[r].color&&(t[r]={color:e[r].color});if(o){let r=["Default","Fabric","Mpdn_Logo","CouchLogo"];for(let n of r)t[n]||(t[n]={color:o})}return t}function Is(o){o.traverse(e=>{e instanceof re&&e.computeBoundingSphere()})}function om(o,e,t){let r=t.elements;for(let n=0;n<16;n++)if(o[e+n]!==Math.fround(r[n]))return!0;return!1}function im(o,e=vv){for(let t of e)if(t>o)return t;return o*2}function ql(o){for(;o.children.length>0;){let e=o.children[0];if(e instanceof re)if(e.geometry?.dispose(),Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material&&e.material.dispose();o.remove(e)}}function Os(o){ql(o),o.parent?.remove(o)}function Ls(o,e,t,r){let n=r||t?nm(t,r):void 0;for(let i of o.children){if(!(i instanceof re))continue;let s=Array.isArray(i.material)?i.material[0]?.name:i.material?.name,a=n?.[s],l=a?new z(a.color):t?new z(t):i.userData.originalColor;l&&(i.setColorAt(e,l),i.instanceColor&&(i.instanceColor.needsUpdate=!0))}}function ln(o,e){let t=new nt;return o.scene.updateWorldMatrix(!0,!0),o.scene.traverse(r=>{let n=r;if("isMesh"in n&&n.isMesh===!0){let i=n.geometry.clone();i.applyMatrix4(n.matrixWorld);let s=n.material,a;Array.isArray(s)?(a=s[0].color?.clone(),s=s.map(d=>{let u=d.clone();return u.color?.setRGB(1,1,1),u})):(a=s.color?.clone(),s=s.clone(),s.color?.setRGB(1,1,1));let l=new re(i,s,e);l.count=0,l.frustumCulled=!1,l.layers.enable(Ve.SHOULD_CAST_SHADOWS),l.userData={entities:{},originalColor:a},t.add(l)}}),t}function Jl(o,e){let t=typeof e=="string"?new z(e):e;o.traverse(r=>{let n=r;"isMesh"in n&&n.isMesh===!0&&(Array.isArray(n.material)?n.material.forEach(i=>{"color"in i&&i.color.copy(t)}):"color"in n.material&&n.material.color.copy(t))})}function Ps(o,e,t=!1){o.userData.intrinsicOpacity==null&&(o.userData.intrinsicOpacity=o.opacity);let r=o.userData.intrinsicOpacity*e;(!t||!o.transparent)&&(o.transparent=r<1),o.opacity=r}function Kl(o,e,t=!1){o.traverse(r=>{let n=r;if("isMesh"in n&&n.isMesh===!0)if(Array.isArray(n.material))for(let i of n.material)Ps(i,e,t);else Ps(n.material,e,t)})}function sm(o,e){o.traverse(t=>{let r=t;"isMesh"in r&&r.isMesh===!0&&(Array.isArray(r.material)?r.material.forEach(n=>{n.depthWrite=!e,n.depthTest=!e,e&&(n.transparent=!0)}):(r.material.depthWrite=!e,r.material.depthTest=!e,e&&(r.material.transparent=!0)))})}function cn(o,e){o.traverse(t=>{if(t instanceof re&&t.material)if(Array.isArray(t.material))for(let r of t.material)Ps(r,e);else Ps(t.material,e)})}function Ql(o){o.traverse(e=>{let t=e;"isMesh"in t&&t.isMesh===!0&&(t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(r=>r.dispose()):t.material?.dispose())})}function am(o){o.traverse(e=>{e instanceof re&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material?.dispose())})}function sr(o,e){let t=e!==0,r=!1;return o.traverse(n=>{if(!(n instanceof re)&&!("isMesh"in n&&n.isMesh))return;let i=n.layers.isEnabled(Ve.SHOULD_CAST_SHADOWS);t&&!i?(n.layers.enable(Ve.SHOULD_CAST_SHADOWS),r=!0):!t&&i&&(n.layers.disable(Ve.SHOULD_CAST_SHADOWS),r=!0)}),r}y();var As=class{element=null;enabled=!1;show(){this.enabled||(this.enabled=!0,this.create())}hide(){this.enabled&&(this.enabled=!1,this.element&&(this.element.remove(),this.element=null))}isEnabled(){return this.enabled}create(){this.element=document.createElement("div"),this.element.id="model-debug-ui",this.element.style.cssText=`
1209
- position: fixed;
1210
- bottom: 10px;
1211
- left: 10px;
1212
- background: rgba(0, 0, 0, 0.8);
1213
- color: #fff;
1214
- font-family: monospace;
1215
- font-size: 12px;
1216
- padding: 10px;
1217
- border-radius: 5px;
1218
- z-index: 10000;
1219
- max-height: 300px;
1220
- overflow-y: auto;
1221
- min-width: 200px;
1222
- `,document.body.appendChild(this.element)}getActualInstanceCount(e){for(let t of e.mesh.children)if(t.isInstancedMesh)return t.count;return e.count}update(e,t,r){if(!this.enabled||!this.element)return;let n='<div style="margin-bottom: 5px; font-weight: bold; border-bottom: 1px solid #666; padding-bottom: 5px;">Model Batches</div>';if(e.size===0)n+='<div style="color: #888;">No models loaded</div>';else{let i=0,s=0,a=Array.from(e.keys()).sort((l,c)=>{let d=t.get(l)??"",u=t.get(c)??"";return d.localeCompare(u)});for(let l of a){let c=e.get(l);if(!c||c.size===0)continue;let d=t.get(l)??`unknown_${l}`,u=0;for(let v of c)u+=this.getActualInstanceCount(v);i+=c.size,s+=u,n+='<div style="margin: 6px 0 2px 0;">',n+=`<span style="color: #4fc3f7; font-weight: bold;">"${d}"</span>`,n+=`<span style="color: #aaa;"> (${u} total, ${c.size} batch${c.size!==1?"es":""})</span>`,n+="</div>";let h=Array.from(c).sort((v,f)=>v.id.localeCompare(f.id));for(let v of h){let f=this.getActualInstanceCount(v),M=v.count,p=f!==M,m=v.opacity===1?"":` @${(v.opacity*100).toFixed(0)}%`;n+='<div style="margin-left: 12px; color: #ccc; font-size: 11px;">',n+=`<span style="color: #81c784;">${v.id}</span>`,p?n+=`<span style="color: #e57373;">: ${f} actual / ${M} tracked</span>`:n+=`<span style="color: #fff;">: ${f} instance${f!==1?"s":""}</span>`,m&&(n+=`<span style="color: #ffb74d;">${m}</span>`),n+="</div>"}}n+='<div style="margin-top: 8px; padding-top: 5px; border-top: 1px solid #666; color: #fff;">',n+=`Total: <span style="color: #81c784;">${s} instance${s!==1?"s":""}</span>`,n+=`, <span style="color: #e57373;">${i} draw call${i!==1?"s":""}</span>`,n+="</div>"}if(r.size>0){n+='<div style="margin-top: 8px; border-top: 1px solid #666; padding-top: 5px;">',n+='<div style="margin-bottom: 5px; font-weight: bold; color: #ff9800;">Non-instanced Models</div>',n+=`<span style="color: #aaa;">(${r.size} total, ${r.size} draw call${r.size!==1?"s":""})</span>`;let i=new Map;for(let[s,a]of r){let l=i.get(a.urlHash)??[];l.push(s),i.set(a.urlHash,l)}for(let[s,a]of i){let l=t.get(s)??`unknown_${s}`;n+='<div style="margin: 6px 0 2px 0;">',n+=`<span style="color: #ff9800;">"${l}"</span>`,n+=`<span style="color: #aaa;"> (${a.length} model${a.length!==1?"s":""})</span>`,n+="</div>";for(let c of a)n+=`<div style="margin-left: 12px; color: #ccc; font-size: 11px;">${c}</div>`}n+="</div>"}this.element.innerHTML=n}destroy(){this.element&&(this.element.remove(),this.element=null)}};var dn=100,xv=!0,Rs=class extends q{transparencyChanged=!1;state;convertTo3DMapPosition;loader;loadPromises=[];gltfCache=new Map;gltfLoadPromises=new Map;instanceMap=new Map;debugUI;modelNames=new Map;batchCounter=0;batchByMesh=new Map;batchesByUrlHash=new Map;nonInstancedModels=new Map;pendingOpacityChanges=new Map;detachedEntityIds=new Set;tempMatrix=new K;tempQuaternion=new kr;tempEuler=new Lt;tempScale=new O;tempColor=new z;constructor(e,t){super(),this.state=e,this.convertTo3DMapPosition=t,this.debugUI=new As}createBatch(e,t,r,n,i){this.batchCounter++;let s={id:`batch_${this.batchCounter}`,mesh:e,count:0,maxCount:i,opacity:n,urlHash:t,containerId:r};return e.userData.batchId=s.id,this.batchByMesh.set(e,s),this.batchesByUrlHash.has(t)||this.batchesByUrlHash.set(t,new Set),this.batchesByUrlHash.get(t).add(s),s}removeBatch(e){this.batchByMesh.delete(e.mesh),this.batchesByUrlHash.get(e.urlHash)?.delete(e),this.batchesByUrlHash.get(e.urlHash)?.size===0&&this.batchesByUrlHash.delete(e.urlHash)}getBatchForMesh(e){return this.batchByMesh.get(e)}updateDebugUI(){this.debugUI.update(this.batchesByUrlHash,this.modelNames,this.nonInstancedModels)}showDebug(){this.debugUI.show(),this.updateDebugUI()}hideDebug(){this.debugUI.hide()}getBatchStats(){let e=new Map;for(let[t,r]of this.batchesByUrlHash)for(let n of r){let i=e.get(t);i?(i.count+=n.count,i.maxCount+=n.maxCount):e.set(t,{urlHash:t,count:n.count,maxCount:n.maxCount,opacity:n.opacity})}return e}getNonInstancedModels(){let e=new Map;for(let[t,r]of this.nonInstancedModels)e.set(t,{urlHash:r.urlHash});return e}getModelUrls(){return new Map(this.modelNames)}async getGLTFLoader(){if(this.loader)return this.loader;let{GLTFLoader:e}=await import("./GLTFLoader-4HJWTRLM.js");return this.loader=new e,this.loader}async getOrLoadGLTF(e,t){let r=this.gltfCache.get(t);if(r)return r;let n=this.gltfLoadPromises.get(t);if(n)return n;let i=await this.getGLTFLoader(),s=new Promise((a,l)=>{let c=u=>{this.gltfCache.set(t,u),this.gltfLoadPromises.delete(t),a(u)},d=u=>{this.gltfLoadPromises.delete(t),l(u)};Xd(e)?i.parse(Yd(e),"",c,d):$d(e)?i.parse(qd(e),"",c,d):i.load(e,c,void 0,d)});return this.gltfLoadPromises.set(t,s),s}createNonInstancedModel(e,t,r,n){let i=e.components[0],s=e.components[1],a=i.feature,l=t.scene.clone(!0);l.updateWorldMatrix(!0,!0);let c=new nt;c.userData={nonInstanced:!0,entityId:String(e.id),type:"model"},l.traverse(p=>{let m=p;if("isMesh"in m&&m.isMesh===!0){let g=m.clone(!1);g.geometry=m.geometry.clone(),g.geometry.applyMatrix4(m.matrixWorld),g.position.set(0,0,0),g.rotation.set(0,0,0),g.scale.set(1,1,1),Array.isArray(m.material)?g.material=m.material.map(b=>b.clone()):g.material=m.material.clone(),g.userData={entityId:String(e.id)},c.add(g)}});let{x:d,y:u}=this.convertTo3DMapPosition(a.geometry.coordinates[1],a.geometry.coordinates[0],0),h=a.geometry.coordinates[2]??0,v=(s.verticalOffset??0)+h;i.altitude=v,i.position.set(d,u,i.altitude);let f=s.scale??Jt,M=s.rotation??Kt;if(c.position.copy(i.position),c.rotation.set(W.degToRad(M[0]),W.degToRad(M[1]),W.degToRad(M[2])),c.scale.set(f[0],f[1],f[2]),s.color&&Jl(c,s.color),s.opacity!=null&&s.opacity!==1&&Kl(c,s.opacity),s.visibleThroughGeometry&&sm(c,!0),!s.EXPERIMENTAL_clippingEnabled){let p=s.opacity??1;sr(c,p)}r.add(c),i.mesh=c,i.meshContainer=c,i.instanceIndex=-1,so(e),this.nonInstancedModels.set(e.id,{urlHash:n,mesh:c}),this.updateDebugUI()}resizeInstanceContainer(e,t){let r=im(e.maxCount),n=e.object,i=ln(t,r),s=n.children,a=i.children;for(let c=0;c<s.length;c++){let d=s[c],u=a[c];if(!(!(d instanceof re)||!(u instanceof re))){for(let h=0;h<e.count;h++)d.getMatrixAt(h,this.tempMatrix),u.setMatrixAt(h,this.tempMatrix),u.userData.entities[h]=d.userData.entities[h],d.instanceColor&&(d.getColorAt(h,this.tempColor),u.setColorAt(h,this.tempColor));u.count=e.count,u.instanceMatrix.needsUpdate=!0}}for(ql(n);i.children.length>0;)n.add(i.children[0]);e.maxCount=r;let l=this.getBatchForMesh(n);return l&&(l.maxCount=r),e}getOrCreateInstanceContainer(e,t,r){let n=this.instanceMap.get(e);n||(n=new Map,this.instanceMap.set(e,n));let i=n.get(t);if(i){let s=this.getBatchForMesh(i.object);s&&(i.count=s.count)}else{let s=ln(r,dn);i={object:s,count:0,maxCount:dn},n.set(t,i);let a=this.createBatch(s,t,e,1,dn);i.batch=a}return i}createModelFromFeature(e,t,r){let n=new Dr(t),i={...r};t.properties.verticalOffset!=null&&(i.verticalOffset=t.properties.verticalOffset),t.properties.rotation!=null&&(i.rotation=t.properties.rotation),t.properties.scale!=null&&(i.scale=t.properties.scale);let s=new Ko(i);n.instancingDisabled=s.visibleThroughGeometry===!0||s.EXPERIMENTAL_clippingEnabled===!0;let a=new Q(n,s);return a.id=e,s.EXPERIMENTAL_clippingEnabled&&(a.components[7]=new ti),a}async populateModelGroup(e,t,r){let n=wn(t);this.modelNames.set(n,t);let i=this.getOrLoadGLTF(t,n).then(l=>{let c=r.parent;if(!(c instanceof he))return;let d=c.userData.entityId,u=this.getOrCreateInstanceContainer(d,n,l);u.count+e.size>u.maxCount&&(u=this.resizeInstanceContainer(u,l)),u.object.parent||r.add(u.object);let v=new K,f=new Lt,M=new kr,p=new O,m,g,b;for(let x of e.values()){if(b=this.state.geometry3DMap.get(x),!b||b?.type!=="model")continue;let S=b.components[0],C=b.components[1];if(S.instanceIndex!=null&&S.instanceIndex>=0||S.instancingDisabled&&S.mesh)continue;if(g=S.feature,S.instancingDisabled){this.createNonInstancedModel(b,l,r,n);continue}let D=C.opacity!=null&&C.opacity!==1;if(D){let T=C.opacity??1,I=Math.round(T*100),L,A,F=this.batchesByUrlHash.get(n);if(F){for(let _ of F)if(_.containerId===c.userData.entityId&&Math.round(_.opacity*100)===I&&_.count<_.maxCount){L=_,A=_.mesh;break}}if(!L||!A){let _=ln(l,dn);_.userData.detached=!0,_.userData.sharedOpacity=T,r.add(_),L=this.createBatch(_,n,c.userData.entityId,T,dn),A=_,cn(_,T),sr(_,T)}let k=L.count;S.mesh=A,S.instanceIndex=k,L.count++,this.detachedEntityIds.add(b.id)}else S.mesh=u.object,S.instanceIndex=u.count;so(b),C.dirty=!1,m=this.convertTo3DMapPosition(g.geometry.coordinates[1],g.geometry.coordinates[0],0),S.position.set(m.x,m.y,S.altitude),oo(f,C.rotation),io(p,C.scale),M.setFromEuler(f),v.compose(S.position,M,p);let w=S.mesh,P=S.instanceIndex;for(let T of w.children)T instanceof re&&(T.setMatrixAt(P,v),T.userData.entities[P]=b.id,T.count=P+1,T.instanceMatrix.needsUpdate=!0);if(Ls(w,P,C.color,C.material),!D){u.count++;let T=this.getBatchForMesh(u.object);T&&(T.count=u.count)}Is(S.mesh)}this.publish("model-loaded")});this.loadPromises.push(i);let s=r.parent?.userData?.entityId;return this.instanceMap.get(s)?.get(n)?.object??new nt}update(){for(let t of this.state.geometryGroupIdsToLoad.values()){let r=this.state.geometry3DMap.get(t);r instanceof Fe&&r.userData.dirty&&r.userData.modelURL&&(this.populateModelGroup(r.userData.entities3D,r.userData.modelURL,r),r.userData.dirty=!1,r.userData.localCenter=void 0)}this.updateModelStyles(),this.rebatchDetachedInstances(),this.flushPendingOpacityChanges(),this.updateDebugUI();let e=this.loadPromises;return this.loadPromises=[],Promise.all(e)}rebatchDetachedInstances(){if(!xv||this.detachedEntityIds.size===0)return;let e=new Map;for(let t of this.detachedEntityIds){let r=this.state.geometry3DMap.get(t);if(!r||r.type!=="model")continue;let n=r.components[0],i=r.components[1],s=n.mesh?.userData;if(!n.mesh?.parent)continue;let a=i.opacity??1,l=s?.sharedOpacity;if(Math.round(a*100)===100&&l!==void 0){this.pendingOpacityChanges.set(r.id,{entity:r,targetOpacity:a});continue}if(l!==void 0&&Math.abs(a-l)<=.01)continue;if(l!==void 0&&Math.abs(a-l)>.01){this.pendingOpacityChanges.set(r.id,{entity:r,targetOpacity:a});continue}let d=n.mesh.parent;if(!(d instanceof Fe))continue;let u=d.userData.modelURL;if(!u)continue;let h=wn(u),v=i.opacity??1,f=Math.round(v*100);e.has(h)||e.set(h,new Map);let M=e.get(h);M.has(f)||M.set(f,[]),M.get(f).push(r)}for(let[t,r]of e.entries()){let n=this.gltfCache.get(t);if(n)for(let[i,s]of r.entries()){if(s.length<2)continue;let a=i/100;this.createSharedBatchForDetached(s,n,a,t)}}this.publish("batch-changed")}createSharedBatchForDetached(e,t,r,n){if(e.length<2)return;let s=e[0].components[0].mesh?.parent;if(!s)return;let a=s.parent,l=a instanceof he?a.userData.entityId:"unknown",c=ln(t,e.length);c.userData.detached=!0,c.userData.sharedOpacity=r,s.add(c);let d=this.createBatch(c,n,l,r,e.length);cn(c,r),sr(c,r);let u=new K,h=new Lt,v=new kr,f=new O,M,p,m=0;for(let g of e){let b=g.components[0],x=g.components[1],S=b.mesh;if(S){let C=this.getBatchForMesh(S);C&&this.removeBatch(C),Os(S)}b.mesh=c,b.instanceIndex=m,p=b.feature,M=this.convertTo3DMapPosition(p.geometry.coordinates[1],p.geometry.coordinates[0],0),b.position.set(M.x,M.y,b.altitude),oo(h,x.rotation),io(f,x.scale),x.visible===!1&&f.set(0,0,0),v.setFromEuler(h),u.compose(b.position,v,f);for(let C of c.children)C instanceof re&&(C.setMatrixAt(m,u),C.userData.entities[m]=g.id,C.count=m+1,C.instanceMatrix.needsUpdate=!0);Ls(c,m,x.color,x.material),m++}d.count=m,Is(c)}removeInstanceFromBatch(e,t,r){let n=e.count-1,i=e.opacity===1&&t.userData?.detached!==!0;if(e.count===1){if(i){e.count=0;for(let d of t.children)d instanceof re&&(d.count=0,d.instanceMatrix.needsUpdate=!0);let c=this.instanceMap.get(e.containerId)?.get(e.urlHash);c&&c.object===e.mesh&&(c.count=0),this.updateDebugUI();return}this.removeBatch(e),Os(t),this.updateDebugUI();return}for(let l of t.children)if(l instanceof re){if(r!==n){l.getMatrixAt(n,this.tempMatrix),l.getColorAt(n,this.tempColor),l.setMatrixAt(r,this.tempMatrix),l.setColorAt(r,this.tempColor);let c=l.userData.entities[n];if(c){l.userData.entities[r]=c;let d=this.state.geometry3DMap.get(c);d&&(d.components[0].instanceIndex=r)}}delete l.userData.entities[n],l.count=n,l.instanceMatrix.needsUpdate=!0,l.instanceColor&&(l.instanceColor.needsUpdate=!0)}e.count=n;let a=this.instanceMap.get(e.containerId)?.get(e.urlHash);a&&a.object===e.mesh&&(a.count=n),this.updateDebugUI()}updateModelStyles(){for(let e of this.state.geometry3DsInScene){if(e?.type!=="model")continue;let t=e.components[1],r=e.components[0];if(!t.dirty&&!r.positionDirty)continue;if(r.instancingDisabled){this.updateNonInstancedModelStyle(e),t.dirty=!1,r.positionDirty=!1;continue}let n=r.mesh?.userData,i=n?.detached,s=t.opacity!=null&&t.opacity!==1,a=t.opacity??1,l=n?.sharedOpacity,c=l!==void 0&&Math.abs(a-l)>.01;if((s&&!i&&r.mesh||c)&&this.pendingOpacityChanges.set(e.id,{entity:e,targetOpacity:a}),so(e),this.updateInstanceTransform(e),this.updateInstanceColor(e,t.color,t.material),r.mesh?.userData?.detached&&r.mesh){let u=t.opacity??1;cn(r.mesh,u),sr(r.mesh,u)&&(this.transparencyChanged=!0)}t.dirty=!1,r.positionDirty=!1}}flushPendingOpacityChanges(){if(this.pendingOpacityChanges.size===0)return;let e=new Map,t=new Map,r=(n,i,s,a,l,c)=>{let d=Math.round(i*100),u=`${s}_${a}_${d}`,h=t.get(u);h||(h={entities:[],targetOpacity:i,urlHash:s,containerId:a,gltf:l,parent:c},t.set(u,h)),h.entities.push(n)};for(let{entity:n,targetOpacity:i}of this.pendingOpacityChanges.values()){let s=n.components[0];if(!s.mesh||s.instanceIndex==null)continue;let a=s.mesh,l=this.getBatchForMesh(a),c=a.parent;if(!(c instanceof Fe))continue;let d=c.userData.modelURL;if(!d)continue;let u=wn(d),h=this.gltfCache.get(u);if(!h)continue;let v=c.parent,f=v instanceof he?v.userData.entityId:"unknown";if(l){let M=e.get(l);M||(M={entities:[],targetOpacity:i},e.set(l,M)),Math.round(M.targetOpacity*100)===Math.round(i*100)?M.entities.push(n):r(n,i,u,f,h,c)}else r(n,i,u,f,h,c)}for(let[n,i]of e){let{entities:s,targetOpacity:a}=i,l=n.mesh.userData?.detached===!0,c=Math.round(a*100)===100;if(s.length===n.count&&l&&!c)n.opacity=a,n.mesh.userData.sharedOpacity=a,cn(n.mesh,a),sr(n.mesh,a)&&(this.transparencyChanged=!0);else{let h=s[0]?.components[0]?.mesh?.parent;if(h instanceof Fe){let v=h.userData.modelURL;if(v){let f=wn(v),M=this.gltfCache.get(f),p=h.parent,m=p instanceof he?p.userData.entityId:"unknown";if(M)for(let g of s)r(g,a,f,m,M,h)}}}}for(let n of t.values()){let{entities:i,targetOpacity:s,urlHash:a,containerId:l,gltf:c,parent:d}=n,u=Math.round(s*100);for(let m of i){let g=m.components[0],b=g.mesh,x=this.getBatchForMesh(b),S=g.instanceIndex;x&&S!=null&&S>=0&&this.removeInstanceFromBatch(x,b,S)}let h,v,f=this.batchesByUrlHash.get(a);if(f){for(let m of f)if(m.containerId===l&&Math.round(m.opacity*100)===u&&m.count+i.length<=m.maxCount){h=m,v=m.mesh;break}}if(!h||!v){let m=Math.max(dn,i.length),g=ln(c,m);g.userData.detached=!0,g.userData.sharedOpacity=s,d.add(g),h=this.createBatch(g,a,l,s,m),v=g,cn(g,s),sr(g,s)&&(this.transparencyChanged=!0)}let M,p;for(let m of i){let g=m.components[0],b=m.components[1],x=h.count;g.mesh=v,g.instanceIndex=x,p=g.feature,M=this.convertTo3DMapPosition(p.geometry.coordinates[1],p.geometry.coordinates[0],0),g.position.set(M.x,M.y,g.altitude),oo(this.tempEuler,b.rotation),io(this.tempScale,b.scale),b.visible===!1&&this.tempScale.set(0,0,0),this.tempQuaternion.setFromEuler(this.tempEuler),this.tempMatrix.compose(g.position,this.tempQuaternion,this.tempScale);for(let S of v.children)S instanceof re&&(S.setMatrixAt(x,this.tempMatrix),S.userData.entities[x]=m.id,S.count=x+1,S.instanceMatrix.needsUpdate=!0);this.updateInstanceColor(m,b.color,b.material),h.count++,v.userData.detached?this.detachedEntityIds.add(m.id):this.detachedEntityIds.delete(m.id)}Is(v),this.publish("batch-changed")}this.pendingOpacityChanges.clear(),this.updateDebugUI()}updateInstanceTransform(e){let t=e.components[0],r=e.components[1];if(!t.mesh)return;let n=t.feature,{x:i,y:s}=this.convertTo3DMapPosition(n.geometry.coordinates[1],n.geometry.coordinates[0],0);if(t.position.set(i,s,t.altitude),oo(this.tempEuler,r.rotation),r.visible===!1?this.tempScale.set(0,0,0):io(this.tempScale,r.scale),t.instancingDisabled){let a=t.meshContainer??t.mesh;a.position.copy(t.position),a.rotation.set(this.tempEuler.x,this.tempEuler.y,this.tempEuler.z),a.scale.copy(this.tempScale);return}if(!(t.instanceIndex==null||t.instanceIndex<0)){this.tempQuaternion.setFromEuler(this.tempEuler),this.tempMatrix.compose(t.position,this.tempQuaternion,this.tempScale);for(let a of t.mesh.children)a instanceof re&&om(a.instanceMatrix.array,t.instanceIndex*16,this.tempMatrix)&&(a.setMatrixAt(t.instanceIndex,this.tempMatrix),a.instanceMatrix.needsUpdate=!0,a.boundingSphere=null)}}updateNonInstancedModelStyle(e){let t=e.components[0],r=e.components[1];if(!t.mesh)return;so(e),this.updateInstanceTransform(e);let n=r.opacity??1;Kl(t.mesh,n,r.visibleThroughGeometry),r.EXPERIMENTAL_clippingEnabled||sr(t.mesh,n)&&(this.transparencyChanged=!0),r.color&&Jl(t.mesh,r.color)}updateInstanceColor(e,t,r){let n=e.components[0];!n.mesh||n.instanceIndex==null||n.instanceIndex<0||Ls(n.mesh,n.instanceIndex,t,r)}removeInstance(e){let t=e.components[0];if(this.detachedEntityIds.delete(e.id),this.nonInstancedModels.has(e.id)){let c=this.nonInstancedModels.get(e.id);return c?.mesh&&(Ql(c.mesh),c.mesh.parent?.remove(c.mesh)),this.nonInstancedModels.delete(e.id),t.mesh=null,this.updateDebugUI(),!0}if(!t.mesh||t.instanceIndex==null||t.instanceIndex<0)return!0;let r=this.getBatchForMesh(t.mesh);if(!r)return!0;let n=t.instanceIndex,i=r.count-1,s=r.opacity===1&&t.mesh.userData?.detached!==!0;if(r.count===1){if(s){r.count=0;for(let f of t.mesh.children)f instanceof re&&(f.count=0,f.instanceMatrix.needsUpdate=!0);let v=this.instanceMap.get(r.containerId)?.get(r.urlHash);return v&&v.object===r.mesh&&(v.count=0),t.mesh.parent&&t.mesh.parent.remove(t.mesh),t.mesh=null,this.updateDebugUI(),!1}let c=r.urlHash;this.removeBatch(r);let d=this.batchesByUrlHash.get(c),u=!1;if(d){for(let h of d)if(h.count>0){u=!0;break}}return Os(t.mesh),t.mesh=null,this.updateDebugUI(),!u}for(let c of t.mesh.children)if(c instanceof re){if(n!==i){c.getMatrixAt(i,this.tempMatrix),c.getColorAt(i,this.tempColor),c.setMatrixAt(n,this.tempMatrix),c.setColorAt(n,this.tempColor);let d=c.userData.entities[i];if(d){c.userData.entities[n]=d;let u=this.state.geometry3DMap.get(d);u?u.components[0].instanceIndex=n:R.warn("[removeInstance] Could not find lastEntity in geometry3DMap:",d)}}delete c.userData.entities[i],c.count=i,c.instanceMatrix.needsUpdate=!0,c.instanceColor&&(c.instanceColor.needsUpdate=!0)}r.count=i;let l=this.instanceMap.get(r.containerId)?.get(r.urlHash);return l&&l.object===r.mesh&&(l.count=i),t.mesh=null,this.updateDebugUI(),!1}destroy(){this.gltfCache.clear(),this.gltfLoadPromises.clear();for(let e of this.instanceMap.values())for(let t of e.values())am(t.object);this.instanceMap.clear(),this.modelNames.clear(),this.batchByMesh.clear(),this.batchesByUrlHash.clear(),this.batchCounter=0;for(let e of this.nonInstancedModels.values())e.mesh&&(Ql(e.mesh),e.mesh.parent?.remove(e.mesh));this.nonInstancedModels.clear(),this.debugUI.destroy(),this.loadPromises=[],this.loader=void 0}endFrame=()=>{this.transparencyChanged=!1}};y();var Fs=class{#e;#n;#i=new O;#o=new V;constructor(e,t,r,n,i={}){this.#e=t,this.#n=new xd(e,r,this.#s(n),{viewportSize:()=>Xr(e),headless:Wt(),...i})}#s(e){return(t,r,n)=>(this.#i.set(t,r,n),this.#o.set(0,0),e(this.#o,this.#i),this.#o.x===0&&this.#o.y===0?null:{x:this.#o.x,y:this.#o.y})}get pipeline(){return this.#n}get labelCanvas(){return this.#n.labelCanvas}get interactiveCollidersQTree(){return this.#n.collisionSystem.interactiveCollidersQTree}get visibleCollidersQTree(){return this.#n.collisionSystem.visibleCollidersQTree}resize(){this.#n.resize()}syncTwoDEntities(){this.#n.clearEntities();for(let e of this.#e.geometry2DsInScene)e.syncPosition(),this.#n.addEntity(e.entity2D)}update(e,t,r,n=[]){this.#a(),this.#n.update(e,t,r,n)}#a(){let e,t;for(let r of this.#e.geometry2DsInScene){t=r.components[0];let n=r.attachedTo?this.#e.geometry3DMap.get(r.attachedTo):void 0;if(n instanceof Q)if(this.#e.geometry3DsInScene.has(n)){if(e=n.components[1],e.dirty||t.attachedDirty){let s=e.height,a=e.altitude;r.setAltitude(s+a)}let i=e.visible;t.visible!==i&&(t.visible=i)}else t.visible===!0&&(t.visible=!1);t.attachedDirty=!1}}markDirty(){this.#n.markDirty()}get collidersNeedRecomputing(){return this.#n.collidersNeedRecomputing}set collidersNeedRecomputing(e){this.#n.collidersNeedRecomputing=e}updateWatermark(e){this.#n.updateWatermark(e)}cancelPendingFrames(){this.#n.cancelPendingFrames()}setCollidersDirty(){this.#n.collisionSystem.collidersDirty=!0}deleteTextCacheEntry(e){delete this.#n.drawSystem.textCache[e]}getLabelCacheStats(){let e=this.#n.drawSystem.getCacheStats(),t=this.#n.drawSystem,r=[];for(let n of this.#e.geometry2DsInScene){if(n.type!=="label")continue;let i=n.entity2D.component,a=t.textCache[i.id]?.canvas??null,l=a!=null,c=i.labelCacheId!=null&&t.pinCache[i.labelCacheId]!=null,d=i.imageHash!=null&&t.imageCache[i.imageHash]!=null,u=a?a.width*a.height*4:0;r.push({id:i.id,text:i.text,screenPosition:{x:i.projection.x,y:i.projection.y},dimensions:{width:i.dimensions.width,height:i.dimensions.height},textCached:l,pinCached:c,imageCached:d,textMemoryBytes:u,totalMemoryBytes:u,textCanvas:a,pinCanvases:i.labelCacheId!=null?t.pinCache[i.labelCacheId]??null:null,imageSource:i.imageHash!=null?t.imageCache[i.imageHash]??null:null})}return{cacheStats:e,labels:r}}showCollisionBoxes(){this.#n.showCollisionBoxes()}hideCollisionBoxes(){this.#n.hideCollisionBoxes()}destroy(){this.#n.destroy()}};var lm=new $t;var{DEFAULT_PITCH:tc,DEFAULT_BEARING:rc,DEFAULT_ZOOM_LEVEL:nc,DEFAULT_MIN_ZOOM_LEVEL:Sv,DEFAULT_MAX_ZOOM_LEVEL:Mv}=ct,Cv=W.radToDeg(.6435011087932844),ec=class extends q{options;container;Debug;#e;#n;#i;#o;get viewCamera(){return this.#o}get cameraObject(){return this.#n}#s;#a;#l;#d;get canvasWidth(){return this.#t.canvasWidth}get canvasHeight(){return this.#t.canvasHeight}rendererDomElement;get resolutionScale(){return this.map?._getClampedPixelRatio(this.canvasWidth,this.canvasHeight)??Zr()}#f(e){this.#p!=="outdoors-overlay"&&this.map?.setPixelRatio(e),this.#t.pixelRatio=this.resolutionScale}get aspect(){return this.canvasWidth/this.canvasHeight}get labelsCanvas(){return this.#r.twoDEntitySystem?.labelCanvas??null}#t;camera;#u;#r={};#b=null;map;#g=()=>{this.signal?.aborted||!this.#r?.renderSystem||(this.#r.renderSystem.twoDdirty=!0)};#c=()=>{this.signal?.aborted||!this.#r?.renderSystem||(this.#r.renderSystem.threeDdirty=!0)};#S=()=>{this.map&&(this.#t.depthRangeFor3D=this.map.painter.depthRangeFor3D)};#C=(e,t)=>{e.addEventListener("childadded",t),e.addEventListener("childremoved",t),this.onAbort(()=>{e.removeEventListener("childadded",t),e.removeEventListener("childremoved",t)})};#M(){this.#r.twoDEntitySystem.markDirty()}#p="standalone";get mode(){return this.#p}#m="native";get cameraMode(){return this.#m}constructor(e,t={}){super();let r={geometry3DMap:new Map,geometry2DMap:new Map,geometry2DIdsInScene:new Set,geometry3DIdsInScene:new Set,geometryGroupIdsToLoad:new Set,geometry3DsInScene:new Set,geometry2DsInScene:new Set,geometryScene:new he("__scene"),hoverColor:"#f6efff",text3dHoverColor:"white",disableUpdateStateValidation:t.disableUpdateStateValidation??!1,insetsPadding:An,shouldMeasureCanvas:!0,pixelRatio:this.resolutionScale,canvasWidth:0,canvasHeight:0,internalTweenGroup:new da,externalTweenGroup:new da,cameraObject:new ga,naturalBearing:0,containerOffset:[0,0],useStandaloneCamera:!1,directionalLight:new Ho(16777215,.3*Math.PI),ambientLight:new ad(16777215,.741*Math.PI),renderer:void 0,threeJSScene:new Rt,depthRangeFor3D:[0,1],renderStats:{drawCalls:0,triangles:0,lines:0,points:0},geometry2DState:{entities:new Set,entityMap:new Map,entityIds:new Set,get pixelRatio(){return r.pixelRatio}}};this.#t=r,this.#t.useStandaloneCamera=t.useStandaloneCamera??!1,this.#t.naturalBearing=t.naturalBearing??0,this.convertTo3DMapPosition=this.convertTo3DMapPosition.bind(this);let{width:n,height:i}=Xr(e);if(!n||!i)throw new Error("[MappedinJS] Container width and height must be greater than 0");(t.mode==="outdoors-interleaved"||t.mode==="outdoors-overlay")&&t.map&&(this.#p=t.mode,this.map=t.map),this.#m=t.outdoorView?.__EXPERIMENTAL_CameraControlsMode==="external"?"external":"native",this.#C(this.#t.geometryScene,()=>{this.#c(),this.#g()}),this.#t.geometry3DMap.set(this.#t.geometryScene.userData.entityId,this.#t.geometryScene),t.center&&(this.#t.center=t.center?[...t.center]:[0,0]),this.options=t,this.container=e,this.#r.htmlControlsSystem=this.#h(new Li(this.container,{outdoorEnabled:!!this.map})),this.#r.maskingSystem=this.#h(new vs(this.#t)),this.#p!=="outdoors-overlay"&&this.#r.htmlControlsSystem.addAttributionControl(this.options.attribution),window.MappedinDebug||(window.MappedinDebug={}),E.env.NODE_ENV==="test"&&(window.MappedinDebug.mapViewCoreInstance=this),this.#u=new si({antialias:typeof t.antialias=="boolean"?t.antialias:!0,alpha:!1,canvas:this.mode!=="standalone"?t.gl?.canvas:void 0,onWebGLContextCreationError:t.onWebGLContextCreationError,onWebGLContextLost:t.onWebGLContextLost,onWebGLContextRestored:b=>{t.onWebGLContextRestored?.(b),this.#g(),this.#c(),this.render()},onWebGLRendererError:t.onWebGLRendererError,backgroundColor:t.backgroundColor||"#ffffff",backgroundAlpha:t.backgroundAlpha??1}),this.#t.renderer=this.#u.renderer,this.#e=this.#t.threeJSScene,this.#e.matrixWorldAutoUpdate=!1,this.#p!=="standalone"&&this.#e.add(Bd()),this.#e.add(this.#t.geometryScene);let s=window.__THREE_DEVTOOLS__;E.env.NODE_ENV==="dev"&&typeof s<"u"&&(s.dispatchEvent(new CustomEvent("observe",{detail:this.#e})),s.dispatchEvent(new CustomEvent("observe",{detail:this.#u}))),this.#n=new ga(Cv,this.aspect,50,1e5),this.#t.cameraObject=this.#n,this.#o=new Kc,this.#o.matrixWorldAutoUpdate=!1,this.#n.renderOrder=999;let a=new Je;a.add(this.#n),this.#d=new Je,this.#d.add(a),this.#e.add(this.#d),this.#n.updateProjectionMatrix(),this.#n.updateMatrixWorld(!0);let l=$p(t.shadows,()=>qp(this.#t));for(let b of l.logLines)R[b.level](b.message);l.enabled&&(this.#r.shadowsSystem=this.#h(new Ts(this.#t,this.#u,this.#d,l.options,l.ladder)),this.map&&this.onMapLibreEvent("render",this.#S)),this.#_=this.mode==="standalone"?this.#n:this.#o,this.referenceMap={scale:1,latitude:0,longitude:0,getNorth:()=>0,georeference:[{target:{x:0,y:0}},{target:{x:0,y:0}},{target:{x:0,y:0}},{target:{x:0,y:0}}]},this.rendererDomElement=this.#u.domElement(),this.#s=new V;let c=new We(1e6,1e6),d=new Be({color:0,visible:!1});this.#a=new X(c,d),this.#a.name="worldPlane",this.#e.add(this.#a),t.gl?.canvas||e.appendChild(this.rendererDomElement),window.addEventListener("resize",this.#F,{capture:!1,signal:this.signal}),this.#T(),document.addEventListener("visibilitychange",this.#R,{signal:this.signal}),typeof ResizeObserver=="function"&&!Wt()&&(this.#l=new ResizeObserver(Do(b=>{this.#w(b[0].contentRect.width,b[0].contentRect.height)},50)),this.#l?.observe(e),this.#l&&this.onAbort(()=>this.#l?.disconnect())),e.classList.add("mappedin-map"),e.style.isolation="isolate",this.rendererDomElement.style.width=globalThis.MappedinDebug?.TEST_IOS?"1080px":"100%",this.rendererDomElement.style.height=globalThis.MappedinDebug?.TEST_IOS?"1920px":"100%",E.env.NODE_ENV==="test"&&this.rendererDomElement.setAttribute("data-testid","mappedin-canvas"),this.mode!=="outdoors-overlay"&&this.#m!=="external"&&this.rendererDomElement.tabIndex!==void 0&&this.rendererDomElement.removeAttribute("tabindex"),Object.defineProperty(this.#t,"canvasWidth",{configurable:!0,enumerable:!0,get:()=>Sa(this.rendererDomElement)?Ot().width:this.rendererDomElement.clientWidth}),Object.defineProperty(this.#t,"canvasHeight",{configurable:!0,enumerable:!0,get:()=>Sa(this.rendererDomElement)?Ot().height:this.rendererDomElement.clientHeight}),this.rendererDomElement.style.touchAction="manipulation";let u=this.canvasWidth,h=this.canvasHeight;this.#r.watermarkSystem=this.#h(new Ti(this.#n,this.#t,t?.watermark)),this.#r.watermarkSystem.on("texture-loaded",this.render),this.#t.shouldMeasureCanvas=!0,this.#t.pixelRatio=this.resolutionScale,this.#k(Math.floor(u*this.resolutionScale),Math.floor(h*this.resolutionScale)),this.#t.directionalLight.position.set(-150,-150,350),this.#e.add(this.#t.directionalLight),this.#e.add(this.#t.ambientLight),this.#r.cameraSystem=this.#h(new Kr(this.#n,this.#e,this.#u.renderer,this.#t,{mode:this.mode,__EXPERIMENTAL_CameraControlsMode:this.cameraMode,canvasHeight:h,canvasWidth:u})),globalThis.MappedinDebug?.__idleCallbackInteractionState&&(globalThis.MappedinDebug.__idleCallbackInteractionState.registerInteractionChecker(this.#r.cameraSystem.isUserInteracting),globalThis.MappedinDebug.__idleCallbackInteractionState.registerInteractionChecker(this.#r.cameraSystem.isCameraMoving)),this.#r.cameraSystem.on("user-dolly-start",this.#x,{signal:this.signal}),this.#r.cameraSystem.on("user-pan-start",this.#x,{signal:this.signal}),this.#r.cameraSystem.on("user-rotate-start",this.#x,{signal:this.signal}),this.#r.cameraSystem.on("user-zoom-start",this.#x,{signal:this.signal}),this.#r.cameraSystem.on("user-tilt-start",this.#x,{signal:this.signal}),this.#r.cameraSystem.on("user-pedestal-start",this.#x,{signal:this.signal}),this.#r.cameraSystem.on("user-dolly-end",this.#L,{signal:this.signal}),this.#r.cameraSystem.on("user-pan-end",this.#L,{signal:this.signal}),this.#r.cameraSystem.on("user-rotate-end",this.#L,{signal:this.signal}),this.#r.cameraSystem.on("user-zoom-end",this.#L,{signal:this.signal}),this.#r.cameraSystem.on("user-tilt-end",this.#L,{signal:this.signal}),this.#r.cameraSystem.on("user-pedestal-end",this.#L,{signal:this.signal}),this.#r.cameraSystem.on("change",()=>{this.publish("camera-change",this.camera),this.#r.geometryInFocusSystem&&(this.#r.geometryInFocusSystem.cameraDirty=!0),this.render()}),this.#r.pathSystem=this.#h(new ro(this.#t,this.convertTo3DMapPosition,this.getParentContainer,this.#r.cameraSystem.convertZoomLevelToAltitude)),this.#r.pathSystem.on("animate:path",this.render,{signal:this.signal}),this.#r.panBoundsSystem=this.#h(new Oi(this.#t,this.#r.cameraSystem));let v=()=>{let{panBounds:b,fov:x,convertAltitudeToZoomLevel:S}=this.#r.cameraSystem;if(this.#r.panBoundsSystem.autoMinZoomLevel){if(b.radius<=0)return;let C=Math.min(this.#t.canvasWidth/this.#t.canvasHeight,1),D=x*Math.PI/180*C,w=Math.tan(D/2),{radius:P,center:T}=this.#r.cameraSystem.panBounds,I=P/w,L=this.getThreeCamera().getWorldPosition(new O),A=T.distanceTo(L),F=Math.abs(L.z-T.z),k=I*F/A,_=S(k);_d(_,this.camera.minZoomLevel)&&this.camera.setMinZoomLevel(_)}this.publish("pan-bounds-change",this.#r.cameraSystem.panBounds)};this.#r.panBoundsSystem.on("update",v,{signal:this.signal}),this.camera=this.#h(new Di(this,this.#r,this.#t));let f=()=>{this.#r.geometryInFocusSystem&&this.#r.geometryInFocusSystem.resize(),this.render()};this.camera.on("padding-change",f,{signal:this.signal}),this.camera.setZoomLevel(t.zoomLevel??nc),this.camera.setBearing(t.bearing??rc),this.camera.setPitch(t.pitch??tc),this.camera.setMaxZoomLevel(Mv),this.camera.setMinZoomLevel(Sv),this.#r.twoDEntitySystem=this.#h(new Fs(this.container,this.#t,this.#t.geometry2DState,this.project,{workerUrl:ha||void 0,useCollisionWorker:(t.useCollisionWorker??!0)&&(t.useWorkers??!0),transformImageRequest:t.transformImageRequest,watermark:{width:0,height:0,position:"bottom-left"}})),this.#r.interactionSystem=this.#h(new kn(this.rendererDomElement,this.#t,this.#n,this.#a,this.#r.cameraSystem.isUserInteracting)),this.#r.interactionSystem.on("doubletap-with-onefinger",b=>{this.#m!=="external"&&this.#r.cameraSystem.enableZoom&&this.camera.animateTo({center:this.projectScreenXYToCoordinate(b.clientX,b.clientY)?.coordinate,zoomLevel:this.camera.zoomLevel+1,duration:xa,easing:"ease-out"})}),this.#r.interactionSystem.on("singletap-with-twofinger",()=>{this.#m!=="external"&&this.#r.cameraSystem.enableZoom&&this.camera.animateTo({zoomLevel:this.camera.zoomLevel-1,duration:xa,easing:"ease-out"})}),this.#r.interactionSystem.on("hover",this.render),this.#r.interactionSystem.on("click",b=>{if(b.entity2D.some(S=>S.id==="watermark")&&typeof this.#r.watermarkSystem.options.onClick=="function"&&this.#r.watermarkSystem.options.interactive){this.#r.watermarkSystem.options.onClick();return}if(!b.position){R.error("Pointer event outside world-plane");return}this.publish("click",{...this.#G(b,b.position),pointerEvent:b.pointerEvent})}),this.#r.interactionSystem.on("long-press",b=>{if(!b.position){R.error("Pointer event outside world-plane");return}this.publish("long-press",{...this.#G(b,b.position),pointerEvent:b.pointerEvent})}),this.#r.interactionSystem.on("hover",b=>{b.position&&this.publish("hover",this.#G(b,b.position))}),this.#r.geometryInFocusSystem=this.#h(new zi(this.#t,this.#_));let M=b=>{this.publish("geometry-in-focus",b)};this.#r.geometryInFocusSystem.on("geometry-in-focus",M,{signal:this.signal}),this.#r.drawSystem=this.#h(new mi(this.#t,this.convertTo3DMapPosition,this.convert3DMapPositionToCoordinate)),this.#r.exporterSystem=this.#h(new zn(this.#t)),this.#r.batchedMeshSystem=this.#h(new hi(this.#t,this.convertTo3DMapPosition)),this.#r.batchedMeshSystem.on("geometry-2d-added",this.render,{signal:this.signal}),this.#r.batchedMeshSystem.on("geometry-group-added",this.#y,{signal:this.signal}),this.#r.modelSystem=this.#h(new Rs(this.#t,this.convertTo3DMapPosition)),this.#r.modelSystem.on("model-loaded",()=>{this.#r.shadowsSystem&&this.#r.shadowsSystem.castersChanged(),this.render()},{signal:this.signal}),this.#r.modelSystem.on("batch-changed",()=>{this.#r.interactionSystem.dirty3D=!0},{signal:this.signal}),this.#r.meshDetachmentSystem=this.#h(new hs(this.#t)),this.#r.meshModificationSystem=this.#h(new ps(this.#t)),this.#r.geometryDisposalSystem=this.#h(new gs(this.#t)),this.#r.textureSystem=this.#h(new ys(this.#t)),this.#r.textureSystem.on("texture-added",this.render,{signal:this.signal}),this.#r.borderSystem=this.#h(new Eu(this.#t,this.convertTo3DMapPosition)),this.#r.clippingPlaneSystem=this.#h(new xs(this.#t)),this.#r.renderOrderSystem=this.#h(new bs(this.#t)),this.#r.pluginSystem=this.#h(new Ss),this.#r.customGeometrySystem=this.#h(new Ai(this.#t,this.convertTo3DMapPosition));let p=typeof t.outlines=="object"?t.outlines:void 0;p&&(this.#t.outlinesOptions=p);let m=t.__TEST_synchronousIdleWork,g=m?.enabled&&typeof m.maxDelay=="number"?m.maxDelay:void 0;this.#r.outlineInterpolationSystem=this.#h(new Ri(this.#t,p,!0,g)),this.#r.outlineInterpolationSystem.on("needs-render",this.render,{signal:this.signal}),this.#r.renderSystem=this.#h(new fi(this.#u,this.#t,this.mode,this.#e,this.#n,this.viewCamera,this.#r)),this.#r.imageSystem=this.#h(new ki(this.#t,this.convertTo3DMapPosition,this.project,t.bearing,t.naturalBearing,t.imagePlacementOptions,t.transformImageRequest)),this.#r.text3DSystem=this.#h(new Nd(this.#t,this.convertTo3DMapPosition,t.useWorkers??!0)),this.#r.text3DSystem.on("render",this.render,{signal:this.signal}),this.#r.imageSystem.on("image-loaded",this.render,{signal:this.signal}),this.#r.renderSystem.on("pre-render",()=>this.publish("pre-render"),{signal:this.signal}),this.#r.renderSystem.on("post-render",()=>this.publish("post-render"),{signal:this.signal}),this.#r.renderSystem.on("measure-canvas",this.#E,{signal:this.signal}),this.#r.outdoorLayersSystem=this.#h(new Qi(this.map,g)),this.#r.occlusion2DSystem=this.#h(new fs(this.#t,this.convertTo3DMapPosition,this.#u)),t.occlusionEnabled&&this.#r.occlusion2DSystem.enable(),this.Debug=new ms(this),t.environment!==!1&&(this.#i=this.#U()),this.#P()}#y=()=>{this.#r.geometryDisposalSystem.dirty=!0,this.render()};#v=e=>Math.trunc(e*10)/10;#A=()=>{this.#f(Zr()),this.#r.twoDEntitySystem.markDirty(),this.#w(void 0,void 0,!0)};#T=()=>{this.signal?.aborted||typeof window>"u"||Wt()||typeof window.matchMedia!="function"||(this.#b=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.#b.addEventListener("change",()=>{this.#A(),this.#T()},{once:!0,signal:this.signal}))};#R=()=>{document.visibilityState==="visible"&&this.#w(void 0,void 0,!0)};#F=()=>{this.#w()};#_;#w=(e,t,r=!1)=>{let n=Xr(this.rendererDomElement),i=e??n.width,s=t??n.height;if((i===0||s===0)&&!r)return;if(this.#r.twoDEntitySystem.resize(),this.#f(Zr()),this.#E(),this.#M(),this.#r.cameraSystem.resize(this.canvasWidth,this.canvasHeight),this.#r.cameraSystem.dirty=!0,this.#r.cameraSystem.stateDirty=!0,this.map!=null){Jo(this.map,this.camera.minZoomLevel,this.camera.maxZoomLevel);let c=this.camera.zoomLevel,d=W.clamp(c,this.camera.minZoomLevel,this.camera.maxZoomLevel);d!==c&&this.camera.setZoomLevel(d)}this.#r.watermarkSystem.resize(this.canvasWidth,this.canvasHeight),this.#r.htmlControlsSystem.resize(this.canvasWidth),this.#r.geometryInFocusSystem.resize(),this.#r.occlusion2DSystem.resize(),this.#r.twoDEntitySystem.resize();let{top:a,left:l}=this.container.getBoundingClientRect();this.#t.containerOffset=[a,l],this.publish("resize"),this.map!=null&&this.publish("camera-change",this.camera),this.render()};#P=()=>{this.renderSync()};#B=new O;project=(e,t)=>{if(this.#n.position.z+this.camera.elevation>t.z){this.#B.copy(t);let r=this.#B.project(this.#_),n=(r.x+1)/2*this.canvasWidth-0/2,i=(-r.y+1)/2*this.canvasHeight-0/2,s=this.#v(n),a=this.#v(i);e.x=s,e.y=a,e instanceof O&&(e.z=r.z)}else e.x=-1e3,e.y=-1e3,e instanceof O&&(e.z=1/0)};#k=(e,t)=>{this.#u.setBufferSize(e,t),this.#n.aspect=e/t,this.#n.updateProjectionMatrix(),this.#n.updateMatrixWorld(!0),this.#s.x=e,this.#s.y=t};#E=()=>{let{width:e,height:t}=Xr(this.rendererDomElement),r=Math.floor(e*this.resolutionScale),n=Math.floor(t*this.resolutionScale);this.#k(r,n),this.map?.resize(),this.#t.shouldMeasureCanvas=!1};addGroupContainer(e,t,r){if(!this.#t.geometry3DMap.has(e)&&!this.#t.geometry2DMap.has(e)){let n=new he(e);this.#C(n,()=>{this.#c(),this.#g()}),t?.visible!==void 0&&(n.visible=t.visible),t?.altitude!==void 0&&n.setAltitude(t.altitude),t?.interactive!==void 0&&je(n,t.interactive,this.#t),t?.focusable!==void 0&&oi(n,t.focusable),t?.preloadGeometry!==void 0&&(n.userData.preloadGeometry=t.preloadGeometry),this.#t.geometry3DMap.set(e,n);let i=this.getParentContainer(r);i instanceof he&&i.addEntity(n),this.#c(),this.render()}else R.error(`Group container with ID '${e}' already exists. The group container cannot be added.`);return{id:e,type:"group-container"}}getParentContainer=(e,t=!0)=>{if(!e)return t?this.#t.geometryScene:void 0;if(typeof e=="string"||typeof e=="number"){let r=this.#t.geometry3DMap.get(e);return r instanceof he?r:(R.warn(`Parent (${typeof e=="object"?e.id:e}) is not a valid container, adding to scene`),t?this.#t.geometryScene:void 0)}else if(e.type==="group-container"){let r=this.#t.geometry3DMap.get(e.id);if(r instanceof he)return r}return t?this.#t.geometryScene:void 0};addCustomGeometry(e,t,r,n,i){if(this.#t.geometry3DMap.has(e))R.error(`Custom geometry with ID '${e}' already exists. The custom geometry cannot be added.`);else{let s=new Qr(t,r),a=new Q(s,new Dt(n));n?.interactive!==void 0&&je(a,n.interactive,this.#t),a.id=e,s.mesh.userData={entityId:e,type:"custom-geometry"},this.#t.geometry3DMap.set(a.id,a);let l=this.getParentContainer(i);i&&l instanceof he?l.addEntity(a):this.#t.geometryScene.addEntity(a),this.#r.panBoundsSystem.dirty=!0,this.#c(),this.render()}return{id:e,type:"custom-geometry"}}registerPlugin(e){this.#r.pluginSystem.registerPlugin(e)}unregisterPlugin(e){this.#r.pluginSystem.unregisterPlugin(e)}addFeatureCollection(e,t,r,n,i){if(!this.#t.geometry3DMap.has(e)&&!this.#t.geometry2DMap.has(e)){let s=new Fe(e);this.#C(s,()=>{this.#c(),this.#g()}),s.userData.dirty=!0,n?.altitude!==void 0&&(s.position.z=n.altitude),n?.visible!==void 0&&(s.visible=n.visible);let a="merged",l;if(typeof r=="function"?(a="batched",l=r):typeof r=="object"?l=()=>r:l=()=>({color:ii}),this.#t.geometry3DMap.set(e,s),a==="batched")for(let u of t.features){if(u.geometry==null||!["Polygon","MultiPolygon","LineString","MultiLineString"].includes(u.geometry.type))continue;let h=u?.id||u?.properties?.id||_r(),v=l(u)??{color:ii},f=this.#r.batchedMeshSystem.createEntityFromFeature(h,u,{outline:!0,...v});this.#t.geometry3DMap.set(h,f),s.userData.entities3D.add(h),this.#r.textureSystem.dirty=!0}else if(a==="merged"){let u=l()??{color:ii},h=this.#r.batchedMeshSystem.createEntityFromFeature(e,t.features,{outline:!0,...u});this.#t.geometry3DMap.set(h.id,h),s.userData.entities3D.add(h.id),s.userData.isMerged=!0,this.#r.textureSystem.dirty=!0}let c=t.features.length>0?l(t.features[0]):void 0;c?.__EXPERIMENTAL_maskEnabled===!0&&Ra(s,{enabled:c.__EXPERIMENTAL_maskEnabled,maskId:c.__EXPERIMENTAL_maskId,effect:c.__EXPERIMENTAL_maskEffect,mode:c.__EXPERIMENTAL_maskMode});let d=this.getParentContainer(i);d instanceof he&&d.addEntity(s),this.#r.panBoundsSystem.dirty=!0,this.#c(),this.render()}else R.error(`Feature collection with ID '${e}' already exists. The feature collection cannot be added.`);return this.#r.outlineInterpolationSystem.geometries3DDirty=!0,{id:e,type:"feature-collection"}}addOccluder(e,t){let r=this.getParentContainer(t),n=this.#r.occlusion2DSystem.reserveOccluderId();return r?.addOccluderFeature(e,n),n}addImage(e,t,r,n){try{oh(e,t,r)}catch(i){R.error(i);return}if(!this.#t.geometry3DMap.has(e)&&!this.#t.geometry2DMap.has(e)){let i=new $n(t),s=new Q(i,new Dt(r));s.id=e||_r(),i.mesh.userData={entityId:s.id,type:"path"},this.#t.geometry3DMap.set(s.id,s),r?.interactive!=null&&je(s,r.interactive,this.#t);let a=this.getParentContainer(n);a instanceof he&&a.addEntity(s);let l=t.geometry.coordinates;if(l){let c=this.convertTo3DMapPosition(l[1],l[0],l[2]??0);this.#r.panBoundsSystem.expandBoundsIfOutside(c)}this.#c(),this.render()}else R.error(`Image with ID '${e}' already exists. The image cannot be added.`);return{id:e,type:"image"}}addModelGroup(e,t,r,{parent:n,onComplete:i}={}){try{Vu(e,t,r)}catch(s){R.error(s);return}if(!this.#t.geometry3DMap.has(e)&&!this.#t.geometry2DMap.has(e)){let s=new Fe(e);this.#C(s,()=>{this.#c(),this.#g()}),this.#t.geometry3DMap.set(e,s),s.userData.dirty=!0,s.userData.modelURL=r.url;for(let c of t.features){let d=c.id||c.properties.id||_r(),u=this.#r.modelSystem.createModelFromFeature(d,c,{...r});(c.properties.interactive!==void 0||r.interactive!=null)&&je(u,c.properties.interactive??r.interactive,this.#t),r.clippingPlaneZOffset!=null&&(u.components[7]=new ti,u.components[7].verticalOffset=r.clippingPlaneZOffset,r.clippingPlaneTopColor!=null&&(u.components[7].topColor=r.clippingPlaneTopColor),r.clippingPlaneTopVisible!=null&&(u.components[7].topVisible=r.clippingPlaneTopVisible)),u.parentId=s.userData.entityId,this.#t.geometry3DMap.set(d,u),s.userData.entities3D.add(d)}let a=this.getParentContainer(n);a instanceof he&&a.addEntity(s);let l=t.features[0]?.geometry.coordinates;if(l){let c=this.convertTo3DMapPosition(l[1],l[0],l[2]??0);this.#r.panBoundsSystem.expandBoundsIfOutside(c)}this.#c(),this.render()?.then(i)}else R.error(`Model group with ID '${e}' already exists. The model group cannot be added.`);return{id:e,type:"feature-collection"}}#D(e,t,r,n){let i=new va(t,this.convertTo3DMapPosition(e[1],e[0],e[2]||0),n);return i.components[2]=new Ms(r??this.#r.occlusion2DSystem.backgroundId),this.#t.geometry2DMap.set(i.id,i),i}addMarker2D(e,t,r,n){let i=r?.id;if(!this.#t.disableUpdateStateValidation)try{Md(e,t,r||{})}catch(s){R.error(s);return}if(i===void 0||!this.#t.geometry2DMap.has(i)&&!this.#t.geometry3DMap.has(i)){let s=this.#D(e,new Vo(t,r),r?.occluderId,r?.verticalOffset);s.id=i||String(s.id),i=s.id,r?.interactive!=null&&r.interactive!=="pointer-events-auto"&&je(s,r?.interactive,this.#t),r?.enabled!=null&&ri(s,r.enabled),r?.occlude!=null&&Oa(s,r.occlude);let a=typeof r?.attachTo=="string"||typeof r?.attachTo=="number"?this.#t.geometry3DMap.get(r.attachTo):void 0;a instanceof Q&&a.attach(s),this.getParentContainer(n)?.addEntity(s),this.#r.panBoundsSystem.expandBoundsIfOutside(s.object3d.position),this.render()}else R.error(`Marker2D with ID '${i}' already exists. The marker cannot be added.`);return{id:i,type:"marker"}}addText3D(e,t,r,n){if(!this.#t.geometry3DMap.has(e)&&!this.#t.geometry2DMap.has(e)){let i=new Qo({...t,properties:{...t.properties,id:e,content:t.properties.text}}),s=new Q(i,new _n(r?.appearance));s.id=e,i.mesh.userData.entityId=e.toString(),i.mesh.userData.type="text3d",this.#t.geometry3DMap.set(e,s);let a=this.getParentContainer(n);a instanceof he&&a.addEntity(s);let l=t.geometry.coordinates;if(l){let c=this.convertTo3DMapPosition(l[1],l[0],l[2]??0);this.#r.panBoundsSystem.expandBoundsIfOutside(c)}this.#c(),this.render()}else R.error(`Text3D with ID '${e}' already exists. The text3d cannot be added.`);return{id:e,type:"text3d"}}labelText3D(e,t,r={}){try{if(!t||!e)throw new Error("content and meshGeometryId are required");zd.parse(r)}catch(c){R.error(c);return}let n=this.#t.geometry3DMap.get(e);if(n?.type!=="geometry"){R.error(".labelText3D failed: target incorrect");return}let i=n?.components[0],s=!Array.isArray(i.feature)&&i.feature.properties.textArea;if(!s)return;if(i.textEntityId){let c=this.#t.geometry3DMap.get(i.textEntityId);if(c?.type!=="text3d"){R.error(".labelText3D failed: existing text3d not found");return}return{id:c.id,type:c.type}}let a=new Qo({type:"Feature",geometry:{coordinates:s?.position,type:"Point"},properties:{textArea:s,content:t,id:_r()}});a.polygonEntityId=e;let l=new Q(a,new _n(r?.appearance));return i.textEntityId=l.id.toString(),a.mesh.userData.entityId=l.id.toString(),a.mesh.userData.type="text3d",this.#t.geometry3DMap.set(l.id.toString(),l),r.parentId&&this.getParentContainer(r.parentId)?.addEntity(l),this.#c(),this.render(),{id:l.id,type:"text3d"}}addLabel2D(e,t,r,n){let i=r?.id;if(!this.#t.disableUpdateStateValidation)try{Sd(e,t,r||{})}catch(s){R.error(s);return}if(i===void 0||!this.#t.geometry2DMap.has(i)&&!this.#t.geometry3DMap.has(i)){let s=this.#D(e,new Wo(t,r||{},this.#t.pixelRatio),r?.occluderId,r?.verticalOffset);s.id=i||String(s.id),i=s.id,r?.interactive!=null&&je(s,r?.interactive,this.#t),r?.enabled!=null&&ri(s,r.enabled),r?.occlude!=null&&Oa(s,r.occlude);let a=typeof r?.attachTo=="string"||typeof r?.attachTo=="number"?this.#t.geometry3DMap.get(r.attachTo):void 0;a instanceof Q&&a.attach(s),this.getParentContainer(n)?.addEntity(s),this.#r.panBoundsSystem.expandBoundsIfOutside(s.object3d.position),this.#g(),this.render()}else R.error(`Label2D with ID '${i}' already exists. The label cannot be added.`);return{id:i,type:"label"}}addPath(e,t={},r){try{Bu(e,t||{})}catch(a){R.error(a);return}let n=new wr(e,yu(t)),i=new Q(n,new Dt({color:t?.color??"#ff834c",altitude:t?.verticalOffset??.1}));i.id=t?.id||_r(),n.mesh.userData={entityId:i.id,type:"path"},this.#t.geometry3DMap.set(i.id,i),t?.interactive!=null&&je(i,t?.interactive,this.#t);let s=this.getParentContainer(r);return s instanceof he&&s.addEntity(i),this.#r.panBoundsSystem.dirty=!0,this.#c(),this.render(),{id:i.id,type:"path"}}updateWatermark(e){this.#r.watermarkSystem.options=e,this.#r.watermarkSystem.dirty=!0,this.#r.twoDEntitySystem.setCollidersDirty(),this.render()}remove(e){let t;if(typeof e=="string"||typeof e=="number"?(t=this.#t.geometry2DMap.get(e),t==null&&(t=this.#t.geometry3DMap.get(e))):typeof e.id=="string"||typeof e.id=="number"?(t=this.#t.geometry2DMap.get(e.id),t==null&&(t=this.#t.geometry3DMap.get(e.id))):t=e,t!=null){if(t.type==="custom-geometry")this.#t.geometry3DMap.delete(t.id),t.object3d&&Ce(t.object3d),this.#c();else if(t.type==="group-container"){this.#t.geometry3DMap.delete(t.userData.entityId);for(let r of t.childrenIds.values())this.remove(r),t.userData.entities2D.delete(r);Ce(t),this.#c()}else if(t.type==="feature-collection"){this.#t.geometry3DMap.delete(t.userData.entityId);for(let r of t.userData.entities3D.values())this.remove(r),t.userData.entities3D.delete(r);Ce(t),this.#c()}else if(t.type==="geometry"||t.type==="model"||t.type==="path"){let r=t.components[0];if(t.entities2D.size>0){for(let i of t.entities2D.values())this.remove(i);t.removeAllEntities()}let n=t.parentObject3D?.userData.entityId??t.parentId;if(n){let i=this.#t.geometry3DMap.get(n);i instanceof Fe&&i.userData.entities3D.delete(t.id)}if(t.type==="model"){if(this.#r.modelSystem.removeInstance(t)&&t.object3d&&Ce(t.object3d),n){let s=this.#t.geometry3DMap.get(n);if(s instanceof Fe&&s.userData.entities3D.size===0){let a=!1;for(let l of s.children)if(l.children.length>0){let c=l.children[0];if(c.isInstancedMesh&&(c.count??0)>0){a=!0;break}}a||this.remove(n)}}}else t.object3d&&Ce(t.object3d);if(t.type==="geometry"){let i=t.components[3];i&&(i.enabled=!1,i.dirty=!0)}"textMesh"in r&&r.textMesh!=null&&this.remove(r.textMesh.userData.entityId),this.#t.geometry3DMap.delete(t.id),this.#c()}else if(t.type==="marker"||t.type==="label"){let r=t.attachedTo;if(r){let n=this.#t.geometry3DMap.get(r);n instanceof Q&&n.detach(t)}t.object3d&&Ce(t.object3d),t.type==="label"&&this.#r.twoDEntitySystem.deleteTextCacheEntry(t.id),this.#t.geometry2DMap.delete(t.id),this.#g()}else if(t.type==="image")t.object3d&&Ce(t.object3d),this.#t.geometry3DMap.delete(t.id),this.#c();else if(t.type==="text3d"){Ce(t.object3d);let{batchedText:r,textMesh:n,polygonEntityId:i}=t.components[0];if(n&&(r&&r.removeText(n),Ce(n)),i){this.#r.text3DSystem.remove(i);let s=this.#t.geometry3DMap.get(i);s?.type==="geometry"&&(s.components[0].textMesh=void 0,s.components[0].textEntityId=void 0)}this.#t.geometry3DMap.delete(t.id),this.#c()}this.render()}}showCollisionBoxes=()=>{this.#r.twoDEntitySystem.showCollisionBoxes(),this.render()};hideCollisionBoxes=()=>{this.#r.twoDEntitySystem.hideCollisionBoxes(),this.render()};getScene(){return this.getState("__scene")}getThreeScene(){return this.#e}getThreeCamera(){return this.#n}async setEnvironment(e){if(this.#e)if(e==="basic"){this.#i||(this.#i=this.#U());let t=await this.#i;this.#e.environment=t}else this.#e.environment=null}getEnvironment(){return this.#e?.environment?"basic":!1}getCurrentSceneGLTF(e){return this.#r.exporterSystem.getCurrentSceneGLTF(e)}getBoundingArea(e){(this.#r.renderSystem.threeDdirty||this.#r.renderSystem.twoDdirty)&&this.renderSync();let t=new de;if(e==null)t.setFromObject(this.#t.geometryScene);else{let r=Sr(this.#t,e);if(r?.type==="geometry"&&r?.object3d!=null){let n=r.components[0],i=n instanceof ue?n.geometry:void 0;n.mesh instanceof No&&i?(i.computeBoundingBox(),i.boundingBox&&t.union(i.boundingBox)):t.setFromObject(r.object3d)}else(r?.type==="feature-collection"||r?.type==="group-container")&&r?.userData.entityId!=null&&t.setFromObject(r)}if(jr(t))return Dd(t).map(this.convert3DMapPositionToCoordinate)}hasState(e){return Sr(this.#t,e)!=null}getState(e){if(e==null)return{type:"map-view",hoverColor:this.#t.hoverColor,text3dHoverColor:this.#t.text3dHoverColor};let t=Sr(this.#t,e);if(t?.type==="custom-geometry"){let r=t.components[0],n=t.components[1];return{id:t.id,type:"custom-geometry",visible:n.visible,altitude:n.altitude,parent:t.parentObject3D?.userData.entityId,position:this.convert3DMapPositionToCoordinate(r.position)}}else if(t?.type==="feature-collection"){let r=Array.from(t.userData.entities3D.values()),n=r?.[0],i=n?this.getState(n):{},s=this.#t,a=this.convert3DMapPositionToCoordinate;return{id:t.userData.entityId,type:"feature-collection",initialColor:i?.initialColor,color:i?.color,hoverColor:i?.hoverColor,side:i?.side??"double",opacity:i?.opacity,height:i?.height,texture:i?.texture,topColor:i?.topColor,topTexture:i?.topTexture,visible:t.visible,altitude:t.position.z,interactive:Cu(t,this.#t),children:r,bevel:i?.bevel,maskId:t.components[0]?.maskId,maskEnabled:t.components[0]?.enabled,maskEffect:t.components[0]?.effect,maskMode:t.components[0]?.mode,get position(){return Mu(t,s,a)}}}else{if(t?.type==="group-container")return{id:t.userData.entityId,type:"group-container",visible:t.visible,altitude:t.position.z,opacity:t.opacity,interactive:!!t.components[0],children:Array.from(t.childrenIds.values()).map(r=>this.getState(r)).filter(Boolean)};if(t?.type==="label"){let r=t.components[0],n=t.object3d.parent,i=n?.userData.entityId;return{id:t.id,type:"label",text:r.text||"",parent:{id:i,type:n?.type},position:this.convert3DMapPositionToCoordinate(t.position),enabled:r.enabled,visible:r.visible,initialRank:Ln(r.initialRank),verticalOffset:t.verticalOffset,options:{rank:Ln(r.rank),appearance:r.appearance,interactive:t.components[1]!=null,verticalOffset:t.verticalOffset,attachTo:t.attachedTo,occlude:t.components[2]?.enabled??!1}}}else if(t?.type==="marker"){let r=t.components[0],n=t.object3d.parent,i=n?.userData.entityId;return{id:t.id,type:"marker",enabled:r.enabled,visible:r.visible,placement:r.options.placement,dynamicResize:r.options.dynamicResize,parent:{id:i,type:n?.type},position:this.convert3DMapPositionToCoordinate(t.position),element:r.containerEl,initialRank:Ln(r.initialRank),contentHTML:r.contentHtml,options:{rank:Ln(r.rank),interactive:t.components[1]!=null||!1,verticalOffset:t.verticalOffset,attachTo:t.attachedTo,lowPriorityPin:r.options.lowPriorityPin,occlude:t.components[2]?.enabled??!1,zIndex:r.options.zIndex,animated:r.options.animated}}}else if(t?.type==="geometry"){let{color:r,hoverColor:n,initialColor:i,initialTopColor:s,topColor:a,altitude:l}=t.components[1],c=t.components[0],d=t.components[4],u=t.components[1],h=t.components[6],v=t.components[2],f=t.components[3],M=t.parentObject3D;return{id:t.id,type:"geometry",opacity:u.opacity,initialColor:i,color:r,focusable:d!=null&&d.vertices!=null&&d.vertices.length>0,initialTopColor:s,topColor:a,side:u.side,hoverColor:n,hovered:!!v?.hover,height:u.height,visible:u.visible,outline:f?.enabled,showImage:u.showImage,texture:h?.texture?.path,topTexture:h?.topTexture?.path,flipImageToFaceCamera:u.flipImageToFaceCamera,enableImageCollisions:u.enableImageCollisions,parent:{id:M?.userData.entityId,type:M?.type},altitude:l,bevel:u.bevel,slope:u.slope,slopeEnabled:u.slopeEnabled,position:this.convert3DMapPositionToCoordinate(c.position),interactive:c.pointerEventsPassThrough?"pass-through":t.components[2]!=null,borderVisible:u.borderVisible,borderColor:u.borderColor,borderWidth:u.borderWidth}}else if(t?.type==="model"){let r=t.components[0],n=t.components[1],i=t.components[2],s=t.components[7],a=r.feature.geometry.coordinates,l=[a[0],a[1],a[2]??0];return{id:t.id,type:"model",position:l,interactive:i!=null,material:n.material,parent:t.parentObject3D?.parent?{id:t.parentObject3D.parent.userData.entityId,type:t.parentObject3D.parent.type}:void 0,visible:n.visible,verticalOffset:n.verticalOffset,color:n.color,opacity:n.opacity,rotation:n.rotation??Kt,scale:n.scale??Jt,clippingPlaneZOffset:s?.verticalOffset??n.clippingPlaneZOffset,clippingPlaneTopColor:s?.topColor??n.clippingPlaneTopColor,clippingPlaneTopVisible:s?.topVisible??n.clippingPlaneTopVisible}}else if(t?.type==="path"){let r=t.components[0],n=t.components[2],i=t.components[1];return{id:t.id,type:"path",position:this.convert3DMapPositionToCoordinate(r.position),visible:i.visible,interactive:n!=null,completeFraction:r.completeFraction,color:i.color,accentColor:r.accentColor,width:r.width,animateArrowsOnPath:r.animateArrowsOnPath,displayArrowsOnPath:r.displayArrowsOnPath,verticalOffset:i.altitude,highlightCompleteFraction:r.highlightCompleteFraction,highlightStartFraction:r.highlightStartFraction,highlightEndFraction:r.highlightEndFraction,highlightColor:r.highlightColor,highlightWidthMultiplier:r.highlightWidthMultiplier,highlightDisplayArrowsOnPath:r.highlightDisplayArrowsOnPath,travelledEndFraction:r.travelledEndFraction,travelledColor:r.travelledColor,xrayOpacity:r.xrayOpacity,xrayStyle:r.xrayStyle,smoothingTension:r.smoothingTension,smoothingCornerRadius:r.smoothingCornerRadius,dashed:r.dashed,dashDiscrete:r.dashDiscrete,dashedMask:r.dashedMask,dashCornerRadius:r.dashCornerRadius,dashLength:r.dashLength,dashGap:r.dashGap,dashRelativeToWidth:r.dashRelativeToWidth,dashSize:r.dashSize,gapSize:r.gapSize,dashAbsolute:r.dashAbsolute,dashMeters:r.dashMeters,gapMeters:r.gapMeters,geometryType:r.geometryType,endcapExtension:r.endcapExtension,billboarding:r.billboarding,border:r.border}}else if(t?.type==="image"){let r=t.components[0],n=t.components[2];return{id:t.id,type:"image",position:this.convert3DMapPositionToCoordinate(r.position),visible:t.components[1].visible,verticalOffset:r.feature.properties.verticalOffset??0,opacity:t.components[1].opacity,flipImageToFaceCamera:t.components[1].flipImageToFaceCamera,width:r.feature.properties.width??0,height:r.feature.properties.height??0,rotation:r.feature.properties.rotation??0,interactive:n!=null}}else if(t?.type==="text3d"&&t.components[0]instanceof Qo){bu(t);let r=t.components[0],n=t.components[1],{textMesh:i}=r,s=r.feature.properties,a=r.mesh?.parent;a instanceof he&&a.children.find(h=>h.type==="batchedtext")?.getWorldPosition(this.#H),this.#z.set(0,0,0);let l=i?i.getWorldPosition(this.#z):this.#z,c=s.rotation??s.textArea?.rotation??0,d=s.content??s.text??"";return Object.assign({},_t,n.getState(),{id:t.id,type:"text3d",position:this.convert3DMapPositionToCoordinate(l.add(this.#H)),visible:r.visible??!1,content:d,rotation:c})}else return}}getRenderedState(e){let t=typeof e=="string"||typeof e=="number"?e:e.id,r=Sr(this.#t,t);if(r&&r.type==="label")return{textVisible:r.components[0].textVisible}}setState(e,t){if(typeof e=="object"&&t==null){"hoverColor"in e&&(fd(e.hoverColor)?this.#t.hoverColor=e.hoverColor??this.#t.hoverColor:R.warn(`Failed to update global hover color. Invalid color "${e.hoverColor}".`)),"text3dHoverColor"in e&&(this.#t.text3dHoverColor=e.text3dHoverColor??this.#t.text3dHoverColor);return}let r=Sr(this.#t,e);if(r!=null){if(r.type==="custom-geometry"){let n=this.#t.geometry3DMap.get(r.id);if(n instanceof Q&&n.components[0]instanceof Qr){let i=t;Cr(r,this.#t,i.visible),Gn(r,this.#t,i.altitude),Pa(r,i.position,this.convertTo3DMapPosition,this.#r.panBoundsSystem),Ia(r,this.getParentContainer(i.parent,!1)),je(r,i.interactive,this.#t)&&this.#c()}}else if(r.type==="path"){let n=t;je(r,n.interactive,this.#t)&&this.#c(),Gn(r,this.#t,n.verticalOffset),gu(r,this.#t,n)}else if(r.type==="model"){let n=t;je(r,n.interactive,this.#t)&&this.#c(),Cr(r,this.#t,n.visible),xu(r,n,this.convertTo3DMapPosition,this.#r.panBoundsSystem),Su(r,n)}else if(r.type==="group-container"){let n=t;Cr(r,this.#t,n.visible)&&(this.#r.pathSystem.verticalDistanceDirty=!0,this.#r.geometryInFocusSystem.focusablesDirty=!0),Gn(r,this.#t,n.altitude)&&(this.#r.pathSystem.verticalDistanceDirty=!0),je(r,n.interactive,this.#t)&&this.#c(),ni(r,this.#t,n.opacity)&&(this.#r.outlineInterpolationSystem.outlineOpacitiesDirty=!0),n.preloadGeometry&&r.userData.preloadGeometry!==!0&&(r.userData.preloadGeometry=!0,this.#r.outlineInterpolationSystem.geometries3DDirty=!0),oi(r,n.focusable)&&(this.#r.geometryInFocusSystem.focusablesDirty=!0)}else if(r.type==="feature-collection"){let n=t;n.visible!==void 0&&r.visible!==n.visible&&(r.visible=n.visible,this.#c()),n.altitude!==void 0&&r.position.z!==n.altitude&&(r.position.z=n.altitude,this.#c()),Kd(r,this.#t,n),su(r,this.#t,n.hoverColor),Fa(r,this.#t,n.outline),n.height!=null&&Ta(r,this.#t,n.height)&&this.#r.shadowsSystem?.castersChanged(),n.heightScale!=null&&tu(r,this.#t,n.heightScale)&&this.#r.shadowsSystem?.castersChanged(),Aa(r,this.#t,n)&&(this.#r.textureSystem.dirty=!0),Aa(r,this.#t,n),Qd(r,this.#t,n.shading),ni(r,this.#t,n.opacity)&&(this.#r.outlineInterpolationSystem.outlineOpacitiesDirty=!0),je(r,n.interactive,this.#t)&&(this.#c(),this.#g(),this.#r.interactionSystem.dirty3D=!0),_a(r,this.#t,n.side),Ra(r,{maskId:n.maskId,enabled:n.maskEnabled,effect:n.maskEffect,mode:n.maskMode}),du(r,this.#t,{effectStart:n.effectStart,effectDistance:n.effectDistance,darkenAmount:n.darkenAmount,darkenUseDepth:n.darkenUseDepth,desaturateAmount:n.desaturateAmount,desaturateUseDepth:n.desaturateUseDepth,washOutAmount:n.washOutAmount,washOutUseDepth:n.washOutUseDepth}),n.position!=null&&(r.userData.centroid=[n.position[0],n.position[1]],r.userData.positionDirty=!0)}else if(r.type==="geometry"){if(r.components[0]instanceof ue){let n=t;if(Cr(r,this.#t,n.visible)&&this.#c(),Fa(r,this.#t,n.outline),eu(r,n),oi(r,n.focusable)&&(this.#r.geometryInFocusSystem.focusablesDirty=!0),hu(r,n.renderOrder)&&(this.#r.meshDetachmentSystem.dirty=!0),uu(r,n.opacity)&&(this.#r.meshDetachmentSystem.dirty=!0,this.#r.interactionSystem.dirty3D=!0,this.#r.outlineInterpolationSystem.outlineOpacitiesDirty=!0),La(r,n.flipImageToFaceCamera),lu(r,n.enableImageCollisions),Gn(r,this.#t,n.altitude)){let i=r.components[1],s=(i.altitude??0)+(i.height??0);this.#r.panBoundsSystem.expandBoundsIfOutside(new O(0,0,s)),this.#r.shadowsSystem&&this.#r.shadowsSystem.castersChanged()}if(n.height!=null&&Ta(r,this.#t,n.height)){let i=r.components[1],s=(i.altitude??0)+(i.height??0);this.#r.panBoundsSystem.expandBoundsIfOutside(new O(0,0,s)),this.#r.shadowsSystem&&this.#r.shadowsSystem.castersChanged()}cu(r,n)&&(this.#r.meshDetachmentSystem.dirty=!0,this.#r.textureSystem.dirty=!0),ru(r,n,this.#t.outlinesOptions?.darkenFactor),iu(r,n.hoverColor),je(r,n.interactive,this.#t)&&(this.#r.interactionSystem.dirty3D=!0),au(r,n.hovered),_a(r,this.#t,n.side),pu(r,n.slope),mu(r,n.slopeEnabled),fu(r,n)}}else if(r.type==="label"||r.type==="marker"){let n=t;ou(r,n,this.#t),nu(r,n,this.#t)&&(this.#g(),this.#r.twoDEntitySystem.markDirty()),Pa(r,n.position,this.convertTo3DMapPosition,this.#r.panBoundsSystem),Ia(r,this.getParentContainer(n.parent,!1))&&(this.#g(),this.#r.panBoundsSystem.dirty=!0),ri(r,n.enabled),Cr(r,this.#t,n.visible)}else if(r.type==="image"){let n=t;Cr(r,this.#t,n.visible),ni(r,this.#t,n.opacity),La(r,n.flipImageToFaceCamera),je(r,n.interactive,this.#t)&&this.#c()}else if(r.type==="text3d"){let n=t;vu(r,this.#t,n)}this.render()}}projectScreenXYToCoordinate=(e,t,r=!1)=>{let n=this.container.getBoundingClientRect(),i=(e-n.left)/this.#t.canvasWidth*2-1,s=-((t-n.top)/this.#t.canvasHeight)*2+1,a=new V(i,s),l,c;if(r?(lm.setFromCamera(a,this.#n),l=lm.intersectObject(this.#a,!1)[0]?.point):(l=this.#r.interactionSystem.getThreeDIntersectsFromXY(a)?.[0]?.point,c=this.#r.interactionSystem.getGroupContainerIntersectsFromXY(a)),l)return{coordinate:this.convert3DMapPositionToCoordinate(l),groupContainers:c}};projectCoordinateToScreenXY=e=>{let t=this.convertTo3DMapPosition(e[1],e[0],e[2]||0),r=new V;return this.project(r,t),{x:r.x,y:r.y}};convertTo3DMapPosition(e,t,r=0,n){if(Array.isArray(e))return this.convertTo3DMapPosition(e[1],e[0],e[2]??r,typeof t=="function"?t:void 0);if(typeof t!="number")throw new Error("convertTo3DMapPosition failed: longitude must be a number");let{x:i,y:s}=Yo(this.#t.center?.[1]??0,this.#t.center?.[0]??0,e,t);return n?(n.set(i,s,r),n):new O(i,s,r)}convert3DMapPositionToCoordinate=e=>{let{lat:t,lon:r}=Xo(this.#t.center?.[1]??0,this.#t.center?.[0]??0,e.x,e.y);return[r,t,e.z]};#G=(e,t)=>{let r=e.entity3D?[e.entity3D.id]:[];e.entity3D?.parentObject3D?.userData?.entityId&&r.push(e.entity3D.parentObject3D.userData.entityId);let n=[],i=[];for(let l of e.entity2D)l.components&&(l.components[0]instanceof Vo?n.push(l.id):l.components[0]instanceof Wo&&i.push(l.id));let s=e.entity3D?.components[0],a=e.entity3D?.id;return{coordinate:this.convert3DMapPositionToCoordinate(t),geometry:r,paths:s instanceof wr&&a!==void 0?[a]:[],markers:n,models:s instanceof Dr&&a!==void 0?[a]:[],images:s instanceof $n&&a!==void 0?[a]:[],labels:i,containers:Array.isArray(e.groupContainers)?e.groupContainers.map(l=>l.userData.entityId):[]}};setBackgroundColor=(e,t)=>{this.#u.setBackgroundColor(e,t)};get backgroundColor(){return typeof this.#u.backgroundColor=="string"?this.#u.backgroundColor:`#${this.#u.backgroundColor.getHexString()}`}get backgroundAlpha(){return this.#u.backgroundAlpha}getThreeRenderer(){return this.#u}getMetersPerPixel=()=>this.#r.cameraSystem.getCurrentMetersPerPixel();hideOutdoorLayersIntersectingPolygons=(e,t)=>{this.#r.outdoorLayersSystem.hideLayersIntersectingPolygons(e,t),this.render()};getCenter(e){let t=Array.isArray(e)?e:this.getBoundingArea(e);return t?Fd(t):void 0}#I=new Nr;#N=new K;isInView(e){let t=Sr(this.#t,e);if(this.#N.identity().multiply(this.#n.projectionMatrix).multiply(this.#n.matrixWorldInverse),this.#I.setFromProjectionMatrix(this.#N),t instanceof va)return this.#I.containsPoint(t.position);if(t instanceof Q){let r=t?.components[0];if(r instanceof Qr||r instanceof Dr)return this.#I.containsPoint(this.convertTo3DMapPosition(r.feature.geometry.coordinates));if(r instanceof ue){let n=new de(this.convertTo3DMapPosition(r.featureBbox[1],r.featureBbox[0],0),this.convertTo3DMapPosition(r.featureBbox[3],r.featureBbox[2],0));return this.#I.intersectsBox(n)}}return!1}queryGeometry2DInView(e){let{screenOffsets:t,fullyContains:r}=e??{},[n,i,s,a]=Gd(this.container,t),l=new qt(n,i,s,a);return this.#r.twoDEntitySystem.visibleCollidersQTree.queryRect(l).filter(h=>r?l.contains(h):l.intersects(h)).map(h=>this.#t.geometry2DMap.get(h.userData.entityId)).filter(h=>h!=null).filter(h=>h.components[0]instanceof Wo||h.components[0]instanceof Vo).map(h=>h.id.toString())}#O=e=>{R.error("Render failed: ",e,e.stack??"No stack trace available"),this.publish("render-error",{error:e})};render=()=>{if(!(this.#r?.renderSystem==null||this.signal?.aborted))if(this.map&&(this.mode==="outdoors-interleaved"||this.mode==="outdoors-overlay"))this.map.triggerRepaint();else return this.#r.renderSystem.update().catch(this.#O)};renderSync=()=>this.signal?.aborted?Promise.resolve():this.#r.renderSystem.update(!0).catch(this.#O);#x=zt(()=>{this.publish("user-interaction-start",void 0)},0,!0);#L=zt(()=>{this.publish("user-interaction-end",void 0),this.render()},0,!0);onMapLibreEvent(e,t){if(!this.map){R.warn(`Tried to add event listener "${e}" but MapLibre map is not initialized.`);return}let r=this.map.on(e,t);r?.unsubscribe&&this.onAbort(()=>r.unsubscribe())}offMapLibreEvent(e,t){this.map&&this.map.off(e,t)}getSystems(){return this.#r}getInternalState(){return this.#t}getInternalTweenGroup(){return this.#t.internalTweenGroup}getExternalTweenGroup(){return this.#t.externalTweenGroup}async#U(){return er.load(Tu).then(e=>(this.#e&&(this.#e.environment?.dispose(),e.mapping=Hc,this.#e.environment=e,this.render()),e))}computeMinZOffsetBetweenContainers(e,t,r){if(!e||!t)return-1;ka(e,"group-container"),ka(t,"group-container"),e.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let n=qo(e,this.getThreeCamera()),i=t.clone(!0);$o(i,!0),i.updateMatrixWorld();let s=qo(i,this.getThreeCamera());if(!jr(n)||!jr(s))return-1;let a=0,l;r&&this.container.querySelectorAll(".debug-box").forEach(d=>d.remove());do{if(a>1e4)return-1;if(a+=20,i.setAltitude(a),s.makeEmpty(),qo(i,this.#n,s),l=n.intersectsBox(s),r){let c=Ca(n,"blue",this.container),d=Ca(s,l?"red":"green",this.container);c.classList.add("debug-box"),d.classList.add("debug-box")}}while(l);return a}on=(e,t,r)=>{let n=super.on(e,t,r);return["outdoor-view-loaded","outdoor-style-loaded"].includes(e)&&this.mode==="standalone"&&E.env.NODE_ENV!=="test"&&(Wt()||R.warn(`"${e}" was subscribed to but outdoor view is disabled. The event has been triggered immediately. Enable outdoor view or remove the listener.`),this.publish(e),n()),n};off=(e,t)=>{super.off(e,t)};getCursor=()=>this.#r.interactionSystem.getCursor();#W=()=>{try{this.#p!=="outdoors-overlay"&&(this.map&&this.map.remove(),this.container&&this.rendererDomElement&&this.container.contains(this.rendererDomElement)&&this.container.removeChild(this.rendererDomElement))}catch(e){R.warn("Error during DOM cleanup, some elements may not have been removed:",e)}};#h=e=>(this.onAbort(()=>{e&&typeof e=="object"&&("destroy"in e&&typeof e.destroy=="function"?e.destroy():"dispose"in e&&typeof e.dispose=="function"&&e.dispose())}),e);destroy=()=>{!this.#r||this.signal?.aborted||(super.destroy(),globalThis.MappedinDebug?.__idleCallbackInteractionState&&(globalThis.MappedinDebug.__idleCallbackInteractionState.unregisterInteractionChecker(this.#r.cameraSystem.isUserInteracting),globalThis.MappedinDebug.__idleCallbackInteractionState.unregisterInteractionChecker(this.#r.cameraSystem.isCameraMoving)),this.remove("__scene"),this.#u.destroy(),this.#e?.traverse(e=>{Ce(e),"dispose"in e&&typeof e.dispose=="function"&&e.dispose()}),this.#e=void 0,this.#r=void 0,this.#W(),this.#u=void 0)};#z=new O;#H=new O},ar=ec;y();var wv=5,Ev=2e3;function cm({refreshOutdoorToken:o,headers:e,reloadSource:t,maxAttempts:r=wv,backoffMs:n=Ev,now:i=()=>Date.now()}){let s=!1,a=0,l=0,c,d=f=>{if(f)try{t(f)}catch(M){R.warn("Failed to reload outdoor source after token refresh:",M)}},u=f=>{a+=1,!(a>=r||c!==void 0)&&(c=setTimeout(()=>{c=void 0,h(f)},n))},h=async f=>{if(s||a>=r||c!==void 0)return;let M=i();if(!(M-l<n)){s=!0,l=M;try{let p=await o();if(!p||p===e["x-mappedin-tiles-key"]){u(f);return}e["x-mappedin-tiles-key"]=p,a=0,d(f)}catch(p){R.warn("Failed to refresh outdoor tiles token:",p),u(f)}finally{s=!1}}};return{recoverFromTileAuthError:h,dispose:()=>{c!==void 0&&(clearTimeout(c),c=void 0)}}}y();function dm(o,e){let{cameraSystem:t}=o.getSystems(),r={center:e.getCenter().toArray(),zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),elevation:e.getCenterElevation()},n=!1;o.on("camera-change",i=>{if(!n){r.center=i.center,r.zoom=i.zoomLevel,r.bearing=i.bearing,r.pitch=i.pitch,r.elevation=i.elevation,n=!0;try{e.jumpTo(r)}finally{n=!1}}}),o.onMapLibreEvent("move",()=>{if(!n){n=!0;try{let i=e.getCenter();t.setCenter(i.lng,i.lat),t.setZoomLevel(e.getZoom()),t.setRotation(W.degToRad(e.getBearing())),t.setTilt(W.degToRad(e.getPitch())),t.setPedestal(Math.min(e.getCenterElevation(),t.maxPedestal),!0)}finally{n=!1}}}),o.onMapLibreEvent("movestart",()=>{n||t.beginGesture()}),o.onMapLibreEvent("moveend",()=>{n||t.endGesture()})}y();function Dv(o,e){Tv(o,e)(o.getScene(),e),Pv(o,e),e.addFolder("Export").add({export:async()=>{let s=await o.getCurrentSceneGLTF({binary:!0}),a=new Blob([s],{type:"application/octet-stream"});var l=document.createElement("a");document.body.appendChild(l),l.style.display="none";let c=window.URL.createObjectURL(a);l.href=c,l.download="scene.glb",l.click(),window.URL.revokeObjectURL(c)}},"export");let n=e.addFolder("Camera"),i={get bearing(){return o.camera.bearing},set bearing(s){o.camera.setBearing(s)},get pitch(){return o.camera.pitch},set pitch(s){o.camera.setPitch(s)},get zoomLevel(){return o.camera.zoomLevel},set zoomLevel(s){o.camera.setZoomLevel(s)}};n.add(i,"bearing",-359,359,1),n.add(i,"pitch",o.camera.minPitch,o.camera.maxPitch,1),n.add(i,"zoomLevel",o.camera.minZoomLevel,o.camera.maxZoomLevel,.1)}function Tv(o,e){let t=e;return function r(n,i){let s=i.addFolder(`${[n.type]} ${n.id.slice(0,16)}`);if(i.close(),n.type==="geometry"||n.type==="model"||n.type==="path"||n.type==="image"){let a={get height(){let l=o.getState(n.id);return l?.type==="geometry"?l.height:0},set height(l){o.getState(n.id)?.type==="geometry"&&o.setState(n,{height:l})},set flipImageToFaceCamera(l){o.getState(n.id)?.type==="image"&&o.setState(n,{flipImageToFaceCamera:l})},get flipImageToFaceCamera(){let l=o.getState(n.id);return l?.type==="image"?l.flipImageToFaceCamera:!1},set visible(l){let c=o.getState(n.id);(c?.type==="geometry"||c?.type==="path"||c?.type==="image")&&o.setState(n,{visible:l})},get visible(){let l=o.getState(n.id);return l?.type==="geometry"||l?.type==="path"||l?.type==="image"?l.visible:!1},set outline(l){o.getState(n.id)?.type==="geometry"&&o.setState(n,{outline:l})},get outline(){let l=o.getState(n.id);return l?.type==="geometry"?l.outline:!1},get opacity(){let l=o.getState(n.id);return l?.type==="geometry"?l.opacity:1},set opacity(l){let c=o.getState(n.id);c?.type==="geometry"&&o.setState(c,{opacity:l})},get color(){let l=o.getState(n.id);return l?.type==="geometry"&&l.color?gd(l.color).toHexString():"#ffffff"},set color(l){let c=o.getState(n.id);c?.type==="geometry"&&o.setState(c,{color:l})},set interactive(l){let c=o.getState(n.id);(c?.type==="geometry"||c?.type==="model"||c?.type==="path")&&(o.setState(n,{interactive:l}),t.controllersRecursive().forEach(d=>d.updateDisplay()))},get interactive(){let l=o.getState(n.id);return l?.type==="geometry"||l?.type==="model"||l?.type==="path"?l.interactive:!1},get completeFraction(){let l=o.getState(n.id);return l?.type==="path"?l.completeFraction:1},set completeFraction(l){let c=o.getState(n.id);c?.type==="path"&&o.setState(c,{completeFraction:l})},focus:()=>{}};s.add(a,"focus").onChange(()=>{let l=o.getState(n.id);l?.type==="model"||l?.type==="path"||l?.type==="image"?o.camera.focusOn([l.position]):l?.type==="geometry"&&o.camera.focusOn(o.getBoundingArea(l))}),s.add(a,"visible"),n.type==="image"?s.add(a,"flipImageToFaceCamera"):(s.add(a,"interactive"),n.type==="path"&&s.add(a,"completeFraction",0,1,.1),n.type!=="model"&&(s.addColor(a,"color"),s.add(a,"outline"))),n.type==="geometry"&&(s.add(a,"height"),s.add(a,"opacity",0,1,.1))}else if(n.type==="marker"){let a={get interactive(){let l=o.getState(n.id);return l?.type==="marker"?l.options?.interactive:!1},set interactive(l){let c=o.getState(n.id);c?.type==="marker"&&(o.setState(c,{options:{interactive:l}}),t.controllersRecursive().forEach(d=>d.updateDisplay()))},focus:()=>{}};s.add(a,"focus").onChange(()=>{let l=o.getState(n.id);l?.type==="marker"&&o.camera.focusOn([l.position])}),s.add(a,"interactive")}else if(n.type==="label"){let a={get interactive(){let l=o.getState(n.id);return l?.type==="label"?l.options?.interactive:!1},set interactive(l){let c=o.getState(n.id);c?.type==="label"&&(o.setState(c,{options:{interactive:l}}),t.controllersRecursive().forEach(d=>d.updateDisplay()))},get text(){let l=o.getState(n.id);return l?.type==="label"?l.text:""},set text(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:l})},get"Text Color"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.textColor:"#000000"},set"Text Color"(l){o.getState(n.id)?.type==="label"&&o.setState(n.id,{text:a.text,options:{appearance:{textColor:l}}})},get"Text Size"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.textSize:10},set"Text Size"(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:a.text,options:{appearance:{textSize:l}}})},get"Icon Size"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.iconSize:10},set"Icon Size"(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:a.text,options:{appearance:{iconSize:l}}})},get"Pin Color"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.pinColor:"#000000"},set"Pin Color"(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:a.text,options:{appearance:{pinColor:l}}})},get"Pin Color Inactive"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.pinColorInactive:"#000000"},set"Pin Color Inactive"(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:a.text,options:{appearance:{pinColorInactive:l}}})},get"Pin Outline Color"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.pinOutlineColor:"#000000"},set"Pin Outline Color"(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:a.text,options:{appearance:{pinOutlineColor:l}}})},get"Pin Outline Color Inactive"(){let l=o.getState(n.id);return l?.type==="label"?l.options.appearance?.pinOutlineColorInactive:"#000000"},set"Pin Outline Color Inactive"(l){let c=o.getState(n.id);c?.type==="label"&&o.setState(c,{text:a.text,options:{appearance:{pinOutlineColorInactive:l}}})},focus:()=>{}};s.add(a,"focus").onChange(()=>{let l=o.getState(n.id);l?.type==="label"&&o.camera.focusOn([l.position])}),s.add(a,"interactive"),s.add(a,"text"),s.add(a,"Text Size",10,50),s.add(a,"Icon Size",10,50),s.addColor(a,"Text Color"),s.addColor(a,"Active Background Color"),s.addColor(a,"Inactive Background Color"),s.addColor(a,"Active Foreground Color"),s.addColor(a,"Inactive Foreground Color")}else if(n.type==="feature-collection"){let a={get opacity(){let l=o.getState(n.id);return l?.type==="feature-collection"?l.opacity:1},set opacity(l){o.getState(n.id)?.type==="feature-collection"&&o.setState(n,{opacity:l})},set outline(l){o.getState(n.id)?.type==="feature-collection"&&o.setState(n,{outline:l})},get outline(){let l=o.getState(n.id);return l?.type==="feature-collection"?l.outline??!1:!1},set interactive(l){o.getState(n.id)?.type==="feature-collection"&&(o.setState(n,{interactive:l}),t.controllersRecursive().forEach(d=>d.updateDisplay()))},get interactive(){let l=o.getState(n.id);return l?.type==="feature-collection"?l.interactive:!1},get shadingStart(){let l=o.getState(n.id);return l?.type==="feature-collection"?l.shading?.start??0:0},set shadingStart(l){let c=o.getState(n.id);c?.type==="feature-collection"&&o.setState(c,{shading:{start:l}})},get shadingEnd(){let l=o.getState(n.id);return l?.type==="feature-collection"?l.shading?.end??0:0},set shadingEnd(l){let c=o.getState(n.id);c?.type==="feature-collection"&&o.setState(c,{shading:{end:l}})},get shadingIntensity(){let l=o.getState(n.id);return l?.type==="feature-collection"?l.shading?.intensity??0:0},set shadingIntensity(l){let c=o.getState(n.id);c?.type==="feature-collection"&&o.setState(c,{shading:{intensity:l}})}};s.add(a,"opacity",0,1,.1),s.add(a,"interactive"),s.add(a,"outline"),s.add(a,"shadingStart",0,1,.1),s.add(a,"shadingEnd",0,1,.1),s.add(a,"shadingIntensity",0,1,.1)}else if(n.type==="group-container"){let a={set visible(l){o.getState(n.id)?.type==="group-container"&&o.setState(n,{visible:l})},get visible(){let l=o.getState(n.id);return l?.type==="group-container"?l.visible:!1},set interactive(l){let c=o.getState(n.id);c?.type==="group-container"&&(o.setState(c,{interactive:l}),t.controllersRecursive().forEach(d=>d.updateDisplay()))},get interactive(){let l=o.getState(n.id);return l?.type==="group-container"?l.interactive:!1}};s.add(a,"visible"),s.add(a,"interactive")}if(s.close(),n.children)for(let a of n.children.values())a==null||typeof a!="object"||r(a,s)}}function Pv(o,e){let t=e.addFolder("Watermark"),r={padding:16,iconOnly:!1,position:"bottom-left",color:"dark",scale:1};t.add(r,"padding",0,100,1),t.add(r,"scale",.5,1.5,.1),t.add(r,"color",["dark","light"]),t.add(r,"position",["top-left","top-right","bottom-left","bottom-right","center","top","bottom","left","right"]),t.add(r,"iconOnly"),t.onChange(()=>{o.updateWatermark(r)})}y();var oc=class extends q{gl;options;el=document.createElement("div");core;origin;map;layer;cameraSystem;constructor(e,t){super(),this.origin=e,this.options=t}handleStyleChange=()=>{!this.map||!this.layer||this.map.getLayer(this.layer.id)||(this.map.addLayer(this.layer),this.core.camera.setMinZoomLevel(this.map.getMinZoom()),this.core.camera.setMaxZoomLevel(this.map.getMaxZoom()),this.core.camera.setMinPitch(this.map.getMinPitch()),this.core.camera.setMaxPitch(this.map.getMaxPitch()))};handleMoveStart=()=>{this.cameraSystem.beginGesture()};handleMove=()=>{if(!this.map)return;let[e,t]=this.map.getCenter().toArray();this.cameraSystem.setCenter(e,t),this.cameraSystem.setZoomLevel(this.map.getZoom()),this.cameraSystem.setRotation(W.degToRad(this.map.getBearing())),this.cameraSystem.setTilt(W.degToRad(this.map.getPitch()))};handleMoveEnd=()=>{this.cameraSystem.endGesture()};handleError=e=>{R.warn(e)};onAdd(e){this.origin=this.origin||e.getCenter().toArray(),this.gl=e.painter.context.gl,this.core=new ar(e._container,{...this.options,center:this.origin,zoomLevel:e.getZoom(),pitch:e.getPitch(),bearing:e.getBearing(),gl:this.gl,map:e,mode:"outdoors-overlay"}),this.map=e,this.cameraSystem=this.core.getSystems().cameraSystem,this.core.camera.setMinZoomLevel(e.getMinZoom()),this.core.camera.setMaxZoomLevel(e.getMaxZoom()),this.core.camera.setMinPitch(e.getMinPitch()),this.core.camera.setMaxPitch(e.getMaxPitch()),this.map.on("error",this.handleError);let t=xr.fromLngLat(this.origin,0);return this.layer=Zo(t,this.core.viewCamera,()=>{this.core.renderSync()}),this.map.on("styledata",this.handleStyleChange),this.map.on("movestart",this.handleMoveStart),this.map.on("move",this.handleMove),this.map.on("moveend",this.handleMoveEnd),this.handleStyleChange(),this.el}onRemove(){this.map&&(this.map.off("styledata",this.handleStyleChange),this.map.off("movestart",this.handleMoveStart),this.map.off("move",this.handleMove),this.map.off("moveend",this.handleMoveEnd),this.map.off("error",this.handleError),this.layer&&this.map.removeLayer(this.layer.id)),this.layer=void 0,this.map=void 0,this.core&&this.core.destroy(),this.core=void 0}};y();y();y();y();y();y();y();y();function Pe([o,e],[t,r]){let n=e-r,i=o-t;return(Math.atan2(i,n)+Math.PI*3)%(Math.PI*2)}y();y();function _s(o,e,t,r){let[n,i]=o,[s,a]=e,[l,c]=t,[d,u]=r;if(i===a&&n===s||c===u&&l===d)return null;let h=(d-l)*(a-i)-(u-c)*(s-n);if(h===0)return null;let v=((u-c)*(n-l)-(d-l)*(i-c))/h,f=((a-i)*(n-l)-(s-n)*(i-c))/h;if(v<0||v>1||f<0||f>1)return null;let M=i+v*(a-i);return[n+v*(s-n),M]}y();y();function Bs(o,e,t,r){r===void 0&&(r={});var n=Ui(o),i=Io(n[0]),s=Io(n[1]),a=Io(t),l=Fc(e,r.units),c=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a)),d=i+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(c)),u=sa(d),h=sa(c);return To([u,h],r.properties)}function ic(o,e,t,r){let n=Bs(o,t/1e3,r),i=Bs(e,t/1e3,r);return[n.geometry.coordinates,i.geometry.coordinates]}y();function un(o){let e=o*(180/Math.PI);return e=e%360,e>180?e-=360:e<-180&&(e+=360),Object.is(e,-0)?0:e}var um=111e3;function hm(o,e,t,r,n){return Math.max(o[0][0],o[1][0])>=e&&Math.min(o[0][0],o[1][0])<=t&&Math.max(o[0][1],o[1][1])>=r&&Math.min(o[0][1],o[1][1])<=n}function Pt(o,e,t=[],r=0){let n=o.geometry.coordinates,i=e.geometry.coordinates;if(t.length===0)return!0;let s=r/um,a=r/(um*Math.cos(n[1]*Math.PI/180)),l=Math.min(n[1],i[1])-s,c=Math.max(n[1],i[1])+s,d=Math.min(n[0],i[0])-a,u=Math.max(n[0],i[0])+a;if(r>0){let h=un(Pe(n,i)-Math.PI/2),v=un(Pe(n,i)+Math.PI/2),f=ic(n,i,r,h),M=ic(n,i,r,v);for(let p of t)if(hm(p,d,u,l,c)&&(_s(f[0],f[1],p[0],p[1])||_s(M[0],M[1],p[0],p[1])))return!1}else for(let h of t)if(hm(h,d,u,l,c)&&_s(n,i,h[0],h[1]))return!1;return!0}y();function pm(o,e=.5){let[t,r]=o,n=(t.x+r.x)/2,i=(t.y+r.y)/2,s=r.x-t.x,l=-(r.y-t.y),c=s,d=Math.sqrt(l*l+c*c),u=l/d,h=c/d,v={x:n+u*e,y:i+h*e},f={x:n-u*e,y:i-h*e};return[v,f]}y();function ne(o){return o.properties.floor??o.properties.map}y();var mm=111e3,Iv=63710088e-1/1e3,Ov=256,ao=0,sc=4,ac=8,lr=12,fm=new WeakMap;function Lv(o){let e=o.length,t=1/0,r=1/0,n=-1/0,i=-1/0;for(let x=0;x<e;x++){let S=o[x][0],C=o[x][1];S[0]<t&&(t=S[0]),C[0]<t&&(t=C[0]),S[0]>n&&(n=S[0]),C[0]>n&&(n=C[0]),S[1]<r&&(r=S[1]),C[1]<r&&(r=C[1]),S[1]>i&&(i=S[1]),C[1]>i&&(i=C[1])}let s=Math.max(1,Math.min(Ov,Math.ceil(Math.sqrt(e)))),a=s,l=s,c=n-t,d=i-r,u=c/a||d/a||1e-9,h=d/l||c/l||1e-9,v=(x,S,C,D)=>{let w=Math.floor((x-S)/C);return w<0?0:w>=D?D-1:w},f=a*l,M=new Int32Array(f+1),p=(x,S)=>{let C=o[x][0],D=o[x][1],w=v(Math.min(C[0],D[0]),t,u,a),P=v(Math.max(C[0],D[0]),t,u,a),T=v(Math.min(C[1],D[1]),r,h,l),I=v(Math.max(C[1],D[1]),r,h,l);for(let L=T;L<=I;L++)for(let A=w;A<=P;A++)S(L*a+A)};for(let x=0;x<e;x++)p(x,S=>M[S+1]++);for(let x=0;x<f;x++)M[x+1]+=M[x];let m=M.slice(),g=M.slice(0,f),b=new Int32Array(m[f]);for(let x=0;x<e;x++)p(x,S=>b[g[S]++]=x);return{edges:o,edgeCount:e,minX:t,minY:r,cellW:u,cellH:h,cols:a,rows:l,cellStart:m,cellEdges:b,cellStamp:new Uint32Array(f),edgeStamp:new Uint32Array(e),stamp:0}}function Av(o){let e=fm.get(o);return(!e||e.edgeCount!==o.length)&&(e=Lv(o),fm.set(o,e)),e}function Rv(o,e,t,r,n,i,s,a){if(e===r&&o===t||i===a&&n===s)return!1;let l=(s-n)*(r-e)-(a-i)*(t-o);if(l===0)return!1;let c=((a-i)*(o-n)-(s-n)*(e-i))/l,d=((r-e)*(o-n)-(t-o)*(e-i))/l;return!(c<0||c>1||d<0||d>1)}function lc(o,e,t){let r=e[t],n=e[t+1],i=e[t+2],s=e[t+3],a=e[lr],l=e[lr+1],c=e[lr+2],d=e[lr+3],{edges:u,cols:h,rows:v,cellW:f,cellH:M,minX:p,minY:m,cellStart:g,cellEdges:b,cellStamp:x,edgeStamp:S}=o,C=o.stamp,D=Math.ceil(Math.max(Math.abs(i-r)/f,Math.abs(s-n)/M)*2)+1;for(let w=0;w<=D;w++){let P=w/D,T=Math.floor((r+(i-r)*P-p)/f),I=Math.floor((n+(s-n)*P-m)/M);T=T<0?0:T>=h?h-1:T,I=I<0?0:I>=v?v-1:I;let L=I>0?I-1:0,A=I<v-1?I+1:I,F=T>0?T-1:0,k=T<h-1?T+1:T;for(let _=L;_<=A;_++)for(let j=F;j<=k;j++){let G=_*h+j;if(x[G]!==C){x[G]=C;for(let Z=g[G],se=g[G+1];Z<se;Z++){let xe=b[Z];if(S[xe]===C)continue;S[xe]=C;let oe=u[xe][0],ie=u[xe][1];if(!(Math.max(oe[0],ie[0])<a||Math.min(oe[0],ie[0])>l||Math.max(oe[1],ie[1])<c||Math.min(oe[1],ie[1])>d)&&Rv(r,n,i,s,oe[0],oe[1],ie[0],ie[1]))return!0}}}}return!1}var cc=o=>o%360*Math.PI/180,gm=o=>o%(2*Math.PI)*180/Math.PI;function Gs(o,e,t,r,n,i){let s=cc(t),a=cc(r),l=cc(i),c=n/Iv,d=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(l)),u=s+Math.atan2(Math.sin(l)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(d));o[e]=gm(u),o[e+1]=gm(d)}function ym(o=[]){if(o.length===0)return()=>!0;let e=Av(o),t=new Float64Array(16),r=()=>{++e.stamp===4294967295&&(e.cellStamp.fill(0),e.edgeStamp.fill(0),e.stamp=1)};return(n,i,s)=>{let a=n.geometry.coordinates,l=i.geometry.coordinates,c=s/mm,d=s/(mm*Math.cos(a[1]*Math.PI/180));if(t[lr]=Math.min(a[0],l[0])-d,t[lr+1]=Math.max(a[0],l[0])+d,t[lr+2]=Math.min(a[1],l[1])-c,t[lr+3]=Math.max(a[1],l[1])+c,r(),s>0){let u=Pe(a,l),h=un(u-Math.PI/2),v=un(u+Math.PI/2),f=s/1e3;return Gs(t,sc,a[0],a[1],f,h),Gs(t,sc+2,l[0],l[1],f,h),lc(e,t,sc)?!1:(Gs(t,ac,a[0],a[1],f,v),Gs(t,ac+2,l[0],l[1],f,v),r(),!lc(e,t,ac))}return t[ao]=a[0],t[ao+1]=a[1],t[ao+2]=l[0],t[ao+3]=l[1],!lc(e,t,ao)}}var ks=0,tt=class{origin;destination;distance;angle;pathWeight;weight;constructor({origin:e,destination:t,distance:r=0,angle:n=0,pathWeight:i=ks,multiplicativeDistanceWeightScaling:s=!0}){if(this.origin=e,this.destination=t,this.distance=r,this.angle=n,this.pathWeight=i,this.weight=i||ks,s?ne(e)===ne(t)&&(this.weight=(this.weight>=0?this.distance*this.weight:ks)+this.distance):ne(e)===ne(t)&&(this.weight=this.weight>=0?this.distance+this.weight:ks),isNaN(this.angle))throw new Error("Invalid angle: Expected a numeric value, but received NaN.")}};y();y();y();y();var Ns=class{#e=[];#n;constructor(e){this.#n=e}get size(){return this.#e.length}isEmpty(){return this.#e.length===0}peek(){return this.#e[0]}push(e){this.#e.push(e),this.#i(this.#e.length-1)}pop(){if(this.#e.length===0)return;let e=this.#e[0],t=this.#e.pop();return this.#e.length>0&&t!==void 0&&(this.#e[0]=t,this.#o(0)),e}#i(e){for(;e>0;){let t=e-1>>1;if(this.#n(this.#e[e],this.#e[t])>=0)break;this.#s(e,t),e=t}}#o(e){let t=this.#e.length;for(;;){let r=e*2+1,n=e*2+2,i=e;if(r<t&&this.#n(this.#e[r],this.#e[i])<0&&(i=r),n<t&&this.#n(this.#e[n],this.#e[i])<0&&(i=n),i===e)break;this.#s(e,i),e=i}}#s(e,t){[this.#e[e],this.#e[t]]=[this.#e[t],this.#e[e]]}};y();var zs=class{#e;#n;#i;#o;#s=0;#a=0;constructor(e=1024){let t=Math.max(16,e);this.#e=new Float64Array(t),this.#n=new Float64Array(t),this.#i=new Float64Array(t),this.#o=new Int32Array(t)}get size(){return this.#s}reset(){this.#s=0,this.#a=0}push(e,t,r){this.#s===this.#o.length&&this.#d();let n=this.#a++,i=this.#s++,s=this.#e,a=this.#i;for(;i>0;){let l=i-1>>1,c=s[l];if(c<t||c===t&&a[l]<n)break;this.#l(l,i),i=l}s[i]=t,a[i]=n,this.#n[i]=r,this.#o[i]=e}popInto(e){let t=this.#o[0];e[0]=this.#n[0];let r=--this.#s;if(r<=0)return t;let n=this.#e,i=this.#i,s=n[r],a=i[r],l=this.#n[r],c=this.#o[r],d=0,u=r>>1;for(;d<u;){let h=2*d+1,v=h+1;v<r&&(n[v]<n[h]||n[v]===n[h]&&i[v]<i[h])&&(h=v);let f=n[h];if(s<f||s===f&&a<i[h])break;this.#l(h,d),d=h}return n[d]=s,i[d]=a,this.#n[d]=l,this.#o[d]=c,t}#l(e,t){this.#e[t]=this.#e[e],this.#i[t]=this.#i[e],this.#n[t]=this.#n[e],this.#o[t]=this.#o[e]}#d(){let e=this.#o.length*2,t=new Float64Array(e);t.set(this.#e);let r=new Float64Array(e);r.set(this.#n);let n=new Float64Array(e);n.set(this.#i);let i=new Int32Array(e);i.set(this.#o),this.#e=t,this.#n=r,this.#i=n,this.#o=i}};y();function bm(o,e,t){return t.zone[o]===e||(t.extraZones.get(o)?.includes(e)??!1)}function dc(o,e,t){let{stamp:r,generation:n}=t;if(r[e]!==n)return 0;if(r[o]!==n)return t.cost[e];let{zoneCosts:i,zonePerEntry:s}=t,a=t.zone[e],l=s[a]&&bm(o,a,t)?0:i[a],c=t.extraZones.get(e);if(c)for(let d of c)s[d]&&bm(o,d,t)||(l+=i[d]);return l}var vm=Symbol("all-groups"),Us=class{#e;#n;#i=new WeakMap;#o;#s=0;constructor(e){this.#e=e,this.#o=new Uint32Array(e.nodeCount)}fill(e,t,r){let{lon:n,lat:i}=this.#e,{cost:s,stamp:a,generation:l,zone:c,extraZones:d,zoneCosts:u,zonePerEntry:h}=r,v=this.#o;d.clear(),u.length=0,h.length=0;for(let f=0;f<e.length;f++){let M=e[f],p=Math.max(0,M.cost);u.push(p),h.push(M.costAccumulation==="per-zone-entry");let m=M.geometry.geometry,g=m.type==="Polygon"?[m.coordinates]:m.coordinates,b=M[t]?M[t]:vm,x=m.bbox,S=g.length>1,C=S?this.#a():0;for(let D of g){let w=this.#l(D,b);for(let P=0;P<w.length;P++){let T=w[P];if(S){if(v[T]===C)continue;v[T]=C}if(!(x&&!(x[0]<=n[T]&&x[1]<=i[T]&&x[2]>=n[T]&&x[3]>=i[T]))){if(a[T]!==l)a[T]=l,s[T]=0,c[T]=f;else if(c[T]!==f){let I=d.get(T);I?I.includes(f)||I.push(f):d.set(T,[f])}s[T]+=p}}}}}#a(){return this.#s>=4294967294&&(this.#o.fill(0),this.#s=0),++this.#s}#l(e,t){let r=this.#i.get(e);r||(r=new Map,this.#i.set(e,r));let n=r.get(t);return n||(n=this.#d(e,t),r.set(t,n)),n}#d(e,t){let r=this.#f(t);if(!r||e.length===0||e[0].length===0)return new Int32Array(0);let n=e.map(Fv),i=1/0,s=1/0,a=-1/0,l=-1/0,c=n[0];for(let f=0;f<c.length;f+=2)c[f]<i&&(i=c[f]),c[f]>a&&(a=c[f]),c[f+1]<s&&(s=c[f+1]),c[f+1]>l&&(l=c[f+1]);let{lat:d}=this.#e,{indices:u,lon:h}=r,v=[];for(let f=_v(h,i);f<u.length&&h[f]<=a;f++){let M=u[f],p=d[M];if(p<s||p>l)continue;let m=h[f];if(!xm(n[0],m,p,!1))continue;let g=!1;for(let b=1;b<n.length&&!g;b++)xm(n[b],m,p,!0)&&(g=!0);g||v.push(M)}return Int32Array.from(v)}#f(e){if(!this.#n){let{nodeCount:t,lon:r,group:n}=this.#e,i=new Map,s=new Array(t);for(let a=0;a<t;a++){s[a]=a;let l=i.get(n[a]);l||i.set(n[a],l=[]),l.push(a)}i.set(vm,s),this.#n=new Map;for(let[a,l]of i){l.sort((u,h)=>r[u]-r[h]);let c=Int32Array.from(l),d=new Float64Array(c.length);for(let u=0;u<c.length;u++)d[u]=r[c[u]];this.#n.set(a,{indices:c,lon:d})}}return this.#n.get(e)}};function Fv(o){let e=o.length;e>0&&o[0][0]===o[e-1][0]&&o[0][1]===o[e-1][1]&&e--;let t=new Float64Array(e*2);for(let r=0;r<e;r++)t[r*2]=o[r][0],t[r*2+1]=o[r][1];return t}function xm(o,e,t,r){let n=o.length>>1,i=!1;for(let s=0,a=n-1;s<n;a=s++){let l=o[s*2],c=o[s*2+1],d=o[a*2],u=o[a*2+1];if(t*(l-d)+c*(d-e)+u*(e-l)===0&&(l-e)*(d-e)<=0&&(c-t)*(u-t)<=0)return!r;c>t!=u>t&&e<(d-l)*(t-c)/(u-c)+l&&(i=!i)}return i}function _v(o,e){let t=0,r=o.length;for(;t<r;){let n=t+r>>1;o[n]<e?t=n+1:r=n}return t}var lo=.4,Bv=10,Sm=Math.PI/180,Mm=1,uc=2,Hs=class{edges=Object.create(null);nodesById;nodesByGroup=new Map;#e;#n;constructor({nodes:e,groupBy:t,multiplicativeDistanceWeightScaling:r}){this.#e=t,this.#n=r??!0;let{features:n}=e;this.nodesById=Object.create(null),this.#i=this.#o(n,t,r)}#i;#o(e,t,r){let n=this.nodesById;for(let x=0;x<e.length;x++)n[e[x].properties.id]=e[x];let i=Object.keys(n),s=i.length,a=new Map,l=new Array(s),c=new Float64Array(s),d=new Float64Array(s);for(let x=0;x<s;x++){let S=n[i[x]];a.set(i[x],x),l[x]=S,c[x]=S.geometry.coordinates[0],d[x]=S.geometry.coordinates[1]}let u=0;for(let x=0;x<s;x++){let S=l[x].properties,C=S.neighbors,D=0;for(let w=0;w<C.length;w++)a.has(C[w].id)&&D++;D!==C.length&&(S.neighbors=C.filter(({id:w})=>a.has(w))),u+=D}for(let x=0;x<e.length;x++){let S=e[x],C=t==="default"?t:S.properties[t],D=this.nodesByGroup.get(C);D||this.nodesByGroup.set(C,D=[]),D.push(S)}let h=new Int32Array(s+1),v=new Int32Array(u),f=new Int32Array(u),M=new Uint8Array(u),p=new Uint8Array(u),m=new Set,g=new Array(u),b=0;for(let x=0;x<s;x++){let S=l[x],C=S.properties.neighbors,D=new Array(C.length);h[x]=b;for(let w=0;w<C.length;w++){let{id:P,weight:T,sameStop:I}=C[w],L=a.get(P),A=l[L],F=new tt({origin:S,destination:A,pathWeight:T,distance:Qe(S.geometry.coordinates,A.geometry.coordinates),angle:Pe(S.geometry.coordinates,A.geometry.coordinates),multiplicativeDistanceWeightScaling:r});D[w]=F,v[b]=x,f[b]=L,M[b]=ne(S)!==ne(A)?1:0,I===!0&&(p[b]=1,m.add(F)),g[b]=F,b++}this.edges[S.properties.id]=D}return h[s]=b,{nodeCount:s,indexById:a,nodes:l,lon:c,lat:d,edgeStart:h,edgeOrigin:v,edgeDestination:f,edgeCrossesFloor:M,edgeSameStop:p,sameStopEdges:m,edgeRefs:g,generation:0,scratch:{costSoFar:new Float64Array(s),cameFrom:new Int32Array(s),stamp:new Uint32Array(s),heuristic:new Float64Array(s),heuristicStamp:new Uint32Array(s),flags:new Uint8Array(s),frontier:new zs(1024),popped:new Float64Array(1),zoneTarget:{cost:new Float64Array(s),stamp:new Uint32Array(s),generation:0,zone:new Int32Array(s),extraZones:new Map,zoneCosts:[],zonePerEntry:[]}},flagSetCache:new WeakMap}}#s(){return this.#i.scratch}#a(e){let t=this.#i,r=t.flagSetCache.get(e);if(!r||r.setSize!==e.size){let n=new Uint8Array(t.nodeCount);for(let i of e){let s=t.indexById.get(i);s!==void 0&&(n[s]=1)}r={array:n,setSize:e.size},t.flagSetCache.set(e,r)}return r.array}getShortestEuclideanDistance(e,t){return t.reduce((r,n)=>{let i=Wu(e.geometry.coordinates,n.geometry.coordinates);return Math.min(r,i)},Number.MAX_VALUE)}hasLineOfSight=(e,t,r=[],n=lo)=>Pt({type:"Feature",properties:{id:"origin",neighbors:[]},geometry:{type:"Point",coordinates:e}},{type:"Feature",properties:{id:"destination",neighbors:[]},geometry:{type:"Point",coordinates:t}},r,n)===!0;dijkstraFindWithinTravelDistance(e,t,r,n,i,s,a,l){let c=this.nodesById[e];if(!c)return[];let d=new Set(r),u=new Ns((C,D)=>C.distance-D.distance),h=new Map,v=[],f=l!==void 0&&l.length>0;f&&this.#u(l);let{zoneTarget:M}=this.#s(),p=this.#i.indexById,m=this.#i.sameStopEdges,g=new Set,b=0,x=(C,D)=>{let w=C.properties.id;if(g.has(w))return;let P=m.size>0&&(this.edges[w]??[]).some(T=>m.has(T)&&g.has(T.destination.properties.id));v.push({feature:C,distance:D}),g.add(w),P||b++},S=()=>{if(m.size!==0)for(let C=0;C<v.length;C++){let{feature:D,distance:w}=v[C];for(let P of this.edges[D.properties.id]??[]){let T=P.destination;m.has(P)&&d.has(T.properties.id)&&x(T,w)}}};for(u.push({node:c,distance:0,geometricDistance:0}),h.set(c.properties.id,0);!u.isEmpty()&&!(b>=s);){let C=u.pop();if(!C)break;let D=C.node,w=C.distance,P=C.geometricDistance;if(!(w>(h.get(D.properties.id)??1/0))){D.properties.id!=null&&d.has(D.properties.id?.toString())&&(i?this.hasLineOfSight(c.geometry.coordinates,D.geometry.coordinates,n)&&x(D,w):x(D,w));for(let T of this.edges[D.properties.id]){let I=T.destination,L=ne(T.origin)!==ne(T.destination),A=a?.get(T)??T.weight,F=L?Math.max(A,Bv):a?.has(T)?A:T.distance,k=w+F+(f&&!this.#i.sameStopEdges.has(T)?dc(p.get(D.properties.id),p.get(I.properties.id),M):0),_=P+F;if(k===1/0||_>t)continue;let j=h.get(I.properties.id);j!==void 0&&k>=j||(h.set(I.properties.id,k),u.push({node:I,distance:k,geometricDistance:_}))}}}return S(),v}aStar({originIds:e,destinationNodeIds:t,disabledConnectionNodeIds:r,zones:n,overrideEdgeWeights:i,disabledNodeIds:s,outdoorNodeIds:a,indoorPathWeight:l,outdoorPathWeight:c,outdoorPathWeightMultiplier:d}){let u=this.#t(e),h=this.#t(t);if(u.length===0||h.length===0)return[];let v=this.#i,f=this.#s(),{edgeStart:M,edgeDestination:p,edgeCrossesFloor:m,edgeSameStop:g,edgeRefs:b}=v,{costSoFar:x,cameFrom:S,stamp:C,heuristic:D,heuristicStamp:w,flags:P,frontier:T}=f,I=this.#l();T.reset();let L=H=>v.indexById.get(H.properties.id),A=h.map(L),F=[];if(r)for(let H of r){let fe=v.indexById.get(H);fe!==void 0&&F.push(fe)}for(let H of A)P[H]|=Mm;for(let H of F)P[H]|=uc;let k=s&&s.size>0?this.#a(s):void 0,_=this.#n&&d!==void 0&&l!==void 0&&a!==void 0&&a.size>0,j=_?this.#a(a):void 0,G=_?(l+1)*d/((c??l)+1):1,Z=i&&i.size>0?i:void 0,se=n.length>0;se&&this.#u(n,I);let{zoneTarget:xe}=f,oe=h.length,ie=new Float64Array(oe),rt=new Float64Array(oe),ze=f.popped;for(let H=0;H<oe;H++)ie[H]=h[H].geometry.coordinates[0],rt[H]=h[H].geometry.coordinates[1];try{for(let H of u){let fe=L(H);C[fe]=I,x[fe]=0,S[fe]=-1,this.#d(fe,I,ie,rt),T.push(fe,D[fe],0)}for(;T.size>0;){let H=T.popInto(ze),fe=ze[0],Ye=P[H];if(Ye&Mm)return this.#f(H);let pt=x[H];if(fe>pt||k!==void 0&&k[H]===1)continue;let _e=(Ye&uc)!==0,$e=M[H+1];for(let Oe=M[H];Oe<$e;Oe++){let te=p[Oe],Ue=m[Oe]===1;if(_e&&(Ue||(P[te]&uc)!==0))continue;let Le=b[Oe],st=Z!==void 0?Z.get(Le):void 0,Ae=st??Le.weight;j!==void 0&&st===void 0&&!Ue&&j[H]===1&&j[te]===1&&(Ae*=G);let ce=se&&g[Oe]!==1?dc(H,te,xe):0,He=pt+Ae+ce;He!==1/0&&(C[te]!==I||He<x[te])&&(C[te]=I,x[te]=He,S[te]=Oe,w[te]!==I&&this.#d(te,I,ie,rt),T.push(te,He+D[te],He))}}return[]}finally{for(let H of A)P[H]=0;for(let H of F)P[H]=0}}#l(){let e=this.#i;if(e.generation>=4294967294){let t=this.#s();t.stamp.fill(0),t.heuristicStamp.fill(0),t.zoneTarget.stamp.fill(0),e.generation=0}return++e.generation}#d(e,t,r,n){let{lon:i,lat:s}=this.#i,{heuristic:a,heuristicStamp:l}=this.#s(),c=i[e],d=s[e],u=Number.MAX_VALUE;for(let h=0;h<r.length;h++){let v=(r[h]-c)*Sm,f=(n[h]-d)*Sm,M=Math.sqrt(v*v+f*f)*yt;u=Math.min(u,M)}a[e]=u,l[e]=t}#f(e){let{edgeRefs:t,edgeOrigin:r}=this.#i,{cameFrom:n}=this.#s(),i=[],s=n[e];for(;s!==-1;)i.push(t[s]),s=n[r[s]];return i.reverse()}#t(e){return e.map(t=>this.nodesById[t]).filter(Boolean)}#u(e,t=this.#l()){let r=this.#i;r.zoneIndex||(r.zoneIndex=new Us({nodeCount:r.nodeCount,lon:r.lon,lat:r.lat,group:r.nodes.map(i=>i.properties[this.#e])}));let n=this.#s();return n.zoneTarget.generation=t,r.zoneIndex.fill(e,this.#e,n.zoneTarget),t}};y();function Cm(o,e,t,r=lo){if(o.length<3)return o;let n=1e-4,i=o.length,s=new Uint8Array(i),a=new Int32Array(i+1);a[i]=i;for(let f=i-1;f>=0;f--)s[f]=o[f].origin.properties.preventSmoothing?1:0,a[f]=s[f]?f:a[f+1];let l=o[i-1].destination,c=ym(e),d=new Array(i+1).fill(null).map(()=>({cost:1/0,prev:-1}));d[0]={cost:0,prev:-1};for(let f=0;f<i;f++){let M=!0;if(d[f].cost===1/0)continue;let p=o[f].origin,m=a[f+1];for(let g=f+1;g<=m;g++){let b=g===i?l:o[g].origin,x=Qe(p.geometry.coordinates,b.geometry.coordinates);if(x<.01)continue;let C=(g-f-1)*n,D=d[f].cost+x-C;if(D>=d[g].cost)continue;let w=g===f+1&&g<i&&s[g]===1,P=g===f+1&&s[f]===1;!w&&!P&&!c(p,b,r)||(d[g].cost=D,d[g].prev=f,M=!1)}M&&d[f+1].cost===1/0&&(d[f+1].cost=d[f].cost,d[f+1].prev=f)}let u=[],h=i;for(;h!==-1;)u.unshift(h),h=d[h].prev===-1?h-1:d[h].prev;let v=[];for(let f=0;f<u.length-1;f++){let M=u[f],p=u[f+1],m=o[M].origin,g=p===i?l:o[p].origin;v.push(new tt({origin:m,destination:g,distance:Qe(m.geometry.coordinates,g.geometry.coordinates),angle:Pe(m.geometry.coordinates,g.geometry.coordinates),multiplicativeDistanceWeightScaling:t}))}return v}y();var Dm=Cn(Ki());y();var wm=Ac("Navigator");function co(o,e,t){if(o==null||o[e]==null)return!1;let r=1<<t;return(o[e]&r)!==0}y();var Gv=.5;function Em(o,e,t,r,n,i){if(!o?.geoJSON?.geometry?.coordinates)return null;let[s,a]=pm(r,Gv),l=s,c=a;if(n){let f=Math.sqrt(Math.pow(s.x-n.x,2)+Math.pow(s.y-n.y,2));Math.sqrt(Math.pow(a.x-n.x,2)+Math.pow(a.y-n.y,2))<f&&(l=a,c=s)}let d=i(l.x,l.y),u=i(c.x,c.y),h={type:"Feature",geometry:{type:"Point",coordinates:[d.lon,d.lat]},properties:{id:`${e}_buffer_entry`,map:t,neighbors:[],preventSmoothing:!0}},v={type:"Feature",geometry:{type:"Point",coordinates:[u.lon,u.lat]},properties:{id:`${e}_buffer_exit`,map:t,neighbors:[],preventSmoothing:!0}};return{entryNode:h,exitNode:v,entryMeters:l,exitMeters:c}}function Tm(o,e,t,r){let n=[o[0].origin];for(let w=0;w<o.length;w++)n.push(o[w].destination);let i=new Map,s=new Map;for(let w=0;w<n.length;w++)i.set(n[w].properties.id,n[w]),s.set(w,n[w]);let a=n[0].geometry.coordinates[1],{toCartesian:l,toGeographic:c}=Mi(a),d=n.map((w,P)=>{let T={x:0,y:0,nodeId:w.properties.id,originalIndex:P};return l(w.geometry.coordinates,T),T}),u=new Set,h=new Map,v=new Set;for(let w=0;w<n.length;w++){let P=e(n[w].properties.id);if(P&&(u.add(w),h.set(w,P)),w<n.length-1){let T=ne(n[w]),I=ne(n[w+1]);T!==I&&(v.add(w),v.add(w+1),w>0&&v.add(w-1))}}if(o.length<3&&u.size===0)return o;let f=o.length>=3?(0,Dm.default)(d,.7,!1):d,M=new Set;for(let w=0;w<f.length;w++)M.add(f[w].originalIndex);let p=[];for(let w of u)M.has(w)||p.push(w);let m=f.slice(),g=.25;for(let w of v){if(M.has(w))continue;let P=s.get(w);if(!P)continue;let T=-1;for(let I=0;I<m.length-1;I++)if(m[I].originalIndex<w&&m[I+1].originalIndex>w){T=I+1;break}if(T!==-1){let I={x:0,y:0,nodeId:P.properties.id,originalIndex:w};l(P.geometry.coordinates,I),m.splice(T,0,I)}}for(let w of p){let P=s.get(w);if(!P)continue;let T=-1;for(let I=0;I<m.length-1;I++)if(m[I].originalIndex<w&&m[I+1].originalIndex>w){T=I+1;break}if(T!==-1){let I={x:0,y:0,nodeId:P.properties.id,originalIndex:w};l(P.geometry.coordinates,I);let L=rl(I,m[T-1]),A=rl(I,m[T]);L<g?m[T-1]=I:A<g?m[T]=I:m.splice(T,0,I)}}let b=[],x={x:0,y:0},S={x:0,y:0},C=new Map;for(let w=0;w<m.length;w++)C.set(m[w].originalIndex,w);for(let w of u){let P=s.get(w);if(!P)continue;let T=h.get(w);if(!T)continue;let I=C.get(w)??-1;if(I!==-1){let L;I>0&&(L={x:m[I-1].x,y:m[I-1].y});let A=T.geoJSON.geometry.coordinates;l(A[0],x),l(A[1],S);let F=[x,S],k=P.properties.id,_=ne(P)||"test-floor",j=Em(T,k,_,F,L,c);if(j){let G={x:j.entryMeters.x,y:j.entryMeters.y,nodeId:j.entryNode.properties.id,originalIndex:w-.5},Z={x:j.exitMeters.x,y:j.exitMeters.y,nodeId:j.exitNode.properties.id,originalIndex:w+.5};i.set(j.entryNode.properties.id,j.entryNode),i.set(j.exitNode.properties.id,j.exitNode),b.push(G,Z)}}}if(m.push(...b),m.sort((w,P)=>w.originalIndex-P.originalIndex),r&&m.length>=3)for(let w=0;w<m.length-1;w++){let P=m[w];if(P.nodeId.endsWith("_buffer_exit")){let T=m[m.length-1];if(w<m.length-2){let I=!1;for(let L=w+1;L<m.length-1;L++)if(m[L].nodeId.endsWith("_buffer_entry")||m[L].nodeId.endsWith("_buffer_exit")){I=!0;break}if(!I){let L=i.get(P.nodeId),A=i.get(T.nodeId);if(L&&A){if(ne(L)!==ne(A))continue;if(Pt(L,A,r,.1)){let F=m.length-w-2;m.splice(w+1,F)}}}}}}if(r&&m.length>=3){let w=m[0],P=-1;for(let T=1;T<m.length;T++)if(m[T].nodeId.endsWith("_buffer_entry")){P=T;break}if(P>1){let T=!1;for(let I=1;I<P;I++)if(m[I].nodeId.endsWith("_buffer_entry")||m[I].nodeId.endsWith("_buffer_exit")){T=!0;break}if(!T){let I=m[P],L=i.get(w.nodeId),A=i.get(I.nodeId);if(L&&A&&ne(L)===ne(A)){if(Pt(L,A,r,.1)){let F=P-1;m.splice(1,F)}}}}}let D=[];for(let w=0;w<m.length-1;w++){let P=m[w],T=m[w+1],I=i.get(P.nodeId),L=i.get(T.nodeId);I&&L?D.push(new tt({origin:I,destination:L,distance:Qe(I.geometry.coordinates,L.geometry.coordinates),angle:Pe(I.geometry.coordinates,L.geometry.coordinates),multiplicativeDistanceWeightScaling:t})):wm.warn(`Origin or destination node not found for point ${P.nodeId} or ${T.nodeId}`)}return D}function Ne(o,e){return new tt({origin:o,destination:e,distance:Qe(o.geometry.coordinates,e.geometry.coordinates),angle:Pe(o.geometry.coordinates,e.geometry.coordinates)})}function Pm(o,e,t,r=!0){if(o.length<3)return o;let n=new Set;for(let a=0;a<o.length;a++)if(o[a].origin.properties.preventSmoothing){if(n.add(a),r){for(let l=a-1;l>=0;l--)if(!o[l].origin.properties.preventSmoothing){n.add(l);break}}if(r){for(let l=a+1;l<o.length;l++)if(!o[l].origin.properties.preventSmoothing){n.add(l);break}}}if(o.length>0&&o[o.length-1].destination.properties.preventSmoothing&&(n.add(o.length-1),r)){for(let a=o.length-2;a>=0;a--)if(!o[a].origin.properties.preventSmoothing){n.add(a);break}}let i=[],s=0;for(let a=1;a<o.length;a++){let l=a===o.length-1,c=n.has(a),d=l?.05:.7,u=Pt(o[s].origin,o[a].origin,e,d),h=o[a].origin.properties.preventSmoothing,v=a-1;if(c){s!==a&&(u?(i.push(Ne(o[s].origin,o[a].origin)),s=a):(s!==v&&(i.push(Ne(o[s].origin,o[v].origin)),s=v),s!==a&&(i.push(Ne(o[s].origin,o[a].origin)),s=a))),l&&i.push(Ne(o[a].origin,o[a].destination));continue}if(h)u?(i.push(Ne(o[s].origin,o[a].origin)),s=a):s!==v&&(i.push(Ne(o[s].origin,o[v].origin)),s=v),i.push(Ne(o[s].origin,o[a].origin)),s=a,l&&i.push(Ne(o[a].origin,o[a].destination));else if(u)l&&(Pt(o[s].origin,o[a].destination,e,.7)?i.push(Ne(o[s].origin,o[a].destination)):(i.push(Ne(o[s].origin,o[a].origin)),i.push(Ne(o[a].origin,o[a].destination))),s=a);else{if(s===v){l&&(i.push(Ne(o[s].origin,o[a].origin)),i.push(Ne(o[a].origin,o[a].destination)));continue}i.push(Ne(o[s].origin,o[v].origin)),s=v,l&&(i.push(Ne(o[s].origin,o[a].origin)),i.push(Ne(o[a].origin,o[a].destination)))}}if(!1){let a=i[i.length-1];window.__DEBUG_PATH.finalSteps.push({nodeId:a.destination.properties.id,coordinate:a.destination.geometry.coordinates,floorId:ne(a.destination)})}return i}y();function ut(o,e,t){return new tt({origin:o,destination:e,distance:Qe(o.geometry.coordinates,e.geometry.coordinates),angle:Pe(o.geometry.coordinates,e.geometry.coordinates),multiplicativeDistanceWeightScaling:t})}function Im(o,e,t=.2,r={},n){if(o.length<3)return o;let i=l=>"outdoors"in r&&co(l?.properties?.flags??[],r.outdoors.index,r.outdoors.bit)||!!l?.properties?.preventSmoothing,s=[o[0]],a=1;for(let l=a+1;l<o.length;l++){let c=l===o.length-1,d=o[a].origin,u=o[l].origin,h=Pt(d,u,e,t),v=i(u),f=l-1;if(v)h?(s.push(ut(d,u,n)),a=l):(a!==f&&(s.push(ut(o[a].origin,o[f].origin,n)),a=f),s.push(ut(o[a].origin,u,n)),a=l),c&&s.push(ut(u,o[l].destination,n));else if(h)c&&(!(ne(u)!==ne(o[l].destination))&&Pt(d,o[l].destination,e,t)?s.push(ut(d,o[l].destination,n)):(s.push(ut(d,u,n)),s.push(ut(u,o[l].destination,n))),a=l);else{if(a===f){c&&(s.push(ut(d,u,n)),s.push(ut(u,o[l].destination,n)));continue}s.push(ut(o[a].origin,o[f].origin,n)),a=f,c&&(s.push(ut(o[a].origin,u,n)),s.push(ut(u,o[l].destination,n)))}}return s}y();var Om=Cn(Ki());function Lm(o,e){let t=new Set;if(o.length<2)return t;let r=[o[0].origin];for(let f=0;f<o.length;f++)r.push(o[f].destination);let n=r[0].geometry.coordinates[1],{toCartesian:i}=Mi(n),s=e;if(!s)return t;let a=r.map((f,M)=>{let p={x:0,y:0,nodeId:f.properties.id,originalIndex:M};return i(f.geometry.coordinates,p),p}),l=new Set,c=new Set;for(let f=0;f<a.length;f++)s(a[f].nodeId)&&(l.add(f),c.add(a[f].nodeId));if(l.size===0)return t;let d=a.length>=3?(0,Om.default)(a,.7,!1):a,u=new Map;for(let f=0;f<d.length;f++)u.set(d[f].originalIndex,f);let h=new Set;for(let f of l){let M=u.get(f);if(M!==void 0){if(M>0){let p=d[M-1].nodeId;h.add(p)}if(M<d.length-1){let p=d[M+1].nodeId;h.add(p)}}else{let p,m;for(let g=0;g<d.length-1;g++){let b=d[g].originalIndex,x=d[g+1].originalIndex;if(b<f&&f<x){p=d[g].nodeId,m=d[g+1].nodeId;break}}p&&h.add(p),m&&h.add(m)}}let v=0;for(let f of o)h.has(f.origin.properties.id)&&(f.origin.properties.preventSmoothing||(f.origin.properties.preventSmoothing=!0,t.add(f.origin.properties.id))),h.has(f.destination.properties.id)&&(f.destination.properties.preventSmoothing||(f.destination.properties.preventSmoothing=!0,t.add(f.destination.properties.id))),v++;return t}y();y();var hn={accessible:"accessible",outdoors:"outdoors",public:"public"};y();y();function ho(o,e,t=[]){let r={...o};for(let[n,i]of Object.entries(e))if(i!==void 0)if(n in r){let s=n;if(Array.isArray(i)&&i.length>0){let a=kv(i[0],t);if(a){let l=r[s];if(!Array.isArray(l))throw new Error(`Expected array at ${n}, got ${typeof l}`);let c=new Map(i.map(h=>[Am(h,a),h])),u=l.map(h=>{let v=c.get(Am(h,a));return v?ho(h,v,t):h});r[s]=u}else r[s]=i}else{let a=r[s];typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null?Object.keys(i).length===0?r[s]=i:r[s]=ho(a,i,t):r[n]=i}}else r[n]=i;return r}function kv(o,e){function t(r){if(typeof r!="object"||r===null)return null;for(let n of e)if(n in r&&typeof r[n]<"u")return[n];if(Array.isArray(r))return null;for(let[n,i]of Object.entries(r)){let s=t(i);if(s)return[n,...s]}return null}return t(o)}function Am(o,e){return e.reduce((t,r)=>{if(t&&typeof t=="object")return t[r]},o)}y();var Nv=o=>{if(o==="space"||o==="obstruction"||o==="entrance")return{}},zv=/\.json|\.geojson$/,Ws=(o,e,t)=>{let r=o[e];if(typeof r!="object"||Object.keys(r).length===0)return Nv(e);let n={};for(let[i,s]of Object.entries(r)){let a=i.replace(zv,"");n[a]=JSON.parse(t(s))}return n},Uv=["floorstack.json","styles.json","shapes.json","mapstack.json","floor.geojson","tileset.json","location.json","category.json","navigationFlags.json","annotation-symbols.json"],Hv=Uv,Wv=["annotation","textAreas","enterprise","floorImages","shapeInstances","modelInstances","window","area","facade"],Vv=Wv,jv=o=>{let e=new TextDecoder("utf-8"),t=e.decode.bind(e),r={"manifest.geojson":JSON.parse(t(o["manifest.geojson"])),"mapstack.geojson":JSON.parse(t(o["mapstack.geojson"])),"map.geojson":JSON.parse(t(o["map.geojson"])),"node.geojson":JSON.parse(t(o["node.geojson"])),"connection.json":JSON.parse(t(o["connection.json"])),space:Ws(o,"space",t),obstruction:Ws(o,"obstruction",t),entrance:Ws(o,"entrance",t)};for(let n of Hv)o[n]&&(r[n]=JSON.parse(t(o[n])));for(let n of Vv)o[n]&&(r[n]=Ws(o,n,t));return r};y();y();y();var po=["agriculture","airport","casino","city-district","convention-center","entertainment","event-centre","first-responder-building","government-building","grocery-store","healthcare","higher-education","hotel","library","manufacturing","medical-centre","mixed-use","multifamily","museum","office-building","oil-and-energy","other","parking-facility","religious-institution","resort","retail-store","schools-k-12","shopping-mall","stadium-or-arena","storage-facility","theme-park","transit","transportation-hub","warehousing"],Zv=[...po,"unknown"],hc=Object.freeze(Object.fromEntries([...po,"unknown"].map(o=>[o,o])));y();var mo=["reference-point","checkpoint","checkpoint-passport","parent"],Xv=[...mo,"unknown"],Yv=Object.freeze(Object.fromEntries([...mo,"unknown"].map(o=>[o,o])));var fo=["closed-temporarily","new","pop-up","coming-soon","relocated"],$v=[...fo,"unknown"],qv=Object.freeze(Object.fromEntries([...fo,"unknown"].map(o=>[o,o])));y();var go=["left","center","right"],Jv=[...go,"unknown"],Kv=Object.freeze(Object.fromEntries([...go,"unknown"].map(o=>[o,o])));y();var yo=["near","center"],Qv=[...yo,"unknown"],e0=Object.freeze(Object.fromEntries([...yo,"unknown"].map(o=>[o,o])));y();var bo=["top","side"],t0=[...bo,"unknown"],r0=Object.freeze(Object.fromEntries([...bo,"unknown"].map(o=>[o,o])));var vo=["inside","outside","both"],n0=[...vo,"unknown"],o0=Object.freeze(Object.fromEntries([...vo,"unknown"].map(o=>[o,o])));y();var Vs=["elevator","escalator","travelator","stairs","door","ramp","ladder"],gA=[...Vs,"unknown"],pc=Object.freeze(Object.fromEntries([...Vs,"unknown"].map(o=>[o,o])));y();var js=["room","hallway","wall","object","poi","area","window"],vA=[...js,"unknown"],xA=Object.freeze(Object.fromEntries([...js,"unknown"].map(o=>[o,o])));y();y();var Zs=class{_value;constructor(e){this._value=e}[Symbol.iterator](){return this}next(){if(this._value==null)return{done:!0,value:void 0};let e=this._value;return this._value=null,{done:!1,value:e}}},Xs=class{_tag="Some";_value;constructor(e){this._value=e}get value(){return this._value}isSome(){return!0}isSomeAnd(e){return e(this.value)}isNone(){return!1}equals(e){return e.isSome()&&e.value===this.value}expect(e){return this.value}unwrap(){return this.value}unwrapOr(e){return this.value}unwrapOrElse(e){return this.value}inspect(e){return e(this.value),this}inspectNone(e){return this}map(e){return Rm(e(this.value))}mapAsync(e){return e(this.value).then(t=>Rm(t))}mapOr(e,t){return this.map(e).unwrapOr(t)}mapOrAsync(e,t){return this.mapAsync(e).then(r=>r.unwrapOr(t))}mapOrElse(e,t){return this.map(e).unwrapOrElse(t)}mapOrElseAsync(e,t){return this.mapAsync(e).then(r=>r.unwrapOrElse(t))}and(e){return e}andThen(e){return e(this.value)}andThenAsync(e){return e(this.value)}filter(e){return e(this.value)?this:cr()}or(e){return this}orElse(e){return this}xor(e){return e.isSome()?cr():this}toString(){return`Some(${this.value})`}okOr(e){return xt(this.value)}okOrElse(e){return xt(this.value)}iter(){return new Zs(this.value)}[Symbol.iterator](){return this.iter()}zip(e){return e.isSome()?pn([this.value,e.value]):cr()}zipWith(e,t){return e.isSome()?pn(t(this.value,e.value)):cr()}get[Symbol.toStringTag](){return"Some"}},Ys=class{_tag="None";get value(){return null}isSome(){return!1}isSomeAnd(e){return!1}isNone(){return!0}equals(e){return e.isNone()}expect(e){throw new Error(e)}unwrap(){throw new Error("Tried to unwrap a None value!")}unwrapOr(e){return e}unwrapOrElse(e){return e()}inspect(e){return this}inspectNone(e){return e(),this}map(e){return this}mapAsync(e){return Promise.resolve(this)}mapOr(e,t){return t}mapOrAsync(e,t){return Promise.resolve(t)}mapOrElse(e,t){return t()}mapOrElseAsync(e,t){return t()}and(e){return this}andThen(e){return this}andThenAsync(e){return Promise.resolve(this)}filter(e){return this}or(e){return e}orElse(e){return e()}xor(e){return e}toString(){return"None"}okOr(e){return dr(e)}okOrElse(e){return dr(e())}iter(){return new Zs(null)}[Symbol.iterator](){return this.iter()}zip(e){return this}zipWith(e,t){return this}get[Symbol.toStringTag](){return"None"}},pn=o=>new Xs(o),cr=()=>new Ys,Rm=o=>o instanceof Xs||o instanceof Ys?o:o==null?cr():pn(o);var $s=class{_value;constructor(e){this._value=e}[Symbol.iterator](){return this}next(){if(this._value==null)return{done:!0,value:void 0};let e=this._value;return this._value=null,{done:!1,value:e}}},mc=class{_tag="Ok";_value;constructor(e){this._value=e}get value(){return this._value}get error(){return null}isOk(){return!0}isOkAnd(e){return e(this.value)}isErr(){return!1}isErrAnd(e){return!1}ok(){return pn(this.value)}err(){return cr()}expect(e){return this.value}expectErr(e){throw new Error(e)}unwrap(){return this.value}unwrapOr(e){return this.value}unwrapOrElse(e){return this.value}inspect(e){return e(this.value),this}inspectErr(){return this}map(e){return xt(e(this.value))}async mapAsync(e){return e(this.value).then(xt)}mapOr(e,t){return e(this.value)}async mapOrAsync(e,t){return e(this.value)}mapOrElse(e,t){return e(this.value)}async mapOrElseAsync(e,t){return e(this.value)}mapErr(e){return this}iter(){return new $s(this.value)}[Symbol.iterator](){return this.iter()}and(e){return e}andThen(e){return e(this.value)}or(e){return this}orElse(e){return this}async andThenAsync(e){return e(this.value)}toString(){return`Ok(${this.value})`}get[Symbol.toStringTag](){return"Ok"}},fc=class o{_tag="Err";_error;constructor(e){this._error=e}get value(){return null}get error(){return this._error}isOk(){return!1}isOkAnd(e){return!1}isErr(){return!0}isErrAnd(e){return e(this.error)}ok(){return cr()}err(){return pn(this.error)}expect(e){throw new Error(e)}expectErr(e){return this.error}unwrap(){throw this.error}unwrapOr(e){return e}unwrapOrElse(e){return e()}inspect(){return this}inspectErr(e){return e(this.error),this}map(e){return this}iter(){return new $s(null)}[Symbol.iterator](){return this.iter()}async mapAsync(e){return this}mapOr(e,t){return t}async mapOrAsync(e,t){return t}mapOrElse(e,t){return t()}async mapOrElseAsync(e,t){return t()}mapErr(e){return new o(e(this.error))}and(e){return this}andThen(e){return this}async andThenAsync(e){return this}or(e){return e}orElse(e){return e(this.error)}toString(){return`Err(${this.error})`}get[Symbol.toStringTag](){return"Err"}},xt=o=>new mc(o),dr=o=>new fc(o);y();var it=Uint8Array,mn=Uint16Array,i0=Int32Array,Fm=new it([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),_m=new it([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),s0=new it([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Bm=function(o,e){for(var t=new mn(31),r=0;r<31;++r)t[r]=e+=1<<o[r-1];for(var n=new i0(t[30]),r=1;r<30;++r)for(var i=t[r];i<t[r+1];++i)n[i]=i-t[r]<<5|r;return{b:t,r:n}},Gm=Bm(Fm,2),km=Gm.b,a0=Gm.r;km[28]=258,a0[258]=28;var Nm=Bm(_m,0),l0=Nm.b,IA=Nm.r,vc=new mn(32768);for(ee=0;ee<32768;++ee)kt=(ee&43690)>>1|(ee&21845)<<1,kt=(kt&52428)>>2|(kt&13107)<<2,kt=(kt&61680)>>4|(kt&3855)<<4,vc[ee]=((kt&65280)>>8|(kt&255)<<8)>>1;var kt,ee,xo=(function(o,e,t){for(var r=o.length,n=0,i=new mn(e);n<r;++n)o[n]&&++i[o[n]-1];var s=new mn(e);for(n=1;n<e;++n)s[n]=s[n-1]+i[n-1]<<1;var a;if(t){a=new mn(1<<e);var l=15-e;for(n=0;n<r;++n)if(o[n])for(var c=n<<4|o[n],d=e-o[n],u=s[o[n]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)a[vc[u]>>l]=c}else for(a=new mn(r),n=0;n<r;++n)o[n]&&(a[n]=vc[s[o[n]-1]++]>>15-o[n]);return a}),So=new it(288);for(ee=0;ee<144;++ee)So[ee]=8;var ee;for(ee=144;ee<256;++ee)So[ee]=9;var ee;for(ee=256;ee<280;++ee)So[ee]=7;var ee;for(ee=280;ee<288;++ee)So[ee]=8;var ee,zm=new it(32);for(ee=0;ee<32;++ee)zm[ee]=5;var ee;var c0=xo(So,9,1);var d0=xo(zm,5,1),gc=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},St=function(o,e,t){var r=e/8|0;return(o[r]|o[r+1]<<8)>>(e&7)&t},yc=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},u0=function(o){return(o+7)/8|0},Sc=function(o,e,t){return(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length),new it(o.subarray(e,t))};var h0=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ht=function(o,e,t){var r=new Error(e||h0[o]);if(r.code=o,Error.captureStackTrace&&Error.captureStackTrace(r,ht),!t)throw r;return r},p0=function(o,e,t,r){var n=o.length,i=r?r.length:0;if(!n||e.f&&!e.l)return t||new it(0);var s=!t,a=s||e.i!=2,l=e.i;s&&(t=new it(n*3));var c=function($e){var Oe=t.length;if($e>Oe){var te=new it(Math.max(Oe*2,$e));te.set(t),t=te}},d=e.f||0,u=e.p||0,h=e.b||0,v=e.l,f=e.d,M=e.m,p=e.n,m=n*8;do{if(!v){d=St(o,u,1);var g=St(o,u+1,3);if(u+=3,g)if(g==1)v=c0,f=d0,M=9,p=5;else if(g==2){var C=St(o,u,31)+257,D=St(o,u+10,15)+4,w=C+St(o,u+5,31)+1;u+=14;for(var P=new it(w),T=new it(19),I=0;I<D;++I)T[s0[I]]=St(o,u+I*3,7);u+=D*3;for(var L=gc(T),A=(1<<L)-1,F=xo(T,L,1),I=0;I<w;){var k=F[St(o,u,A)];u+=k&15;var b=k>>4;if(b<16)P[I++]=b;else{var _=0,j=0;for(b==16?(j=3+St(o,u,3),u+=2,_=P[I-1]):b==17?(j=3+St(o,u,7),u+=3):b==18&&(j=11+St(o,u,127),u+=7);j--;)P[I++]=_}}var G=P.subarray(0,C),Z=P.subarray(C);M=gc(G),p=gc(Z),v=xo(G,M,1),f=xo(Z,p,1)}else ht(1);else{var b=u0(u)+4,x=o[b-4]|o[b-3]<<8,S=b+x;if(S>n){l&&ht(0);break}a&&c(h+x),t.set(o.subarray(b,S),h),e.b=h+=x,e.p=u=S*8,e.f=d;continue}if(u>m){l&&ht(0);break}}a&&c(h+131072);for(var se=(1<<M)-1,xe=(1<<p)-1,oe=u;;oe=u){var _=v[yc(o,u)&se],ie=_>>4;if(u+=_&15,u>m){l&&ht(0);break}if(_||ht(2),ie<256)t[h++]=ie;else if(ie==256){oe=u,v=null;break}else{var rt=ie-254;if(ie>264){var I=ie-257,ze=Fm[I];rt=St(o,u,(1<<ze)-1)+km[I],u+=ze}var H=f[yc(o,u)&xe],fe=H>>4;H||ht(3),u+=H&15;var Z=l0[fe];if(fe>3){var ze=_m[fe];Z+=yc(o,u)&(1<<ze)-1,u+=ze}if(u>m){l&&ht(0);break}a&&c(h+131072);var Ye=h+rt;if(h<Z){var pt=i-Z,_e=Math.min(Z,Ye);for(pt+h<0&&ht(3);h<_e;++h)t[h]=r[pt+h]}for(;h<Ye;++h)t[h]=t[h-Z]}}e.l=v,e.p=oe,e.b=h,e.f=d,v&&(d=1,e.m=M,e.d=f,e.n=p)}while(!d);return h!=t.length&&s?Sc(t,0,h):t.subarray(0,h)};var m0=new it(0);var It=function(o,e){return o[e]|o[e+1]<<8},Mt=function(o,e){return(o[e]|o[e+1]<<8|o[e+2]<<16|o[e+3]<<24)>>>0},bc=function(o,e){return Mt(o,e)+Mt(o,e+4)*4294967296};function f0(o,e){return p0(o,{i:2},e&&e.out,e&&e.dictionary)}var xc=typeof TextDecoder<"u"&&new TextDecoder,g0=0;try{xc.decode(m0,{stream:!0}),g0=1}catch{}var y0=function(o){for(var e="",t=0;;){var r=o[t++],n=(r>127)+(r>223)+(r>239);if(t+n>o.length)return{s:e,r:Sc(o,t-1)};n?n==3?(r=((r&15)<<18|(o[t++]&63)<<12|(o[t++]&63)<<6|o[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):n&1?e+=String.fromCharCode((r&31)<<6|o[t++]&63):e+=String.fromCharCode((r&15)<<12|(o[t++]&63)<<6|o[t++]&63):e+=String.fromCharCode(r)}};function Mc(o,e){if(e){for(var t="",r=0;r<o.length;r+=16384)t+=String.fromCharCode.apply(null,o.subarray(r,r+16384));return t}else{if(xc)return xc.decode(o);var n=y0(o),i=n.s,t=n.r;return t.length&&ht(8),i}}var b0=function(o,e){return e+30+It(o,e+26)+It(o,e+28)},v0=function(o,e,t){var r=It(o,e+28),n=Mc(o.subarray(e+46,e+46+r),!(It(o,e+8)&2048)),i=e+46+r,s=Mt(o,e+20),a=t&&s==4294967295?x0(o,i):[s,Mt(o,e+24),Mt(o,e+42)],l=a[0],c=a[1],d=a[2];return[It(o,e+10),l,c,n,i+It(o,e+30)+It(o,e+32),d]},x0=function(o,e){for(;It(o,e)!=1;e+=4+It(o,e+2));return[bc(o,e+12),bc(o,e+4),bc(o,e+20)]};function Um(o,e){for(var t={},r=o.length-22;Mt(o,r)!=101010256;--r)(!r||o.length-r>65558)&&ht(13);var n=It(o,r+8);if(!n)return{};var i=Mt(o,r+16),s=i==4294967295||n==65535;if(s){var a=Mt(o,r-12);s=Mt(o,a)==101075792,s&&(n=Mt(o,a+32),i=Mt(o,a+48))}for(var l=e&&e.filter,c=0;c<n;++c){var d=v0(o,i,s),u=d[0],h=d[1],v=d[2],f=d[3],M=d[4],p=d[5],m=b0(o,p);i=M,(!l||l({name:f,size:h,originalSize:v,compression:u}))&&(u?u==8?t[f]=f0(o.subarray(m,m+h),{out:new it(v)}):ht(14,"unknown compression type "+u):t[f]=Sc(o,m,m+h))}return t}y();y();y();y();var Ie=o=>Object.entries(o);y();var Mo=o=>Object.keys(o);function Hm(o){return o.replace(/^g_/,"s_")}function qs(o){return o.replace(/^g_/,"o_")}function S0(o){return o.replace(/^g_/,"w_")}function Wm(o){return o.replace(/^loci_/,"eli_")}function Co(o){return o.replace(/^loc_/,"el_")}function Js(o){return o.replace(/^lcat_/,"ec_")}function M0(o){return o.replace(/^g_/,"ar_")}function Vm(o){return o.replace(/^n_/,"s_")}function C0(o,e,t){switch(o.geometry.type){case"MultiPoint":case"MultiLineString":case"MultiPolygon":{let r=[],n=0,i=o.geometry.type.replace("Multi","");for(let s of o.geometry.coordinates)r.push({...o,geometry:{type:i,coordinates:s},properties:{...o.properties,id:`${e}-${n++}`,kind:t}});return r}default:return[{...o,properties:{...o.properties,id:e,kind:t}}]}}function fn(o,e,t,r){let n=new Map;for(let{feature:i,floorId:s}of o){let a=i.properties.id,l=r.get(a);if(e.has(a)){let c=C0(i,t(a),l),d=c.map(h=>h.properties.id),u=d.map(h=>({geometryId:h,floorId:s}));n.set(a,{ids:d,features:c,anchors:u})}}return n}function jm(o){let e={space:new Map,obstruction:new Map,area:new Map,window:new Map,object:new Map};if(!o.geometry)return e;let t=w0(o),r=Ie(o.geometry).flatMap(([c,d])=>(d?.features??[]).map(u=>({feature:u,floorId:c}))).flat(),n=new Set(Object.values(o.walkable??{}).filter(c=>c!==void 0).flatMap(Mo)),i=new Set(Object.values(o.nonwalkable??{}).filter(c=>c!==void 0).flatMap(Mo)),s=new Set(Array.from(t.entries()).filter(([c,d])=>d==="area").map(([c])=>c)),a=new Set(Array.from(t.entries()).filter(([c,d])=>d==="object").map(([c])=>c)),l=new Set(Array.from(t.entries()).filter(([c,d])=>d==="window").map(([c])=>c));return n.size>0&&(e.space=fn(r,n,Hm,t)),i.size>0&&(e.obstruction=fn(r,i,qs,t)),s.size>0&&(e.area=fn(r,s,M0,t)),a.size>0&&(e.object=fn(r,a,qs,t)),l.size>0&&(e.window=fn(r,l,S0,t)),n.size===0&&i.size===0&&s.size===0&&(e.space=fn(r,new Set(r.map(c=>c.feature.properties.id)),Hm,t)),e}function w0(o){let e=new Map(Object.values(o.kinds??{}).filter(t=>t!==void 0).flatMap(Ie));for(let t of o.connections?.filter(r=>r.type!=="door")??[]){for(let r of t.entrances)e.set(r.geometryId,`connection.${t.type}`);for(let r of t.exits)e.set(r.geometryId,`connection.${t.type}`)}return e}function Zm(o){if(!o||o.length===0)return[];let e=Math.max(...o.map(t=>t.length));return o.reduce((t,r)=>t.map((n,i)=>n|(r[i]??0)),Array(e).fill(0))}y();var Dc=Cn($m(),1),I0=o=>{let e=o.geometry.coordinates[0],t=0;for(let r=0;r<e.length-1;r++)t+=e[r][0]*e[r+1][1]-e[r+1][0]*e[r][1];return Math.abs(t/2)},qm=(o,e,t)=>{let r=!1;for(let n=0,i=t.length-1;n<t.length;i=n++){let s=t[n][0],a=t[n][1],l=t[i][0],c=t[i][1];a>e!=c>e&&o<(l-s)*(e-a)/(c-a)+s&&(r=!r)}return r},O0=(o,e)=>{let[t,r]=o,n=e.geometry.coordinates;if(!qm(t,r,n[0]))return!1;for(let i=1;i<n.length;i++)if(qm(t,r,n[i]))return!1;return!0},L0=o=>{let e=o.geometry.coordinates,t=0,r=0,n=0;for(let v of e)for(let f=0;f<v.length-1;f++)t+=v[f][0],r+=v[f][1],n++;if(n===0)throw new Error("Polygon has no vertices");let i=t/n,s=r/n,a=0,l=0,c=0,d,u;for(let v of e)for(let f of v){let M=f[0]-i,p=f[1]-s;if(d!==void 0&&u!==void 0){let m=d*p-M*u;c+=m,a+=(d+M)*m,l+=(u+p)*m}d=M,u=p}if(c===0)return[i,s];let h=1/(3*c);return[i+h*a,s+h*l]},Jm=o=>{let e=I0(o);return!Number.isFinite(e)||e<=0?1e-9:Math.sqrt(e)*.01},gn=o=>{try{let e=L0(o);if(O0(e,o))return xt(e);let t=(0,Dc.default)(o.geometry.coordinates,Jm(o));return xt([t[0],t[1]])}catch{return dr(new Error("Unable to calculate center of polygon"))}},A0=o=>{try{let e=(0,Dc.default)(o.geometry.coordinates,Jm(o));return xt([e[0],e[1]])}catch{return dr(new Error("Unable to calculate center of polygon"))}},Km=(o="center-of-mass")=>{if(typeof o=="function")return o;switch(o){case"visual-center":return A0;case"center-of-mass":return gn}};function Qm(o,e){let{nodesByGeometryId:t,incomingEdgesByNodeId:r,nodesById:n}=R0(o),i=jm(o),s=F0(o),a=o.navigationFlags??{};return{geometryMaps:i,nodesByGeometryId:t,geometryFeatureById:s,navigationFlags:a,incomingEdgesByNodeId:r,nodesById:n,centerCalculator:Km(e?.centerStrategy)}}function R0(o){let e=new Map,t=new Map,r=new Map;for(let n of Object.values(o.nodes??{}))for(let i of n?.features??[]){if(r.set(i.properties.id,i),i.properties.geometryIds.length>0)for(let s of i.properties.geometryIds){let a=e.get(s)??[];a.push(i.properties.id),e.set(s,a)}if(i.properties.neighbors.length>0)for(let s of i.properties.neighbors){let a=t.get(s.id);a!=null?a.push(s):t.set(s.id,[s])}}return{nodesByGeometryId:e,incomingEdgesByNodeId:t,nodesById:r}}function F0(o){let e=new Map;for(let t of Object.values(o.geometry??{}))for(let r of t?.features??[])e.set(r.properties.id,r);return e}y();function ef(o,e){if(!o.annotations||!o.annotationSymbols||!o.geometry)return{};let t={};for(let[r,n]of Ie(o.annotations)){if(!n||n.length===0||!o.geometry[r]||o.geometry[r].features.length===0)continue;let i=new Map(o.geometry[r].features.map(a=>[a.properties.id,a])),s={type:"FeatureCollection",features:[]};for(let a of n){let l=i.get(a.geometryId);if(!l||l.geometry.type!=="Point")continue;let c={id:a.id,externalId:a.externalId,symbolId:a.symbolKey};s.features.push({type:"Feature",geometry:l.geometry,properties:c})}t[r]=s}return{annotation:t}}y();y();function Fr(o,e){return e&&(o.flags[e.index]&1<<e.bit)!==0}y();var Tc={accessible:"accessible",outdoors:"outdoors",public:"public"};function tf(o,{nodesByGeometryId:e}){let t={"connection.json":[],entrance:{}},r=o.navigationFlags?.[Tc.accessible],n=o.navigationFlags?.[Tc.outdoors],i=new Map(Object.values(o.geometry??{}).flatMap(s=>s?.features??[]).map(s=>[s.properties.id,s]));for(let s of o.connections??[]){if(Pc(s,i)&&!_0(s)){let u=B0(s,i,e,n);for(let[h,v]of u)t.entrance[h]||(t.entrance[h]={type:"FeatureCollection",features:[]}),t.entrance[h].features.push(v);continue}let a=r!=null&&s.entrances.some(u=>Fr(u,r))&&s.exits.some(u=>Fr(u,r)),l=Array.from(new Set([...s.entrances.map(u=>e.get(u.geometryId)),...s.exits.map(u=>e.get(u.geometryId))].flat().filter(u=>u!=null))),c=Zm([...s.entrances.map(u=>u.flags),...s.exits.map(u=>u.flags)]),d={id:s.id,externalId:s.details?.externalId??"",type:s.type,accessible:a,nodes:l,flags:c};s.details?.name&&(d.details={name:s.details.name}),s.extra&&(d.extra=s.extra),t["connection.json"].push(d)}return t}function Pc(o,e){return o.type==pc.door&&o.entrances.every(t=>e.get(t.geometryId)?.geometry.type==="LineString")}function _0(o){return o.entrances.length===0||o.exits.length===0?!1:new Set([...o.entrances.map(t=>t.floorId),...o.exits.map(t=>t.floorId)]).size>=2}function B0(o,e,t,r){if(o.type!==pc.door)return[];let n=[];for(let i of o.entrances){let s=e.get(i.geometryId);if(s?.geometry.type==="LineString"){let a={type:"Feature",geometry:s.geometry,properties:{id:o.id,externalId:o.details?.externalId??"",isExterior:G0(o,r)}},l=o.details;l&&(a.properties.details={name:l.name,description:l.description},l.icon&&(a.properties.details.images=[{url:l.icon,altText:`${l.name} icon`}]));let c=t.get(i.geometryId);c&&c.length>0&&(a.properties.node=c[0]),n.push([i.floorId,a])}}return n}function G0(o,e){return o.entrances.some(t=>Fr(t,e))||o.exits.some(t=>Fr(t,e))}y();function nf(o,{geometryMaps:e,nodesByGeometryId:t}){let r={categories:[],locations:[],locationInstances:[],layers:[],venue:{slug:"",name:"",externalId:"",defaultLanguage:{name:"English",code:"en"},languages:[]}},n=o.manifest?.features[0];n&&(r.venue.defaultFloor=n.properties.defaultFloor,r.venue.tzid=n.properties.tzid,r.venue.name=n.properties.name,r.venue.defaultLanguage={name:n.properties.language??"English",code:n.properties.language??"en"});let i=o.cms?.venue;i&&(r.venue={...r.venue,slug:i.slug,name:i.details?.name??r.venue.name??n.properties.name,externalId:i.details?.externalId??"",defaultLanguage:i.defaultLanguage,languages:i.languages??[],countrycode:i.countrycode,coverImage:i.coverImage,logo:i.logo,icon:i.details?.icon,extra:i.extra,mappedinWebUrl:i.mappedinWebUrl,operationHours:i.operationHours,topLocations:i.topLocations,type:i.type&&i.type in hc?i.type:"unknown",propertyImage:i.propertyImage});let s=new Map,a=o.locations??[],l=o.cms?.locations??[],c=o.cms?.categories??[],d=new Map((c??[]).map(b=>[b.categoryId,b]));if(a.length>0){let b=new Map(l.map(x=>[x.locationId,x]));for(let x of a){let S=b.get(x.id)??{};if(x){let C=x.details,D={id:S?.cmsId!==void 0?`el_${S?.cmsId}`:Co(x.id),name:C.name,externalId:C.externalId??"",type:S.type??"location",sortOrder:S.sortOrder??0,amenity:S.amenity,description:C.description,extra:x.extra,links:x.links,operationHours:x.openingHours,gallery:S.gallery,logo:x.logo,shortName:C.shortName,picture:S.picture,showFloatingLabelWhenImagePresent:S.showFloatingLabelWhenImagePresent,showLogo:S.showLogo,siblingGroups:S.siblingGroups,states:S.states,tags:S.tags,spaces:[],nodes:[],polygons:[],headerImage:S.headerImage};if(x.phone&&(D.phone={number:x.phone}),S.primaryCategory){let P=d.get(S.primaryCategory);P&&(D.primaryCategory=P.id)}let w=rf(x.social);x.website&&(w.website=x.website.url),D.social=w;for(let P of x.geometryAnchors){let T=e.space.get(P.geometryId),I=e.obstruction.get(P.geometryId),L=T??I;if(L){let F=new Set(L.features.filter(k=>k.geometry.type==="Polygon").map(k=>k.properties.id));for(let k of L.anchors)T!=null&&L===T&&D.spaces.push({floor:k.floorId,id:k.geometryId}),F.has(k.geometryId)&&D.polygons.push({map:k.floorId,id:k.geometryId})}let A=t.get(P.geometryId);for(let F of A??[])D.nodes.push({map:P.floorId,id:F})}r.locations.push(D);for(let P of x.categories)s.set(P,[...s.get(P)??[],x.id])}}}let u=o.cms?.locationInstances??[],h=o.locationInstances;if(h){let b=new Map(u.map(S=>[S.locationInstanceId,S])),x=[];for(let S of h){let C=b.get(S.id)??{};if(S){let D={id:Wm(S.id),parent:C.parentId??Co(S.parentId),name:S.details?.name,externalId:S.details?.externalId,type:C.type,sortOrder:C.sortOrder,amenity:C.amenity,description:S.details?.description,extra:S.extra,links:S.links,operationHours:S.openingHours,gallery:C.gallery,picture:C.picture,showFloatingLabelWhenImagePresent:C.showFloatingLabelWhenImagePresent,showLogo:C.showLogo,siblingGroups:C.siblingGroups,states:C.states,tags:C.tags,logo:S.logo,shortName:S.details?.shortName,headerImage:C.headerImage};S.phone&&(D.phone={number:S.phone});let w=rf(S.social??[]);if(S.website&&(w.website=S.website.url),Object.keys(w).length>0&&(D.social=w),S.geometryAnchors?.length){let P=S.geometryAnchors.flatMap(T=>e.space.get(T.geometryId)?.anchors??[]);P.length>0&&(D.spaces=P.map(T=>({floor:T.floorId,id:T.geometryId})))}if(S.geometryAnchors){D.spaces=[],D.polygons=[],D.nodes=[];for(let P of S.geometryAnchors){let T=e.space.get(P.geometryId);if(T){let L=new Set(T.features.filter(A=>A.geometry.type==="Polygon").map(A=>A.properties.id));for(let A of T.anchors)D.spaces.push({floor:A.floorId,id:A.geometryId}),L.has(A.geometryId)&&D.polygons.push({map:A.floorId,id:A.geometryId})}let I=t.get(P.geometryId);for(let L of I??[])D.nodes.push({map:P.floorId,id:L})}}x.push(D)}}x.length>0&&(r.locationInstances=x)}let v=o.locationCategories;if(v){let b=[],x=new Map(v.map(w=>[w.id,w])),S=new Map((c??[]).map(w=>[w.categoryId,w])),C=new Map;for(let w of v){let P=x.get(w.parent);if(P){let T=C.get(P.id)??[];T.push(w.id),C.set(P.id,T)}}for(let w of v){let P=S.get(w.id);if(w){let T=(C.get(w.id)??[]).map(Js),I={id:Js(w.id),name:w.details.name,externalId:w.details.externalId??"",sortOrder:P?.sortOrder??0,children:T,locations:(s.get(w.id)??[]).map(Co),icon:w.details.icon,picture:P?.picture,color:P?.color,extra:w.extra,iconFromDefaultList:P?.iconFromDefaultList};b.push(I)}}r.categories=b;let D={};for(let w of a)D[Co(w.id)]=w.categories.map(Js).filter(P=>P!==void 0);r.categoryPriorities=D}let f={};for(let[b,x]of Object.entries(o.defaultStyle??{}))if(x.buffer){let S=x.geometryAnchors.flatMap(C=>e.space.get(C.geometryId)?.anchors??[]);f[b]={edgeOffset:x.buffer,geometryAnchors:S}}Object.keys(f).length>0&&(r.enterpriseStyles=f);let M=new Map;for(let b of Object.values(o.cms?.layers??{}))if(b)for(let[x,S]of Ie(b)){if(typeof S!="string")continue;let C=M.get(S)??{name:S,id:`ely_${S}`,spaces:[]};C.spaces.push(...e.space.get(x)?.anchors.map(D=>({floorId:D.floorId,spaceId:D.geometryId}))??[]),M.set(S,C)}M.size>0&&(r.layers=Array.from(M.values()));let p=[];for(let b of Object.values(o.cms?.textures??{}))for(let x of b){let S=e.space.get(x.geometryId)?.anchors;!S||S.length<1||x.face==="unknown"||x.surface==="unknown"||p.push({repeat:x.repeat,offset:x.offset,rotation:x.rotation,path:x.path,face:x.face,surface:x.surface,bounds:x.bounds,geometryAnchors:S})}p.length>0&&(r.textures=p);let m={};for(let[b,x]of Object.entries(o.cms?.floorText??{})){let S={type:"FeatureCollection",features:[]};for(let C of x.features){if(C.properties.align==="unknown")continue;let D={align:C.properties.align,color:C.properties.color,fontFamily:C.properties.fontFamily,fontSize:C.properties.fontSize,rotation:C.properties.rotation,text:C.properties.text,visible:C.properties.visible};"geometryId"in C.properties?D.geometryId=C.properties.geometryId:D.verticalOffset=C.properties.verticalOffset,S.features.push({type:"Feature",geometry:C.geometry,properties:D})}S.features.length>0&&(m[b]=S)}Object.keys(m).length>0&&(r.floorText=m);let g={enterprise:r};if(o.cms?.textAreas){let b={};for(let[x,S]of Ie(o.cms.textAreas)){let C={type:"FeatureCollection",features:[]};for(let D of S.features){if(D.properties.align==="unknown")continue;let w={align:D.properties.align,maxWidth:D.properties.maxWidth,maxHeight:D.properties.maxHeight,rotation:D.properties.rotation};"geometryId"in D.properties?w.anchorId=D.properties.geometryId:w.verticalOffset=D.properties.verticalOffset;let P={type:"Feature",geometry:D.geometry,properties:w};C.features.push(P)}b[x]=C}g.textAreas=b}return g}var k0=["facebook","instagram","twitter"];function rf(o){let e={};for(let{name:t,url:r}of o){let n=t.toLowerCase();k0.includes(n)&&(e[n]=r)}return e}y();var N0=o=>`fc_${o.slice(3)}`;function of(o,{geometryMaps:e}){if(!o.facade)return{};let t={},r={};for(let[n,i]of Ie(o.facade))if(i)for(let s of Object.values(i)){let{floorStackId:a,geometryIds:l}=s,c=N0(a);r[a]??={id:c,spaces:[]},r[a].spaces.push(...l.map(d=>({floorId:n,spaceId:e.space.get(d)?.ids[0]??""})))}return Object.keys(r).length>0&&(t.facade=r),t}y();function sf(o,e={}){let t={type:"FeatureCollection",features:[]},r=[];for(let n of o.floors.features)r.push({id:n.properties.id,externalId:n.properties.details?.externalId??"",elevation:n.properties.elevation,name:n.properties.details?.name??"",shortName:n.properties.details?.shortName??"",subtitle:n.properties.subtitle,maxHeight:n.properties.maxHeight}),t.features.push({type:"Feature",geometry:n.geometry,properties:{id:n.properties.id,externalId:n.properties.details?.externalId??"",elevation:n.properties.elevation,name:n.properties.details?.name??"",shortName:n.properties.details?.shortName??"",subtitle:n.properties.subtitle,maxHeight:n.properties.maxHeight}});return{"floor.geojson":t,"map.geojson":r}}y();function af(o,{geometryMaps:e}){let t={},r={};for(let[n,i]of Ie(o.floorImages??{})){let s={features:[],type:"FeatureCollection"};for(let a of i?.features??[])if("verticalOffset"in a.properties)s.features.push(a);else{let{geometryId:l,...c}=a.properties,d=e.space.get(l)?.ids[0]??e.obstruction.get(l)?.ids[0];if(!d)continue;let u={geometry:a.geometry,properties:{...c,anchorId:d},type:a.type};s.features.push(u)}r[n]=s}return Object.keys(r).length>0&&(t.floorImages=r),t}y();function lf(o,e={}){let t=[];for(let n of o?.floorStacks??[]){let i={id:n.id,floors:n.floors,maps:n.floors,externalId:n.details?.externalId??"",name:n.details?.name??"",shortName:n.details?.shortName??"",type:"Building"};n.defaultFloor&&(i.defaultFloor=n.defaultFloor),t.push(i)}if(o.outdoors&&o.outdoors.floors.length>0){let n={id:"outdoors",floors:o.outdoors.floors,maps:o.outdoors.floors,type:"Outdoor",name:"Outdoors",externalId:"outdoors"};t.push(n)}return{"floorstack.json":t,"mapstack.geojson":t}}y();function Ic(o){return o?.geometry?.type==="Polygon"}function df(o,{geometryMaps:e,nodesByGeometryId:t,nodesById:r,centerCalculator:n=gn}){let i=W0(o.defaultStyle),s={},a={},l={},c={};for(let u of Mo(o.geometry)){let h=o.geometry[u];if(!h)continue;let v=[],f=[],M=[],p=[];for(let m of h.features){let g=m.properties.id,b=i.has(g),x=t.get(g)??[];for(let S of e.space.get(g)?.features??[])v.push(cf(S,x,n));for(let S of e.obstruction.get(g)?.features??[])if(f.push(z0(S,b,n)),e.object.has(g)){let C=t.get(g)??[],D=C.map(w=>r.get(w)).filter(w=>w!=null);for(let w of D){let P=cf({type:"Feature",geometry:w.geometry,properties:{id:Vm(w.properties.id),kind:"desk-entrance",details:{externalId:qs(g)}}},C,n);v.push(P)}}for(let S of e.area.get(g)?.features??[])M.push(U0(S,x,n));for(let S of e.window.get(g)?.features??[])p.push(H0(S))}v.length>0&&(s[u]={type:"FeatureCollection",features:v.filter(m=>m!==null)}),f.length>0&&(a[u]={type:"FeatureCollection",features:f.filter(m=>m!==null)}),M.length>0&&(l[u]={type:"FeatureCollection",features:M.filter(m=>m!==null)}),p.length>0&&(c[u]={type:"FeatureCollection",features:p.filter(m=>m!==null)})}let d={space:s,obstruction:a};return Object.keys(l).length>0&&(d.area=l),Object.keys(c).length>0&&(d.window=c),d}function cf(o,e,t=gn){switch(o.geometry.type){case"MultiPoint":case"MultiLineString":case"MultiPolygon":return null}let r={type:"Feature",geometry:o.geometry,properties:{destinationNodes:e,id:o.properties.id,externalId:o.properties.details?.externalId??"",kind:o.properties.kind}};return o.properties.details&&(r.properties.details={name:o.properties.details.name,description:o.properties.details.description,images:o.properties.details.icon?[{url:o.properties.details.icon,altText:o.properties.details.name?`${o.properties.details.name} icon`:"icon"}]:void 0}),Ic(r)&&(r.properties.center=t(r).unwrapOr(void 0)),r}function z0(o,e,t=gn){switch(o.geometry.type){case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"Point":return null}let r=o.properties,n={type:"Feature",geometry:o.geometry,properties:{id:r.id,externalId:r.details?.externalId??"",entrances:[],kind:r.kind,footprintComponent:e}};return Ic(n)&&(n.properties.center=t(n).unwrapOr(void 0)),r.details&&(n.properties.details={name:r.details.name,description:r.details.description,images:r.details.icon?[{url:r.details.icon,altText:r.details.name?`${r.details.name} icon`:"icon"}]:void 0}),n}function U0(o,e,t=gn){if(o.geometry.type!=="Polygon")return null;let r=o.properties,n={type:"Feature",geometry:o.geometry,properties:{id:r.id,externalId:r.details?.externalId??"",destinationNodes:e}};return Ic(n)&&(n.properties.center=t(n).unwrapOr(void 0)),r.details&&(n.properties.details={name:r.details.name,description:r.details.description,images:r.details.icon?[{url:r.details.icon,altText:r.details.name?`${r.details.name} icon`:"icon"}]:void 0}),n}function H0(o){return o.geometry.type!=="LineString"?null:{type:"Feature",geometry:o.geometry,properties:{id:o.properties.id}}}function W0(o){return new Set((o?.ExteriorWalls?.geometryAnchors??[]).map(t=>t.geometryId))}y();function uf(o,{geometryMaps:e,geometryFeatureById:t}){if(!o.locationCategories&&!o.locations)return{};let r={};if(o.locationCategories?.length){let n=[];for(let i of o.locationCategories){let s={id:i.id,name:i.details.name,icon:i.details.icon??""};i.parent&&(s.parent=i.parent),n.push(s)}r["category.json"]=n}if(o.locations?.length){let n=V0(o,{geometryFeatureById:t}),i=[];for(let s of o.locations){let a={id:s.id,name:s.details.name,categories:s.categories,spaces:[],obstructions:[],areas:[],annotations:[],connections:[],entrances:[],links:s.links,openingHoursSpecification:s.openingHours??[],pictures:s.images,social:s.social,description:s.details.description,externalId:s.details.externalId,icon:s.details.icon,logo:s.logo,phone:s.phone,website:s.website,searchTags:s.searchTags};i.push(a);for(let{geometryId:l,floorId:c}of s.geometryAnchors)a.spaces.push(...e.space.get(l)?.ids.map(d=>({id:d,floor:c}))??[]),a.obstructions.push(...e.obstruction.get(l)?.ids.map(d=>({id:d,floor:c}))??[]),a.areas.push(...e.area.get(l)?.ids.map(d=>({id:d,floor:c}))??[]),a.entrances.push(...n.entrancesByGeometryId.get(l)??[]),a.connections.push(...n.connectionsByGeometryId.get(l)??[]),a.annotations.push(...n.annotationsByGeometryId.get(l)??[])}r["location.json"]=i}return r}function V0(o,{geometryFeatureById:e}){let t={annotationsByGeometryId:new Map,connectionsByGeometryId:new Map,entrancesByGeometryId:new Map};if(o.annotations)for(let[r,n]of Ie(o.annotations))for(let i of n??[]){let s=i.geometryId,a=i.id,l=t.annotationsByGeometryId.get(s)??[];l.push({floor:r,id:a}),t.annotationsByGeometryId.set(s,l)}if(o.connections)for(let r of o.connections){let n=Pc(r,e),i=Array.from(new Map([...r.entrances,...r.exits].map(s=>[`${s.geometryId}_${s.floorId}`,s])).values());for(let s of i){let a=s.geometryId;if(n){let l=t.entrancesByGeometryId.get(a)??[];l.push({floor:s.floorId,id:r.id}),t.entrancesByGeometryId.set(a,l)}else{let l=t.connectionsByGeometryId.get(a)??[];l.push(r.id),t.connectionsByGeometryId.set(a,l)}}}return t}y();function hf(o,e){let t={features:[],type:"FeatureCollection"},r={"manifest.geojson":t},n=o.manifest;if(n.features.length>0){let i=n.features[0],s=i.properties,a=s.details!=null?{...s.details.externalId!=null&&{externalId:s.details.externalId}}:void 0,l={type:"Feature",geometry:i.geometry,properties:{folder_struct:[],version:"2.0.0",time:s.time,name:s.name,naturalBearing:s.naturalBearing,tzid:s.tzid,map:s.mapId,org_id:s.orgId,language:s.language,...a!=null&&Object.keys(a).length>0&&{details:a}}};t.features.push(l)}return r}y();function pf(o,{geometryMaps:e,navigationFlags:t,incomingEdgesByNodeId:r}){let n={"node.geojson":{type:"FeatureCollection",features:[]}},i=n["node.geojson"].features,s=j0(o),a=Z0(o),l=X0(o,a,s);for(let[c,d]of Ie(o.nodes??{}))for(let u of d?.features??[]){let h=e.space.get(u.properties.geometryIds[0])?.features[0],v=h?.geometry.type==="Point"&&h?.properties.details?.externalId?h.properties.details.externalId:"",f=r.get(u.properties.id)??[],M=Object.keys(t??{}),p=[];for(let g of f)for(let b of M)Fr(g,t[b])&&p.push(t[b]);let m={type:"Feature",geometry:u.geometry,properties:{id:u.properties.id,floor:c,space:u.properties.geometryIds.map(g=>e.space.get(g)?.ids).flat().filter(g=>g!==void 0),neighbors:[...u.properties.neighbors.map(g=>({id:g.id,weight:g.extraCost})),...l.get(u.properties.id)??[]],map:c,externalId:v,flags:p.length>0?Y0(p):void 0}};i.push(m)}return n}function j0(o){let e=new Map;for(let t of o.floors?.features??[])e.set(t.properties.id,t.properties.elevation);return e}function Z0(o){let e=new Map;for(let t of Object.values(o.nodes??{}))for(let r of t?.features??[])if(r.properties.geometryIds.length!==0)for(let n of r.properties.geometryIds){let i=e.get(n)??[];i.includes(r.properties.id)||(i.push(r.properties.id),e.set(n,i))}return e}function X0(o,e,t){let r=new Map;for(let n of o.connections??[]){let i=n.exits.map(s=>({...s,nodes:e.get(s.geometryId)??[]}));for(let s of n.entrances){let a=e.get(s.geometryId)??[];for(let l of a)for(let c of i){let d=Math.abs((t.get(s.floorId)??0)-(t.get(c.floorId)??0))*n.floorCostMultiplier,u=r.get(l)??[];u.push(...c.nodes.filter(h=>h!==l).map(h=>({id:h,weight:d+n.entryCost}))),r.set(l,u)}}}return r}function Y0(o){if(o==null||o.length===0)return;let e=new Array(Math.max(...o.map(t=>t.index))+1).fill(0);for(let t of o)e[t.index]|=1<<t.bit;return e}y();function $0(o,e){let t={};for(let r of o){let n=e.get(r);n&&(t[n]??=[],t[n].push(r))}return t}function mf(o,{geometryMaps:e}){if(!o.defaultStyle)return{};let t={},r={};t["styles.json"]=r;let n=[...Array.from(e.space.values()).map(s=>s.features),...Array.from(e.obstruction.values()).map(s=>s.features)],i=new Map(n.flatMap(s=>s.map(a=>[a.properties.id,a.geometry.type])));for(let[s,a]of Ie(o.defaultStyle)){let l=$0(a.geometryAnchors.flatMap(c=>[...e.space.get(c.geometryId)?.ids??[],...e.obstruction.get(c.geometryId)?.ids??[]]),i);if(l.Point&&l.Point.length>0){let c={points:Array.from(l.Point.values()),showImage:a.extra?.showImage!==void 0?a.extra?.showImage===!0:a.opacity!==0};r[`${s}.Point`]=c}if(l.LineString&&l.LineString.length>0){let c={lineStrings:Array.from(l.LineString.values()),altitude:a.altitude,color:a.color,height:a.height,opacity:a.opacity,width:a.buffer};a.topColor!==void 0&&(c.topColor=a.topColor),r[`${s}.LineString`]=c}if(l.Polygon&&l.Polygon.length>0){let c={polygons:Array.from(l.Polygon.values()),altitude:a.altitude,color:a.color,height:a.height,opacity:a.opacity};a.extra?.showImage!==void 0&&(c.showImage=a.extra.showImage===!0),a.topColor!==void 0&&(c.topColor=a.topColor),r[`${s}.Polygon`]=c}}return t}function ff(o,e){let t=Qm(o,e),r=sf(o,t),n=df(o,t),i=pf(o,t),s=tf(o,t),a=mf(o,t),l=lf(o,t),c=af(o,t),d=of(o,t),u=ef(o,t),h=uf(o,t),v=nf(o,t),f=hf(o,t);return{...o.tileset?{"tileset.json":o.tileset}:{},...o.navigationFlags?{"navigationFlags.json":o.navigationFlags}:{},...o.annotationSymbols?{"annotation-symbols.json":o.annotationSymbols}:{},...r,...n,...i,...s,...a,...l,...c,...d,...u,...h,...v,...f}}var me=o=>JSON.parse(Mc(o)),q0=/^geometry\/(.+)\.geojson$/,J0=/^nodes\/(.+)\.(geo)?json$/,K0=/^floorImages\/(.+)\.geojson$/,Q0=/^facade\/(.+)\.json$/,ex=/^walkable\/(.+)\.json$/,tx=/^nonwalkable\/(.+)\.json$/,rx=/^kinds\/(.+)\.json$/,nx=/^annotations\/(.+)\.json$/,ox=/^cms\/(?:([^/]+)\/)?([^/]+)\.(?:json|geojson)$/,ix=[(o,e)=>o==="manifest.geojson"?{manifest:me(e)}:void 0,(o,e)=>o==="floors.geojson"?{floors:me(e)}:void 0,(o,e)=>{let t=o.match(q0);return t?{geometry:{[t[1]]:me(e)}}:void 0},(o,e)=>o==="connections.json"?{connections:me(e)}:void 0,(o,e)=>o==="navigationFlags.json"?{navigationFlags:me(e)}:void 0,(o,e)=>{let t=o.match(J0);return t?{nodes:{[t[1]]:me(e)}}:void 0},(o,e)=>o==="default-style.json"?{defaultStyle:me(e)}:void 0,(o,e)=>o==="floor-stacks.json"?{floorStacks:me(e)}:void 0,(o,e)=>o==="outdoors.json"?{outdoors:me(e)}:void 0,(o,e)=>o==="tileset.json"?{tileset:me(e)}:void 0,(o,e)=>{let t=o.match(K0);return t?{floorImages:{[t[1]]:me(e)}}:void 0},(o,e)=>{let t=o.match(Q0);return t?{facade:{[t[1]]:me(e)}}:void 0},(o,e)=>{let t=o.match(ex);return t?{walkable:{[t[1]]:me(e)}}:void 0},(o,e)=>{let t=o.match(tx);return t?{nonwalkable:{[t[1]]:me(e)}}:void 0},(o,e)=>{let t=o.match(rx);return t?{kinds:{[t[1]]:me(e)}}:void 0},(o,e)=>o==="annotation-symbols.json"?{annotationSymbols:me(e)}:void 0,(o,e)=>{let t=o.match(nx);return t?{annotations:{[t[1]]:me(e)}}:void 0},(o,e)=>o==="locations.json"?{locations:me(e)}:void 0,(o,e)=>o==="location-categories.json"?{locationCategories:me(e)}:void 0,(o,e)=>o==="location-instances.json"?{locationInstances:me(e)}:void 0,(o,e)=>{let t=o.match(ox);if(!t)return;let[,r,n]=t;return r==="floorText"||r==="textures"||r==="textAreas"?{cms:{[r]:{[n]:me(e)}}}:{cms:{[n]:me(e)}}}],sx=new Set(Vs),ax=new Set(js),lx=new Set(po),cx=new Set(fo),dx=new Set(mo),ux=new Set(go),hx=new Set(yo),px=new Set(bo),mx=new Set(vo);function hr(o,e){return typeof o=="string"&&e.has(o)?o:"unknown"}function fx(o){let e=o.connections;if(Array.isArray(e))for(let a of e)a&&typeof a=="object"&&"type"in a&&(a.type=hr(a.type,sx));let t=o.kinds;if(t&&typeof t=="object"){for(let a of Object.values(t))if(a&&typeof a=="object"){let l=a;for(let c of Object.keys(l))l[c]=hr(l[c],ax)}}let r=o.cms;if(!r||typeof r!="object")return;let n=r,i=n.locations;if(Array.isArray(i))for(let a of i){if(!a||typeof a!="object")continue;let l=a;if("type"in l&&(l.type=hr(l.type,lx)),Array.isArray(l.states))for(let c of l.states)c&&typeof c=="object"&&"type"in c&&(c.type=hr(c.type,cx));if(Array.isArray(l.siblingGroups))for(let c of l.siblingGroups)c&&typeof c=="object"&&"type"in c&&(c.type=hr(c.type,dx))}for(let a of["floorText","textAreas"]){let l=a==="floorText"?ux:hx,c=n[a];if(!(!c||typeof c!="object"))for(let d of Object.values(c)){if(!d||typeof d!="object")continue;let u=d.features;if(Array.isArray(u))for(let h of u){if(!h||typeof h!="object")continue;let v=h.properties;v&&typeof v=="object"&&"alignment"in v&&(v.alignment=hr(v.alignment,l))}}}let s=n.textures;if(s&&typeof s=="object"){for(let a of Object.values(s))if(Array.isArray(a))for(let l of a){if(!l||typeof l!="object")continue;let c=l;"face"in c&&(c.face=hr(c.face,px)),"surface"in c&&(c.surface=hr(c.surface,mx))}}}function gx(o){let e=Um(o),t={};for(let r of Object.keys(e))for(let n of ix){let i=n(r,e[r]);if(i){t=ho(t,i,[]);break}}return fx(t),t}function Qs(o){try{return xt(gx(o))}catch(e){return dr(e instanceof Error?e:new Error(String(e)))}}var yx={decompressUnsafeSync:o=>Qs(o),decompressUnsafe:o=>Promise.resolve(Qs(o)),decompressSync:o=>Qs(o),decompress:o=>Promise.resolve(Qs(o))};var ea=class{groupBy;graph;geometryEdgesByMapId=new Map;flagDeclarations={};getDoorByNodeId;nonPublicNodeIds;outdoorNodeIds;indoorPathWeight;outdoorPathWeight;constructor({nodes:e,geojsonCollection:t,groupBy:r="default",multiplicativeDistanceWeightScaling:n,flagDeclarations:i,getDoorByNodeId:s}){this.groupBy=r,this.graph=new Hs({nodes:e,groupBy:this.groupBy,multiplicativeDistanceWeightScaling:n});let a=t?.features||[];this.flagDeclarations=i??{},this.getDoorByNodeId=s,this.nonPublicNodeIds=this.getNonPublicNodeIds(),this.outdoorNodeIds=this.getOutdoorNodeIds(),this.indoorPathWeight=this.getDominantPathWeight(!1),this.outdoorPathWeight=this.getDominantPathWeight(!0),a.forEach(l=>{let c=null;if(l.geometry.type==="LineString"?c=l.geometry.coordinates:l.geometry.type==="Polygon"&&(c=l.geometry.coordinates.flat()),c){let d=this.groupBy==="default"?this.groupBy:l.properties[this.groupBy];this.geometryEdgesByMapId.has(d)||this.geometryEdgesByMapId.set(d,[]);let u=this.geometryEdgesByMapId.get(d),h=l.geometry.type==="LineString"&&c.length<=2;c.forEach((v,f)=>{h&&f+1>=c.length||u.push([v,c[f+1]||c[0]])})}})}getNonPublicNodeIds(){let e=new Set;if(hn.public in this.flagDeclarations)for(let t in this.graph.nodesById)co(this.graph.nodesById[t].properties.flags,this.flagDeclarations[hn.public].index,this.flagDeclarations[hn.public].bit)||e.add(t);return e}getOutdoorNodeIds(){let e=new Set;if(hn.outdoors in this.flagDeclarations){let t=this.flagDeclarations[hn.outdoors];for(let r in this.graph.nodesById)co(this.graph.nodesById[r].properties.flags,t.index,t.bit)&&e.add(r)}return e}getDominantPathWeight(e){let t=new Map;for(let i in this.graph.edges)if(this.outdoorNodeIds.has(i)===e)for(let s of this.graph.edges[i])ne(s.origin)===ne(s.destination)&&this.outdoorNodeIds.has(s.destination.properties.id)===e&&t.set(s.pathWeight,(t.get(s.pathWeight)??0)+1);let r=0,n=0;for(let[i,s]of t)s>n&&(r=i,n=s);return r}getDirections({zones:e,originIds:t,from:r,to:n,destinationNodeIds:i,disabledConnectionNodeIds:s,simplify:a,multiplicativeDistanceWeightScaling:l,overrideEdgeWeights:c,includeNonPublic:d,outdoorPathWeightMultiplier:u}){let h=a?.enabled??!0,v=e??[],f=this.graph.aStar({originIds:t,destinationNodeIds:i,zones:v,disabledConnectionNodeIds:new Set(s),overrideEdgeWeights:c,disabledNodeIds:d?void 0:this.nonPublicNodeIds,outdoorNodeIds:this.outdoorNodeIds,indoorPathWeight:this.indoorPathWeight,outdoorPathWeight:this.outdoorPathWeight,outdoorPathWeightMultiplier:u});if(f.length===0)return{type:"FeatureCollection",features:[]};if(a?.method!=="greedy-los"&&r&&n&&r.length===1&&n.length===1){let M=new tt({origin:r[0],destination:f[0].origin,distance:Qe(r[0].geometry.coordinates,f[0].origin.geometry.coordinates),angle:Pe(r[0].geometry.coordinates,f[0].origin.geometry.coordinates),multiplicativeDistanceWeightScaling:l}),p=f.slice(),m=new tt({origin:f[f.length-1].destination,destination:n[0],distance:Qe(f[f.length-1].destination.geometry.coordinates,n[0].geometry.coordinates),angle:Pe(f[f.length-1].destination.geometry.coordinates,n[0].geometry.coordinates),multiplicativeDistanceWeightScaling:l});p.unshift(M),p.push(m),f=p}return h&&(f=this.simplifyAllSteps(f,a,l)),this.generatePath(f)}generatePath=e=>{let{destination:t}=e[e.length-1],r={type:"FeatureCollection",features:[]};for(let i=0;i<e.length;i++){let{origin:s,destination:a}=e[i],l={id:s.properties.id,angle:e[i].angle,distance:e[i].distance,destination:a.properties.id,edges:this.graph.edges[s.properties.id]};this.groupBy!=="default"&&(l.groupBy=s.properties[this.groupBy]),r.features.push({type:"Feature",geometry:{type:"Point",coordinates:[s.geometry.coordinates[0],s.geometry.coordinates[1]]},properties:l})}let n={id:t.properties.id,edges:this.graph.edges[t.properties.id]};return this.groupBy!=="default"&&(n.groupBy=t.properties[this.groupBy]),r.features.push({type:"Feature",geometry:{type:"Point",coordinates:[t.geometry.coordinates[0],t.geometry.coordinates[1]]},properties:n}),r};simplifyAllSteps(e,t={enabled:!0,method:"greedy-los"},r){let n=[],i=[e[0]],s=t.method??"greedy-los",a=t.radius??lo,l=s==="dp-optimal"?this.simplifyStepsWithDPMethod.bind(this):s==="rdp"?this.simplifyStepsImprovedWithSimplifyBeforeLoSChecks.bind(this):this.simplifySteps.bind(this);for(let h=1;h<e.length;h++)if(this.groupBy!=="default"&&e[h].origin.properties[this.groupBy]!==e[h-1].origin.properties[this.groupBy]){let v=e[h-1].origin.properties[this.groupBy],f=this.geometryEdgesByMapId.get(v)??[];n.push(...l(i,f,a,r,t)),i=[e[h]]}else i.push(e[h]);let c=e[e.length-1],d=this.groupBy==="default"?this.groupBy:c.origin.properties[this.groupBy],u=this.geometryEdgesByMapId.get(d)??[];return n.push(...l(i,u,a,r,t)),n}findNearestNodesOnGraph=(e,t,r,n,i=!1,s=1/0,a,l)=>this.graph.dijkstraFindWithinTravelDistance(e,t,n,this.geometryEdgesByMapId.get(r)??[],i,s,a,l);hasLineOfSight=(e,t,r,n)=>this.graph.hasLineOfSight(e,t,this.geometryEdgesByMapId.get(r),n);simplifySteps(e,t,r,n,i){return Im(e,t,r,this.flagDeclarations,n)}simplifyStepsImprovedWithSimplifyBeforeLoSChecks(e,t,r,n,i){if(e.length<3)return e;!1,e=Tm(e,this.getDoorByNodeId,n,t);let s=i?.method==="rdp"?i.includeDoorBufferNodes??!0:!0;return Pm(e,t,n,s)}simplifyStepsWithDPMethod(e,t,r,n,i){if(e.length<3)return e;let s=new Set;(i?.method==="dp-optimal"?i.includeDoorBufferNodes??!1:!1)&&(s=Lm(e,this.getDoorByNodeId));for(let d=0;d<e.length-1;d++){let u=ne(e[d].origin),h=ne(e[d+1].origin);u!==h&&(e[d].origin.properties.preventSmoothing||(e[d].origin.properties.preventSmoothing=!0,s.add(e[d].origin.properties.id)),e[d+1].origin.properties.preventSmoothing||(e[d+1].origin.properties.preventSmoothing=!0,s.add(e[d+1].origin.properties.id)))}let l=e[e.length-1];ne(l.origin)!==ne(l.destination)&&(l.origin.properties.preventSmoothing||(l.origin.properties.preventSmoothing=!0,s.add(l.origin.properties.id))),!1;let c=Cm(e,t,n,r);if(!1){let d=c[c.length-1];window.__DEBUG_PATH.finalSteps.push({nodeId:d.destination.properties.id,coordinate:d.destination.geometry.coordinates,floorId:d.destination.properties.map})}for(let d of e)s.has(d.origin.properties.id)&&delete d.origin.properties.preventSmoothing,s.has(d.destination.properties.id)&&delete d.destination.properties.preventSmoothing;return c}getDistance=(e,t)=>Qe(e,t);getAngle=(e,t)=>Pe(e,t)};var Oc="https://tiles-cdn.mappedin.com/styles/mappedin/style.json",bx="https://auth.mappedin.com/oauth2/token";async function h_(o,e){let t=Nc(),r=t?!1:e?.useWorkers??!0,n={...e,...t?{outdoorView:void 0}:{},watermark:e?.watermark,attribution:e?.attribution,antialias:e?.antialias,occlusionEnabled:e?.occlusionEnabled,transformImageRequest:e?.transformImageRequest,naturalBearing:e?.naturalBearing??0,imagePlacementOptions:e?.imagePlacementOptions,onWebGLContextCreationError:e?.onWebGLContextCreationError,onWebGLContextLost:e?.onWebGLContextLost,onWebGLContextRestored:e?.onWebGLContextRestored,onWebGLRendererError:e?.onWebGLRendererError,useStandaloneCamera:e?.useStandaloneCamera??!1,useCollisionWorker:t?!1:e?.useCollisionWorker??!0,useWorkers:r};if(r===!0&&e?.outdoorView?.enabled){let i=e.outdoorView.headers;i==null&&(i=await Rd(bx));let s=e.center||[0,0];pa&&wd(pa);let a=null,l=null,c=e.outdoorView.__EXPERIMENTAL_CameraControlsMode==="external";try{a=new Cd({container:o,style:e.outdoorView.style||Oc,center:s,attributionControl:!1,zoom:e.zoomLevel??nc,pitch:e.pitch??tc,bearing:e.bearing??rc,transformRequest:Pd(i),trackResize:!1,pixelRatio:e.outdoorView.lowDpi?1:Zr(),canvasContextAttributes:{antialias:typeof e.antialias=="boolean"?e.antialias:!0,powerPreference:"high-performance"},interactive:c,validateStyle:!1,centerClampedToGround:!1,boxZoom:!1,doubleClickZoom:c,scrollZoom:c,dragPan:c,dragRotate:c,keyboard:c,touchZoomRotate:c}),c&&a.dragPan.enable({deceleration:3e3,linearity:.2,maxSpeed:1100,easing:u=>u*(2-u)}),await Id(a,{timeout:1e4,styleUrl:e.outdoorView?.style||Oc})}catch(u){if(l=u,R.warn(`[MappedinJS] Outdoor view initialization failed: ${l.message}. Falling back to indoor-only rendering.`),a){try{a.remove()}catch{}a=null}}if(!a||l){let u=new ar(o,n);return u.publish("outdoor-style-error",{error:l}),u}let d=null;try{let u=a.painter.context.gl;d=new ar(o,{center:s,zoomLevel:a.getZoom(),pitch:a.getPitch(),bearing:a.getBearing(),gl:u,map:a,mode:"outdoors-interleaved",...n}),Jo(a,d.camera.minZoomLevel,d.camera.maxZoomLevel),a.setMaxPitch(d.camera.maxPitch),a.setMinPitch(d.camera.minPitch),dm(d,a);let h=xr.fromLngLat(s,0),v=Zo(h,d.viewCamera,()=>{d?.renderSync()}),f=!1,M=!1,p="",m=async()=>{a&&(M=!1,a.addLayer(v),d?.renderSync())};d.onMapLibreEvent("style.load",m),m();let g=()=>{a&&(f||(d?.publish("outdoor-view-loaded"),f=!0),M||(M=!0,d?.publish("outdoor-style-loaded")))};d.onMapLibreEvent("idle",g);let b=w=>{w&&(w.sourceDataType==="metadata"||w.sourceDataType==="visibility"||w.dataType==="style"||w.type==="terrain")&&d?.getSystems().htmlControlsSystem.updateData(a)},x=w=>{if(a&&w&&w.dataType==="style"&&w.type==="styledata"){let P=w?.style?.stylesheet?.id;P&&P!==p&&(p=P,M=!1)}b(w)};d.onMapLibreEvent("styledata",x),d.onMapLibreEvent("sourcedata",b),d.onMapLibreEvent("terrain",b);let S=e.outdoorView?.refreshToken,C=S?cm({refreshOutdoorToken:S,headers:i,reloadSource:w=>a?.refreshTiles(w)}):void 0;C&&d.onAbort(()=>C.dispose());let D=w=>{if(w.error?.url===Oc){R.error(`Failed to load outdoor view style, possibly due to invalid token "${i["x-mappedin-tiles-key"]}"`);return}let P=w?.error?.status;if(C&&w?.tile&&(P===401||P===403)){C.recoverFromTileAuthError(w?.sourceId);return}R.warn(w)};return d.onMapLibreEvent("error",D),d}catch(u){if(d)try{d.destroy()}catch{}if(a)try{a.remove()}catch{}R.warn("Failed to initialize outdoor view, falling back to indoor-only rendering:",u);let h=new ar(o,n);return h.publish("outdoor-style-error",{error:u}),h}}else return new ar(o,n)}export{ho as a,jv as b,$m as c,ff as d,yx as e,Ui as f,Or as g,tn as h,NE as i,Bs as j,$i as k,fC as l,Si as m,gC as n,Qe as o,rl as p,Mi as q,yC as r,Lr as s,ea as t,ka as u,Ei as v,cl as w,Up as x,ar as y,Dv as z,oc as A,h_ as B};