t.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Zc(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const xy=Number.POSITIVE_INFINITY,by=Math.sqrt(2);function vy(t,[e,r]){let n=0,i=0;if(r===xy){e<0&&(e=0);const r=e/by;switch(t){case\"top-right\":case\"top-left\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":i=7-r;break;case\"bottom\":i=7-e;break;case\"top\":i=e-7;}switch(t){case\"top-right\":case\"bottom-right\":n=-r;break;case\"top-left\":case\"bottom-left\":n=r;break;case\"left\":n=e;break;case\"right\":n=-e;}}else {switch(e=Math.abs(e),r=Math.abs(r),t){case\"top-right\":case\"top-left\":case\"top\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":case\"bottom\":i=7-r;}switch(t){case\"top-right\":case\"bottom-right\":case\"right\":n=-e;break;case\"top-left\":case\"bottom-left\":case\"left\":n=e;}}return [n,i]}function _y(t){switch(t){case\"right\":case\"top-right\":case\"bottom-right\":return \"right\";case\"left\":case\"top-left\":case\"bottom-left\":return \"left\"}return \"center\"}function wy(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d){let m=s.textMaxSize.evaluate(e,{},h);void 0===m&&(m=a);const y=t.layers[0].layout,g=y.get(\"icon-offset\").evaluate(e,{},h),x=Iy(r.horizontal)||r.vertical,b=\"globe\"===p.name,v=$d,_=a/v,w=t.tilePixelRatio*m/v,M=(T=t.overscaling,t.zoom>18&&T>2&&(T>>=1),Math.max(is/(512*T),1)*y.get(\"symbol-spacing\")),A=y.get(\"text-padding\")*t.tilePixelRatio,S=y.get(\"icon-padding\")*t.tilePixelRatio,I=qe(y.get(\"text-max-angle\")),k=\"map\"===y.get(\"text-rotation-alignment\")&&\"point\"!==y.get(\"symbol-placement\"),P=\"map\"===y.get(\"icon-rotation-alignment\")&&\"point\"!==y.get(\"symbol-placement\"),E=y.get(\"symbol-placement\"),z=M/2;var T;const B=y.get(\"icon-text-fit\").evaluate(e,{},h),C=y.get(\"icon-text-fit-padding\").evaluate(e,{},h),R=\"none\"!==B;let V;!1===t.hasAnyIconTextFit&&R&&(t.hasAnyIconTextFit=!0),n&&R&&(t.allowVerticalPlacement&&r.vertical&&(V=jm(n,r.vertical,B,C,g,_)),x&&(n=jm(n,x,B,C,g,_)));const D=(a,o,m)=>{if(o.x<0||o.x>=is||o.y<0||o.y>=is)return;let y=null;if(b){const{x:t,y:e,z:r}=p.projectTilePoint(o.x,o.y,m);y={anchor:new qm(t,e,r,0,void 0),up:p.upVector(m,o.x,o.y)};}!function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_,w,M,A,S,I){const k=t.addToLineVertexArray(e,n);let P,E,z,T,B,C,R,V=0,D=0,L=0,F=0,O=-1,U=-1;const N={};let j=Tn(\"\");const q=r?r.anchor:e,$=\"none\"!==l.layout.get(\"icon-text-fit\").evaluate(v,{},A);let G=0,Q=0;if(void 0===l._unevaluatedLayout.getValue(\"text-radial-offset\")?[G,Q]=l.layout.get(\"text-offset\").evaluate(v,{},A).map((t=>t*$d)):(G=l.layout.get(\"text-radial-offset\").evaluate(v,{},A)*$d,Q=xy),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)C=Py(t),o&&(R=Py(o));else {const r=l.layout.get(\"text-rotate\").evaluate(v,{},A)+90;z=ky(u,q,e,c,h,p,t,f,r,m),o&&(T=ky(u,q,e,c,h,p,o,g,r));}}if(s){const n=l.layout.get(\"icon-rotate\").evaluate(v,{},A),i=uy(s,n,w,$),a=o?uy(o,n,w,$):void 0;E=ky(u,q,e,c,h,p,s,g,n),V=4*i.length;const f=t.iconSizeData;let d=null;\"source\"===f.kind?(d=[Gd*l.layout.get(\"icon-size\").evaluate(v,{},A)],d[0]>Ay&&hr(`${t.layerIds[0]}: Value for \"icon-size\" is >= ${My}. Reduce your \"icon-size\".`)):\"composite\"===f.kind&&(d=[Gd*_.compositeIconSizes[0].evaluate(v,{},A),Gd*_.compositeIconSizes[1].evaluate(v,{},A)],(d[0]>Ay||d[1]>Ay)&&hr(`${t.layerIds[0]}: Value for \"icon-size\" is >= ${My}. Reduce your \"icon-size\".`)),t.addSymbols(t.icon,i,d,b,x,v,!1,r,e,k.lineStartIndex,k.lineLength,-1,M,A,S,I),O=t.icon.placedSymbolArray.length-1,a&&(D=4*a.length,t.addSymbols(t.icon,a,d,b,x,v,Pm.vertical,r,e,k.lineStartIndex,k.lineLength,-1,M,A,S,I),U=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=i.horizontal[n];P||(j=Tn(s.text),d?B=Py(s):P=ky(u,q,e,c,h,p,s,f,l.layout.get(\"text-rotate\").evaluate(v,{},A),m));const o=1===s.positionedLines.length;if(L+=Sy(t,r,e,s,a,l,d,v,m,k,i.vertical?Pm.horizontal:Pm.horizontalOnly,o?Object.keys(i.horizontal):[n],N,O,_,M,A,S),o)break}i.vertical&&(F+=Sy(t,r,e,i.vertical,a,l,d,v,m,k,Pm.vertical,[\"vertical\"],N,U,_,M,A,S));let Y=-1;const X=(t,e)=>t?Math.max(t,e):e;Y=X(B,Y),Y=X(C,Y),Y=X(R,Y);const Z=Y>-1?1:0;t.glyphOffsetArray.length>=65535&&hr(\"Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907\"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,q.x,q.y,q.z,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,O,U,j,void 0!==P?P:t.collisionBoxArray.length,void 0!==P?P+1:t.collisionBoxArray.length,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==E?E:t.collisionBoxArray.length,void 0!==E?E+1:t.collisionBoxArray.length,T||t.collisionBoxArray.length,T?T+1:t.collisionBoxArray.length,c,L,F,V,D,Z,0,G,Q,Y,0,$?1:0);}(t,o,y,a,r,n,i,V,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,A,k,l,0,S,P,g,e,s,u,c,h,f,d);};if(\"line\"===E)for(const i of Wm(e.geometry,0,0,is,is)){const e=Zm(i,M,I,r.vertical||x,n,v,w,t.overscaling,is);for(const r of e)x&&Ey(t,x.text,z,r)||D(i,r,h);}else if(\"line-center\"===E){for(const t of e.geometry)if(t.length>1){const e=Xm(t,I,r.vertical||x,n,v,w);e&&D(t,e,h);}}else if(\"Polygon\"===e.type)for(const t of Up(e.geometry,0)){const e=my(t,16);D(t[0],new qm(e.x,e.y,0,0,void 0),h);}else if(\"LineString\"===e.type)for(const t of e.geometry)D(t,new qm(t[0].x,t[0].y,0,0,void 0),h);else if(\"Point\"===e.type)for(const t of e.geometry)for(const e of t)D([e],new qm(e.x,e.y,0,0,void 0),h);}const My=255,Ay=My*Gd;function Sy(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g){const x=function(t,e,r,n,i,s,a,o){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get(\"text-rotate\").evaluate(s,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,f=h/p;let d=e.top-r[1];for(let t=0;tAy&&hr(`${t.layerIds[0]}: Value for \"text-size\" is >= ${My}. Reduce your \"text-size\".`)):\"composite\"===b.kind&&(v=[Gd*d.compositeTextSizes[0].evaluate(o,{},y),Gd*d.compositeTextSizes[1].evaluate(o,{},y)],(v[0]>Ay||v[1]>Ay)&&hr(`${t.layerIds[0]}: Value for \"text-size\" is >= ${My}. Reduce your \"text-size\".`)),t.addSymbols(t.text,x,v,l,a,o,c,e,r,u.lineStartIndex,u.lineLength,f,m,y,g,!1);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function Iy(t){for(const e in t)return t[e];return null}function ky(t,e,r,n,i,s,a,o,l,u){let c=a.top,h=a.bottom,p=a.left,f=a.right;const d=a.collisionPadding;if(d&&(p-=d[0],c-=d[1],f+=d[2],h+=d[3]),l){const t=new Ue(p,c),e=new Ue(f,c),r=new Ue(p,h),n=new Ue(f,h),i=qe(l);let s=new Ue(0,0);u&&(s=new Ue(u[0],u[1])),t._rotateAround(i,s),e._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),c=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,p,c,f,h,o,n,i,s),t.length-1}function Py(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Ey(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])b&&(v(t,u,n,i,o,l),v(u,r,o,l,s,a));}v(h,p,n,s,i,s),v(p,f,i,s,i,a),v(f,d,i,a,n,a),v(d,h,n,a,n,s),m-=b,y-=b,g+=b,x+=b;const _=1/Math.max(g-m,x-y);return {scale:_,x:m*_,y:y*_,x2:g*_,y2:x*_,projection:e}}function By(t,{x:e,y:r},n=0){return new Ue(((e-n)*t.scale-t.x)*is,(r*t.scale-t.y)*is)}const Cy=t.a9.identity(new Float32Array(16));class Ry{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit=\"meters\",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=[\"custom\"],this.center=[0,0],this.range=[3.5,7];}project(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new ac(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return vc(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return zy(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),s=new Ue(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,n))}pointCoordinate3D(t,e,r){const n=new Ue(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y0?e<-qy+r&&(e=-qy+r):e>qy-r&&(e=qy-r);const s=i/Math.pow($y(e),n);let a=s*Math.sin(n*t),o=i-s*Math.cos(n*t);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(t)*s);const l=Ze($e(o/r)+this.center[0],-180,180),u=Ze($e(2*Math.atan(Math.pow(n/a,1/r))-qy),-Ac,Ac);return new ac(l,this.southernCenter?-u:u)}}class Qy extends Ry{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:xc(t),y:bc(e),z:0}}unproject(t,e){const r=_c(t),n=wc(e);return new ac(r,n)}}const Yy=qe(Ac);class Xy extends Ry{project(t,e){const r=(e=qe(e))*e,n=r*r;return {x:.5*((t=qe(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const t=s*s;i=(r*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),r=Ze(r-i,-Yy,Yy);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=Ze($e(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=$e(r);return new ac(a,o)}}const Zy=qe(Ac);class Ky extends Ry{project(t,e){e=qe(e),t=qe(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),s=Math.sin(i)/i,a=.5*(t*n+2*r*Math.sin(t/2)/s)||0,o=.5*(e+Math.sin(e)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,d=p*p,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*p+2*r/Math.PI)-t,b=.5*(g*s+n)-e,v=.5*y*(c*d+g*i*h*u)+1/Math.PI,_=y*(f*l/4-g*s*p),w=.125*y*(l*p-g*s*c*f),M=.5*y*(u*h+g*d*i)+.5,A=_*w-M*v;a=(b*_-x*M)/A,o=(x*w-b*v)/A,r=Ze(r-a,-Math.PI,Math.PI),n=Ze(n-o,-Zy,Zy);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new ac($e(r),$e(n))}}class Wy extends Ry{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(qe(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:qe(t)*n*r+.5,y:-Math.sin(qe(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,s=Ze($e((t-.5)/r)/n,-180,180),a=Math.asin(Ze(i*n,-1,1)),o=Ze($e(a),-Ac,Ac);return new ac(s,o)}}class Hy extends Qy{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit=\"pixels\",this.unsupportedLayers=[\"debug\"],this.range=[3,5];}projectTilePoint(e,r,n){const i=Th(e,r,n),s=Rh(Sh(n));return t.Q.transformMat4(i,i,s),{x:i[0],y:i[1],z:i[2]}}locationPoint(e,r){const n=nc(r.lat,r.lng),i=t.Q.normalize([],n),s=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(r),e._centerAltitude):e._centerAltitude,a=vc(1,0)*is*s;t.Q.scaleAndAdd(n,n,i,a);const o=t.a9.identity(new Float64Array(16));return t.a9.multiply(o,e.pixelMatrix,e.globeMatrix),t.Q.transformMat4(n,n,o),new Ue(n[0],n[1])}pixelsPerMeter(t,e){return vc(1,0)*e}pixelSpaceConversion(t,e,r){const n=vc(1,t)*e,i=qn(vc(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(e,r,n){const i=Vh(Sh(n.canonical));return t.a9.multiply(new Float64Array(16),e.globeMatrix,i)}createInversionMatrix(e,r){const{center:n}=e,i=Rh(Sh(r));return t.a9.rotateY(i,i,qe(n.lng)),t.a9.rotateX(i,i,qe(n.lat)),t.a9.scale(i,i,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(i)}pointCoordinate(t,e,r,n){return wh(t,e,r,!0)||new Ec(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !wh(t,e.x,e.y,!1)}farthestPixelDistance(e){const r=function(e,r){const n=e.cameraToCenterDistance,i=e._centerAltitude*r,s=e._camera,a=e._camera.forward(),o=t.Q.add([],t.Q.scale([],a,-n),[0,0,i]),l=e.worldSize/(2*Math.PI),u=[0,0,-l],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),p=t.Q.scale([],s.up(),h),f=t.Q.scale([],s.right(),h*c),d=t.Q.normalize([],t.Q.add([],t.Q.add([],a,p),f)),m=[];let y;if(new lh(o,d).closestPointOnSphere(u,l,m)){const r=t.Q.add([],m,u),n=t.Q.sub([],r,o);y=Math.cos(e.fovAboveCenter)*t.Q.length(n);}else {const e=t.Q.sub([],o,u),r=t.Q.sub([],u,o);t.Q.normalize(r,r);const n=t.Q.length(e)-l;y=Math.sqrt(n*(n+2*l));const i=Math.acos(y/(l+n))-Math.acos(t.Q.dot(a,r));y*=Math.cos(i);}return 1.01*y}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Oh(e.zoom);if(n>0){const t=zy(e,vc(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return qn(r,t+i*(1-Math.cos(s)),Math.pow(n,10))}return r}upVector(t,e,r){return Th(e,r,t,1)}upVectorScale(t){return {metersToTile:vh(Bh(Sh(t)))}}}function Jy(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case\"mercator\":return new Qy(t);case\"equirectangular\":return new jy(t);case\"naturalEarth\":return new Xy(t);case\"equalEarth\":return new Ny(t);case\"winkelTripel\":return new Ky(t);case\"albers\":return r?new Wy(t):new Vy(t);case\"lambertConformalConic\":return r?new Wy(t):new Gy(t);case\"globe\":return new Hy(t)}throw new Error(`Invalid projection name: ${t.name}`)}const tg=ff.types,eg=[{name:\"a_fade_opacity\",components:1,type:\"Uint8\",offset:0}];function rg(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=o?Math.min(Ay,Math.round(o[0])):0,d=o?Math.min(Ay,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),s,a,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function ng(t,e,r){t.emplaceBack(e,r);}function ig(t,e,r,n,i,s,a){t.emplaceBack(e,r,n,i,s,a);}function sg(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function ag(t){for(const e of t.sections)if(ko(e.text))return !0;return !1}class og{constructor(t){this.layoutVertexArray=new Vl,this.indexArray=new ql,this.programConfigurations=t,this.segments=new mu,this.dynamicLayoutVertexArray=new zl,this.opacityVertexArray=new Ll,this.placedSymbolArray=new su,this.iconTransitioningVertexArray=new Fl,this.globeExtVertexArray=new Dl,this.zOffsetVertexArray=new Ql;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(t,e,r,n,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Vd.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Ld.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,eg,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Od.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Dd.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Fd.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy());}}fo(og,\"SymbolBuffers\");class lg{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new mu,this.collisionVertexArray=new jl,this.collisionVertexArrayExt=new zl;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Ud.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Nd.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}fo(lg,\"CollisionBuffers\");class ug{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=t.a9.identity([]),this.placementViewportMatrix=t.a9.identity([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Qd(this.zoom,r[\"text-size\"]),this.iconSizeData=Qd(this.zoom,r[\"icon-size\"]);const n=this.layers[0].layout,i=n.get(\"symbol-sort-key\"),s=n.get(\"symbol-z-order\");this.canOverlap=n.get(\"text-allow-overlap\")||n.get(\"icon-allow-overlap\")||n.get(\"text-ignore-placement\")||n.get(\"icon-ignore-placement\"),this.sortFeaturesByKey=\"viewport-y\"!==s&&void 0!==i.constantOr(1),this.sortFeaturesByY=(\"viewport-y\"===s||\"auto\"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get(\"text-writing-mode\").map((t=>Pm[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get(\"symbol-z-elevate\");}createArrays(){this.text=new og(new ju(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new og(new ju(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new lu,this.lineVertexArray=new uu,this.symbolInstances=new ou;}calculateGlyphDependencies(t,e,r,n,i){for(let r=0;r0)&&(\"constant\"!==l.value.kind||l.value.value.length>0),p=\"constant\"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,f=a.get(\"symbol-sort-key\");if(this.features=[],!h&&!p)return;const d=r.iconDependencies,m=r.glyphDependencies,y=r.availableImages,g=new Uo(this.zoom);for(const{feature:r,id:u,index:c,sourceLayerIndex:x}of e){const e=s._featureFilter.needGeometry,b=Fc(r,e);if(!s._featureFilter.filter(g,b,n))continue;if(e||(b.geometry=Lc(r,n,i)),o&&1!==r.type&&n.z<=5){const e=b.geometry,r=.98078528056,i=(e,i)=>{const s=Th(e.x,e.y,n,1),a=Th(i.x,i.y,n,1);return t.Q.dot(s,a)=0;for(const r of v.sections)if(r.image)d[r.image.namePrimary]=!0;else {const n=vo(v.toString()),i=r.fontStack||t,s=m[i]=m[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n);}}}\"line\"===a.get(\"symbol-placement\")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n,i){const s=0!==Object.keys(t).length;if(s&&!this.stateDependentLayers.length)return;const a=s?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,a,r,n,i),this.icon.programConfigurations.updatePaintArrays(t,e,a,r,n,i);}updateZOffset(){const t=(t,e,n)=>{r+=e,r>t.length&&t.resize(r);for(let i=-e;i<0;i++)t.emplace(i+r,n);},e=(t,e,r)=>{n+=e,n>t.length&&t.resize(n);for(let i=-e;i<0;i++)t.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||s>0)&&(t(this.text.zOffsetVertexArray,i,o),t(this.text.zOffsetVertexArray,s,o)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=n;t>=0&&e(this.icon.zOffsetVertexArray,a,o),r>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Jy(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m){const y=t.indexArray,g=t.layoutVertexArray,x=t.globeExtVertexArray,b=t.segments.prepareSegment(4*e.length,g,y,this.canOverlap?s.sortKey:void 0),v=this.glyphOffsetArray.length,_=b.vertexLength,w=this.allowVerticalPlacement&&a===Pm.vertical?Math.PI/2:0,M=s.text&&s.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),s=Yd(this.textSizeData,t,i)/$d;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=Yd(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r,n){t.emplaceBack(e,-r,-r,n),t.emplaceBack(e,r,-r,n),t.emplaceBack(e,r,r,n),t.emplaceBack(e,-r,r,n);}_updateTextDebugCollisionBoxes(t,e,r,n,i,s){for(let a=n;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}fo(ug,\"SymbolBucket\",{omit:[\"layers\",\"collisionBoxArray\",\"features\",\"compareText\"]}),ug.addDynamicAttributes=sg;const cg=new Ho({\"symbol-placement\":new Zo(el.layout_symbol[\"symbol-placement\"]),\"symbol-spacing\":new Zo(el.layout_symbol[\"symbol-spacing\"]),\"symbol-avoid-edges\":new Zo(el.layout_symbol[\"symbol-avoid-edges\"]),\"symbol-sort-key\":new Ko(el.layout_symbol[\"symbol-sort-key\"]),\"symbol-z-order\":new Zo(el.layout_symbol[\"symbol-z-order\"]),\"symbol-z-elevate\":new Zo(el.layout_symbol[\"symbol-z-elevate\"]),\"icon-allow-overlap\":new Zo(el.layout_symbol[\"icon-allow-overlap\"]),\"icon-ignore-placement\":new Zo(el.layout_symbol[\"icon-ignore-placement\"]),\"icon-optional\":new Zo(el.layout_symbol[\"icon-optional\"]),\"icon-rotation-alignment\":new Zo(el.layout_symbol[\"icon-rotation-alignment\"]),\"icon-size\":new Ko(el.layout_symbol[\"icon-size\"]),\"icon-text-fit\":new Ko(el.layout_symbol[\"icon-text-fit\"]),\"icon-text-fit-padding\":new Ko(el.layout_symbol[\"icon-text-fit-padding\"]),\"icon-image\":new Ko(el.layout_symbol[\"icon-image\"]),\"icon-rotate\":new Ko(el.layout_symbol[\"icon-rotate\"]),\"icon-padding\":new Zo(el.layout_symbol[\"icon-padding\"]),\"icon-keep-upright\":new Zo(el.layout_symbol[\"icon-keep-upright\"]),\"icon-offset\":new Ko(el.layout_symbol[\"icon-offset\"]),\"icon-anchor\":new Ko(el.layout_symbol[\"icon-anchor\"]),\"icon-pitch-alignment\":new Zo(el.layout_symbol[\"icon-pitch-alignment\"]),\"text-pitch-alignment\":new Zo(el.layout_symbol[\"text-pitch-alignment\"]),\"text-rotation-alignment\":new Zo(el.layout_symbol[\"text-rotation-alignment\"]),\"text-field\":new Ko(el.layout_symbol[\"text-field\"]),\"text-font\":new Ko(el.layout_symbol[\"text-font\"]),\"text-size\":new Ko(el.layout_symbol[\"text-size\"]),\"text-max-width\":new Ko(el.layout_symbol[\"text-max-width\"]),\"text-line-height\":new Ko(el.layout_symbol[\"text-line-height\"]),\"text-letter-spacing\":new Ko(el.layout_symbol[\"text-letter-spacing\"]),\"text-justify\":new Ko(el.layout_symbol[\"text-justify\"]),\"text-radial-offset\":new Ko(el.layout_symbol[\"text-radial-offset\"]),\"text-variable-anchor\":new Zo(el.layout_symbol[\"text-variable-anchor\"]),\"text-anchor\":new Ko(el.layout_symbol[\"text-anchor\"]),\"text-max-angle\":new Zo(el.layout_symbol[\"text-max-angle\"]),\"text-writing-mode\":new Zo(el.layout_symbol[\"text-writing-mode\"]),\"text-rotate\":new Ko(el.layout_symbol[\"text-rotate\"]),\"text-padding\":new Zo(el.layout_symbol[\"text-padding\"]),\"text-keep-upright\":new Zo(el.layout_symbol[\"text-keep-upright\"]),\"text-transform\":new Ko(el.layout_symbol[\"text-transform\"]),\"text-offset\":new Ko(el.layout_symbol[\"text-offset\"]),\"text-allow-overlap\":new Zo(el.layout_symbol[\"text-allow-overlap\"]),\"text-ignore-placement\":new Zo(el.layout_symbol[\"text-ignore-placement\"]),\"text-optional\":new Zo(el.layout_symbol[\"text-optional\"]),visibility:new Zo(el.layout_symbol.visibility)});var hg={paint:new Ho({\"icon-opacity\":new Ko(el.paint_symbol[\"icon-opacity\"]),\"icon-emissive-strength\":new Ko(el.paint_symbol[\"icon-emissive-strength\"]),\"text-emissive-strength\":new Ko(el.paint_symbol[\"text-emissive-strength\"]),\"icon-color\":new Ko(el.paint_symbol[\"icon-color\"]),\"icon-halo-color\":new Ko(el.paint_symbol[\"icon-halo-color\"]),\"icon-halo-width\":new Ko(el.paint_symbol[\"icon-halo-width\"]),\"icon-halo-blur\":new Ko(el.paint_symbol[\"icon-halo-blur\"]),\"icon-translate\":new Zo(el.paint_symbol[\"icon-translate\"]),\"icon-translate-anchor\":new Zo(el.paint_symbol[\"icon-translate-anchor\"]),\"icon-image-cross-fade\":new Ko(el.paint_symbol[\"icon-image-cross-fade\"]),\"text-opacity\":new Ko(el.paint_symbol[\"text-opacity\"]),\"text-color\":new Ko(el.paint_symbol[\"text-color\"],{runtimeType:Jn,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),\"text-halo-color\":new Ko(el.paint_symbol[\"text-halo-color\"]),\"text-halo-width\":new Ko(el.paint_symbol[\"text-halo-width\"]),\"text-halo-blur\":new Ko(el.paint_symbol[\"text-halo-blur\"]),\"text-translate\":new Zo(el.paint_symbol[\"text-translate\"]),\"text-translate-anchor\":new Zo(el.paint_symbol[\"text-translate-anchor\"]),\"icon-color-saturation\":new Zo(el.paint_symbol[\"icon-color-saturation\"]),\"icon-color-contrast\":new Zo(el.paint_symbol[\"icon-color-contrast\"]),\"icon-color-brightness-min\":new Zo(el.paint_symbol[\"icon-color-brightness-min\"]),\"icon-color-brightness-max\":new Zo(el.paint_symbol[\"icon-color-brightness-max\"])}),layout:cg};class pg{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Zn,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}fo(pg,\"FormatSectionOverride\",{omit:[\"defaultValue\"]});class fg extends bl{constructor(e,r,n){super(e,hg,r,n),this._colorAdjustmentMatrix=t.a9.identity([]);}recalculate(t,e){super.recalculate(t,e),\"auto\"===this.layout.get(\"icon-rotation-alignment\")&&(this.layout._values[\"icon-rotation-alignment\"]=\"point\"!==this.layout.get(\"symbol-placement\")?\"map\":\"viewport\"),\"auto\"===this.layout.get(\"text-rotation-alignment\")&&(this.layout._values[\"text-rotation-alignment\"]=\"point\"!==this.layout.get(\"symbol-placement\")?\"map\":\"viewport\"),\"auto\"===this.layout.get(\"text-pitch-alignment\")&&(this.layout._values[\"text-pitch-alignment\"]=this.layout.get(\"text-rotation-alignment\")),\"auto\"===this.layout.get(\"icon-pitch-alignment\")&&(this.layout._values[\"icon-pitch-alignment\"]=this.layout.get(\"icon-rotation-alignment\"));const r=this.layout.get(\"text-writing-mode\");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values[\"text-writing-mode\"]=t;}else this.layout._values[\"text-writing-mode\"]=\"point\"===this.layout.get(\"symbol-placement\")?[\"horizontal\"]:[\"horizontal\",\"vertical\"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,r,n,i){return this._saturation===e&&this._contrast===r&&this._brightnessMin===n&&this._brightnessMax===i||(this._colorAdjustmentMatrix=function(e,r,n,i){e=Er(e),r=Pr(r);const s=t.a9.create(),a=e/3,o=1-2*a,l=[o,a,a,0,a,o,a,0,a,a,o,0,0,0,0,1],u=.5-.5*r,c=i-n;return t.a9.multiply(s,[c,0,0,0,0,c,0,0,0,0,c,0,n,n,n,1],[r,0,0,0,0,r,0,0,0,0,r,0,u,u,u,1]),t.a9.multiply(s,s,l),s}(e,r,n,i),this._saturation=e,this._contrast=r,this._brightnessMin=n,this._brightnessMax=i),this._colorAdjustmentMatrix}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||eo(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):\"\"))}(e.properties,i)}createBucket(t){return new ug(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of hg.paint.overridableProperties){if(!fg.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new pg(e),n=new to(r,e.property.specification,this.scope,this.options);let i=null;i=\"constant\"===e.value.kind||\"source\"===e.value.kind?new no(\"source\",n):new io(\"composite\",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Yo(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&fg.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get(\"text-field\"),n=hg.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if(\"constant\"===r.value.kind&&r.value.value instanceof fi)s(r.value.value.sections);else if(\"source\"===r.value.kind){const t=e=>{i||(e instanceof bi&&gi(e.value)===ni?s(e.value.sections):e instanceof Mi?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramIds(){const t=0!==this.paint.get(\"icon-opacity\").constantOr(1),e=0!==this.paint.get(\"text-opacity\").constantOr(1),r=[];return t&&r.push(\"symbolIcon\"),e&&r.push(\"symbolSDF\"),r}getDefaultProgramParams(t,e){return {config:new Nu(this,e),overrideFog:!1}}}const dg=new Ho({visibility:new Zo(el.layout_background.visibility)});var mg={paint:new Ho({\"background-color\":new Zo(el.paint_background[\"background-color\"]),\"background-pattern\":new Zo(el.paint_background[\"background-pattern\"]),\"background-opacity\":new Zo(el.paint_background[\"background-opacity\"]),\"background-emissive-strength\":new Zo(el.paint_background[\"background-emissive-strength\"])}),layout:dg};const yg=new Ho({visibility:new Zo(el.layout_raster.visibility)});var gg={paint:new Ho({\"raster-opacity\":new Zo(el.paint_raster[\"raster-opacity\"]),\"raster-color\":new Wo(el.paint_raster[\"raster-color\"]),\"raster-color-mix\":new Zo(el.paint_raster[\"raster-color-mix\"]),\"raster-color-range\":new Zo(el.paint_raster[\"raster-color-range\"]),\"raster-hue-rotate\":new Zo(el.paint_raster[\"raster-hue-rotate\"]),\"raster-brightness-min\":new Zo(el.paint_raster[\"raster-brightness-min\"]),\"raster-brightness-max\":new Zo(el.paint_raster[\"raster-brightness-max\"]),\"raster-saturation\":new Zo(el.paint_raster[\"raster-saturation\"]),\"raster-contrast\":new Zo(el.paint_raster[\"raster-contrast\"]),\"raster-resampling\":new Zo(el.paint_raster[\"raster-resampling\"]),\"raster-fade-duration\":new Zo(el.paint_raster[\"raster-fade-duration\"]),\"raster-emissive-strength\":new Zo(el.paint_raster[\"raster-emissive-strength\"]),\"raster-array-band\":new Zo(el.paint_raster[\"raster-array-band\"]),\"raster-elevation\":new Zo(el.paint_raster[\"raster-elevation\"])}),layout:yg},xg=Ml([{name:\"a_pos\",type:\"Int16\",components:2},{name:\"a_texture_pos\",type:\"Int16\",components:2}]);class bg{constructor(t,e,r,n){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this.update(e,n);}update(t,e,r){const{width:n,height:i}=t,{context:s}=this,{gl:a}=s;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!e||!1!==e.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===i){const{x:e,y:s}=r||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)a.texSubImage2D(a.TEXTURE_2D,0,e,s,a.RGBA,a.UNSIGNED_BYTE,t);else {let r=this.format,o=a.UNSIGNED_BYTE;this.format===a.R32F&&(r=a.RED,o=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,e,s,n,i,r,o,t.data);}}else if(this.size=[n,i],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===a.R8&&(e=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,e,a.UNSIGNED_BYTE,t);}else {let e=this.format,r=this.format,s=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(e=a.DEPTH_COMPONENT16,s=a.UNSIGNED_SHORT),this.format===a.R8&&(r=a.RED),this.format===a.R32F&&(s=a.FLOAT,r=a.RED),a.texImage2D(a.TEXTURE_2D,0,e,n,i,0,r,s,t.data);}this.useMipmap=Boolean(e&&e.useMipmap),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D);}bind(t,e,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrapS=e);}bindExtraParam(t,e,r,n){const{context:i}=this,{gl:s}=i;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?t===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}class vg{constructor(t,e){this.context=t,this.texture=e;}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}}function _g(e,r,n,i,s,a,o,l){const u=[e,r,1,n,i,1,s,a,1],c=[o,l,1],h=t.ct.adjoint([],u),[p,f,d]=t.Q.transformMat3(c,c,h);return t.ct.multiply(u,u,[p,0,0,0,f,0,0,0,d])}function wg(e,r,n,i,s,a,o,l){const u=function(e,r,n,i,s,a,o,l){const u=_g(0,0,1,0,1,1,0,1),c=_g(e,r,n,i,s,a,o,l),h=t.ct.adjoint([],u);return t.ct.multiply(c,c,h)}(e,r,n,i,s,a,o,l);return [u[2]/u[8]/is,u[5]/u[8]/is]}function Mg(t){return [t[0],Math.min(Math.max(t[1],-Ac),Ac)]}class Ag extends Dn{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.coordinates,this.type=\"image\",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1;}load(t,e){if(this._loaded=e||!1,this.fire(new Rn(\"dataloading\",{dataType:\"source\"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=sn(this.map._requestManager.transformRequest(this.url,Zr.Image),((e,r)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new Vn(e)):r&&(this.image=r instanceof HTMLImageElement?Tr.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading());}));}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error(\"The provided handle is not a WebGLTexture instance\");return this.texture=new vg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Rn(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})));}onAdd(t){this.map=t,this.load();}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof vg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],r=t[0][1];for(const n of t)n[1]>r&&(r=n[1]),n[1]Ac?this.onNorthPole=!0:n<-Ac&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const e=t.map(Ec.fromLngLat);this.tileID=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);const s=Math.max(n-e,i-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),o=Math.pow(2,a);let l=Math.floor((e+n)/2*o);return l>1&&(l-=1),new cc(a,l,Math.floor((r+i)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new Rn(\"data\",{dataType:\"source\",sourceDataType:\"content\"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];\"loaded\"!==e.state&&(e.state=\"loaded\",e.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const r=Ty(new cc(0,0,0),this.map.transform.projection),n=[r.projection.project(this.coordinates[0][0],this.coordinates[0][1]),r.projection.project(this.coordinates[1][0],this.coordinates[1][1]),r.projection.project(this.coordinates[2][0],this.coordinates[2][1]),r.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,r=t[1].y-t[0].y,n=t[2].x-t[1].x,i=t[2].y-t[1].y,s=t[3].x-t[2].x,a=t[3].y-t[2].y,o=t[0].x-t[3].x,l=t[0].y-t[3].y,u=e*i-n*r,c=n*a-s*i,h=s*l-o*a,p=o*r-e*l;return u>0&&c>0&&h>0&&p>0||u<0&&c<0&&h<0&&p<0}(n))return console.warn(\"Image source coordinates are defining non-convex area in the Mercator projection\"),void(this._unsupportedCoords=!0);const i=Ty(this.tileID,this.map.transform.projection),[s,a,o,l]=this.coordinates.map((t=>{const e=i.projection.project(t[0],t[1]);return By(i,e)._round()}));this.perspectiveTransform=wg(s.x,s.y,a.x,a.y,o.x,o.y,l.x,l.y);const u=this._boundsArray=new kl;u.emplaceBack(s.x,s.y,0,0),u.emplaceBack(a.x,a.y,is,0),u.emplaceBack(l.x,l.y,0,is),u.emplaceBack(o.x,o.y,is,is),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,xg.members),this.boundsSegments=mu.simpleSegment(0,0,4,2);const c=[],h=[Mg((p=this.coordinates)[0]),Mg(p[1]),Mg(p[2]),Mg(p[3])];var p;const[f,d,m,y]=function(t){let e=t[0][0],r=e,n=t[0][1],i=n;for(let s=1;sr&&(r=t[s][0]),t[s][1]i&&(i=t[s][1]);return [e,n,r-e,i-n]}(h);{const i=new kl,[s,a,o,l]=function(t){let e=t[0].x,r=e,n=t[0].y,i=n;for(let s=1;sr&&(r=t[s].x),t[s].yi&&(i=t[s].y);return [e,n,r-e,i-n]}(n),u=t=>[(t.x-s)/o,(t.y-a)/l],[h,p,g,x]=n.map(u),b=function(e,r,n,i,s,a,o,l){const u=_g(0,0,1,0,1,1,0,1),c=_g(e,r,n,i,s,a,o,l),h=t.ct.adjoint([],c);return t.ct.multiply(u,u,h)}(h[0],h[1],p[0],p[1],g[0],g[1],x[0],x[1]);this.elevatedGlobePerspectiveTransform=wg(h[0],h[1],p[0],p[1],g[0],g[1],x[0],x[1]);const v=(e,r)=>{c.push(e.lng);const n=Math.round((e.lng-f)/m*is),s=Math.round((e.lat-d)/y*is),a=u(r),o=t.Q.transformMat3([],[a[0],a[1],1],b),l=Math.round(o[0]/o[2]*is),h=Math.round(o[1]/o[2]*is);i.emplaceBack(n,s,l,h);},_=n[3].x-n[0].x,w=n[3].y-n[0].y,M=n[2].x-n[1].x,A=n[2].y-n[1].y;for(let t=0;t<65;t++){const e=t/64,i=[n[0].x+e*_,n[0].y+e*w],s=[n[1].x+e*M,n[1].y+e*A],a=s[0]-i[0],o=s[1]-i[1];for(let t=0;t<65;t++){const e=t/64,n={x:i[0]+a*e,y:i[1]+o*e,z:0};v(r.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(i,xg.members);}{this.maxLongitudeTriangleSize=0;let t=[],r=new ql;const n=(e,n,i)=>{r.emplaceBack(e,n,i);const s=c[e],a=c[n],o=c[i],l=Math.min(Math.min(s,a),o),u=Math.max(Math.max(s,a),o)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),t.push(l+u/2);};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const r=65*t+e,i=r+1,s=r+65,a=s+1;n(r,s,i),n(i,s,a);}[t,r]=function(t,e){const r=Array.from({length:t.length},((t,e)=>e));r.sort(((e,r)=>t[e]-t[r]));const n=[],i=new ql;for(let s=0;st+360*Math.round((e-t)/360))(t+180,r[0]);const i=new mu,s=(t,r)=>{i.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=a){const t=kr(r,0,r.length,n+a);return t===r.length||s(t,Ir(r,t+1,r.length,n+360-a)-t),i}n0){const n=function(e,r){const n=r.worldSize,i=vc(1,0)*n*Ic(r.center.lat,r.zoom)/Dh(n),s=vc(1,r.center.lat)*n,a=t.a9.identity([]);return t.a9.rotateY(a,a,qe(r.center.lng)),t.a9.rotateX(a,a,qe(r.center.lat)),t.a9.translate(a,a,[0,0,Xu]),t.a9.scale(a,a,[i,i,i*s]),t.a9.translate(a,a,[r.point.x-.5*n,r.point.y-.5*n,0]),t.a9.multiply(a,a,e),t.a9.multiply(a,r.globeMatrix,a)}(e,r);return function(e,r,n){const i=(e,r,n)=>{const i=t.Q.length(e),s=t.Q.length(r),a=Ih(e,r,n);return t.Q.scale(a,a,1/t.Q.length(a)*qn(i,s,n))},s=i([e[0],e[1],e[2]],[r[0],r[1],r[2]],n),a=i([e[4],e[5],e[6]],[r[4],r[5],r[6]],n),o=i([e[8],e[9],e[10]],[r[8],r[9],r[10]],n),l=Ih([e[12],e[13],e[14]],[r[12],r[13],r[14]],n);return [s[0],s[1],s[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],0,l[0],l[1],l[2],1]}(s,n,i)}return s}function $g(t,e,r,n){const i=mh.projectAabbCorners(n,r);let s=Number.MAX_VALUE,a=-1;for(let t=0;tnew Ue(i[t][0],i[t][1]);let l;switch(a){case 0:case 6:l=[o(1),o(5),o(4),o(7),o(3),o(2),o(1)];break;case 1:case 7:l=[o(0),o(4),o(5),o(6),o(2),o(3),o(0)];break;case 3:case 5:l=[o(1),o(0),o(4),o(7),o(6),o(2),o(1)];break;default:l=[o(1),o(5),o(6),o(7),o(3),o(0),o(1)];}if(jc(t,l))return s}const Gg=Ml([{name:\"a_pos_3f\",components:3,type:\"Float32\"}]),Qg=Ml([{name:\"a_color_3f\",components:3,type:\"Float32\"}]),Yg=Ml([{name:\"a_color_4f\",components:4,type:\"Float32\"}]),Xg=Ml([{name:\"a_uv_2f\",components:2,type:\"Float32\"}]),Zg=Ml([{name:\"a_normal_3f\",components:3,type:\"Float32\"}]),Kg=Ml([{name:\"a_normal_matrix0\",components:4,type:\"Float32\"},{name:\"a_normal_matrix1\",components:4,type:\"Float32\"},{name:\"a_normal_matrix2\",components:4,type:\"Float32\"},{name:\"a_normal_matrix3\",components:4,type:\"Float32\"}]),Wg=Ml([{name:\"a_pbr\",components:4,type:\"Uint16\"},{name:\"a_heightBasedEmissiveStrength\",components:3,type:\"Float32\"}]);class Hg{constructor(t,e,r,n){this.message=(t?`${t}: `:\"\")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__);}}function Jg(t,e){const r=-1===t.indexOf(\"://\");try{return new URL(t,r&&e?\"http://example.com\":void 0),!0}catch(t){return !1}}class tx{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class ex{constructor(){this.instancedDataArray=new Hl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class rx{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1;}populate(t,e,r,n){this.tileToMeter=Pc(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:s,id:a,index:o,sourceLayerIndex:l}of t){const t=null!=a?a:s.properties&&s.properties.hasOwnProperty(\"id\")?s.properties.id:void 0,u=Fc(s,i);if(!this.layers[0]._featureFilter.filter(new Uo(this.zoom),u,r))continue;const c={id:t,sourceLayerIndex:l,index:o,geometry:i?u.geometry:Lc(s,r,n),properties:s.properties,type:s.type,patterns:{}},h=this.addFeature(c,c.geometry,u);h&&e.featureIndex.insert(s,c.geometry,o,l,this.index,this.instancesPerModel[h].instancedDataArray.length,is/32);}this.lookup=null;}update(t,e,r,n){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e in t)r.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(r.features[r.idToFeaturesIndex[e]],t[e],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const r in this.instancesPerModel){const n=this.instancesPerModel[r];for(const r of n.features){const i=this.layers[0],s=r.feature,a=this.canonical,o=i.paint.get(\"model-rotation\").evaluate(s,{},a),l=i.paint.get(\"model-scale\").evaluate(s,{},a),u=i.paint.get(\"model-translation\").evaluate(s,{},a);t.Q.exactEquals(r.rotation,o)&&t.Q.exactEquals(r.scale,l)&&t.Q.exactEquals(r.translation,u)||(this.evaluate(r,r.featureStates,n,!0),e=!0);}}return e}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.instancedDataArray,Kg.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(t&&this.modelUris)for(const e of this.modelUris)t.removeModel(e,\"\");}addFeature(t,e,r){const n=this.layers[0],i=n.layout.get(\"model-id\").evaluate(r,{},this.canonical);if(!i)return hr(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),i;Jg(i,!1)&&(this.modelUris.includes(i)||this.modelUris.push(i)),this.instancesPerModel[i]||(this.instancesPerModel[i]=new ex);const s=this.instancesPerModel[i],a=s.instancedDataArray,o=new tx(r,a.length);for(const t of e)for(const e of t){if(e.x<0||e.x>=is||e.y<0||e.y>=is)continue;const t=(this.lookupDim-1)/is,r=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}this.instanceCount++;const n=a.length;a.resize(n+1),s.instancesEvaluatedElevation.push(0),a.float32[16*n]=e.x,a.float32[16*n+1]=e.y;}return o.instancedDataCount=s.instancedDataArray.length-o.instancedDataOffset,o.instancedDataCount>0&&(t.id&&(s.idToFeaturesIndex[t.id]=s.features.length),s.features.push(o),this.evaluate(o,{},s,!1)),i}getModelUris(){return this.modelUris}evaluate(t,e,r,n){const i=this.layers[0],s=t.feature,a=this.canonical,o=t.rotation=i.paint.get(\"model-rotation\").evaluate(s,e,a),l=t.scale=i.paint.get(\"model-scale\").evaluate(s,e,a),u=t.translation=i.paint.get(\"model-translation\").evaluate(s,e,a),c=i.paint.get(\"model-color\").evaluate(s,e,a);c.a=i.paint.get(\"model-color-mix-intensity\").evaluate(s,e,a);const h=[];this.maxVerticalOffset10?this.tileToMeter:Pc(a,f)),o[s+4]=u[0],o[s+5]=u[1],o[s+6]=u[2]+l,o[s+7]=h[0],o[s+8]=h[1],o[s+9]=h[2],o[s+10]=h[4],o[s+11]=h[5],o[s+12]=h[6],o[s+13]=h[8],o[s+14]=h[9],o[s+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}fo(rx,\"ModelBucket\",{omit:[\"layers\"]}),fo(ex,\"PerModelAttributes\"),fo(tx,\"ModelFeature\");const nx=new Ho({visibility:new Zo(el.layout_model.visibility),\"model-id\":new Ko(el.layout_model[\"model-id\"])});var ix={paint:new Ho({\"model-opacity\":new Zo(el.paint_model[\"model-opacity\"]),\"model-rotation\":new Ko(el.paint_model[\"model-rotation\"]),\"model-scale\":new Ko(el.paint_model[\"model-scale\"]),\"model-translation\":new Ko(el.paint_model[\"model-translation\"]),\"model-color\":new Ko(el.paint_model[\"model-color\"]),\"model-color-mix-intensity\":new Ko(el.paint_model[\"model-color-mix-intensity\"]),\"model-type\":new Zo(el.paint_model[\"model-type\"]),\"model-cast-shadows\":new Zo(el.paint_model[\"model-cast-shadows\"]),\"model-receive-shadows\":new Zo(el.paint_model[\"model-receive-shadows\"]),\"model-ambient-occlusion-intensity\":new Zo(el.paint_model[\"model-ambient-occlusion-intensity\"]),\"model-emissive-strength\":new Ko(el.paint_model[\"model-emissive-strength\"]),\"model-roughness\":new Ko(el.paint_model[\"model-roughness\"]),\"model-height-based-emissive-strength-multiplier\":new Ko(el.paint_model[\"model-height-based-emissive-strength-multiplier\"]),\"model-cutoff-fade-range\":new Zo(el.paint_model[\"model-cutoff-fade-range\"]),\"model-front-cutoff\":new Zo(el.paint_model[\"model-front-cutoff\"])}),layout:nx};const sx=64,ax={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function ox(e,r,n,i,s,a,o,l,u,c=!1){const h=n.zoom,p=n.project(i),f=Ic(i.lat,h),d=1/f;t.a9.identity(e),t.a9.translate(e,e,[p.x+o[0]*d,p.y+o[1]*d,o[2]]);let m=1,y=1;const g=n.worldSize;if(c){if(\"mercator\"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Ec(p.x/g,p.y/g),0));const r=t.aa.transformMat4([],[p.x,p.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=r,y=r*Ic(n.center.lat,h);}else if(\"globe\"===n.projection.name){const r=qg(e,n),s=t.a9.multiply([],n.projMatrix,r),a=[0,0,0,1];t.aa.transformMat4(a,a,s);const o=a[3]/n.cameraToCenterDistance,l=Oh(h),u=n.projection.pixelsPerMeter(i.lat,g)*Ic(i.lat,h),c=n.projection.pixelsPerMeter(n.center.lat,g)*Ic(n.center.lat,h);m=o/qn(u,Sc(n.center.lat),l),y=o*f/u,m*=c,y*=c;}}else m=d;t.a9.scale(e,e,[m,m,y]);const x=[...e],b=r.orientation,v=[];if(Ng(v,[b[0]+s[0],b[1]+s[1],b[2]+s[2]],a),t.a9.multiply(e,x,v),l&&n.elevation){let s=0;const a=[];if(u&&n.elevation){s=function(e,r,n,i,s){const a=r.elevation;if(!a)return 0;const o=mh.projectAabbCorners(n,i),l=vc(1,s.lat)*r.worldSize,u=function(e,r){const n=[0,0,1],i=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const s of i){const i=e[s.corners[0]],a=e[s.corners[1]],o=e[s.corners[2]],l=[a[0]-i[0],a[1]-i[1],r*(a[2]-i[2])],u=t.Q.cross(l,l,[o[0]-i[0],o[1]-i[1],r*(o[2]-i[2])]);t.Q.normalize(u,u),s.dotProductWithUp=t.Q.dot(u,n);}return i.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),i[0].corners}(o,l),c=o[u[0]],h=o[u[1]],p=o[u[2]],f=o[u[3]],d=a.getAtPointOrZero(new Ec(c[0]/r.worldSize,c[1]/r.worldSize),0),m=a.getAtPointOrZero(new Ec(h[0]/r.worldSize,h[1]/r.worldSize),0),y=a.getAtPointOrZero(new Ec(p[0]/r.worldSize,p[1]/r.worldSize),0),g=a.getAtPointOrZero(new Ec(f[0]/r.worldSize,f[1]/r.worldSize),0),x=(d+g)/2,b=(m+y)/2;return x>b?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null);}function ux(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Gg.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Zg.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Xg.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?Qg:Yg).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Wg.members,!0)),t.segments=mu.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&lx(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&lx(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&lx(n.normalTexture,e),n.occlusionTexture&&lx(n.occlusionTexture,e,r),n.emissionTexture&&lx(n.emissionTexture,e);}function cx(t,e,r){if(t.meshes)for(const n of t.meshes)ux(n,e,r);if(t.children)for(const n of t.children)cx(n,e,r);}function hx(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)hx(e);}function px(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)px(e);}class fx{constructor(t){this._callback=t,this._triggered=!1,\"undefined\"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){this._channel=void 0,this._callback=()=>{};}}class dx{constructor(){this.tasks={},this.taskQueue=[],sr([\"process\"],this),this.invoker=new fx(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,\"message\"===t?0:\"maybePrepare\"!==t||e?\"parseTile\"!==t||e?\"parseTile\"===t&&e?300-r:\"maybePrepare\"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){mr();try{t();}finally{}return null}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){mr();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:\"\",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(\"\"===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||mr()){const t=this.callbacks[r],n=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:\"message\"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,e);}processTask(t,e){if(delete this.cancelCallbacks[t],\"\"===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(xo(e.error)):r(null,xo(e.data)));}else {const r=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:\"\",sourceMapId:this.mapId,error:e?go(e):null,data:go(n,r)},r);}:t=>{},i=xo(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(\".\");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source,i.scope)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener(\"message\",this.receive,!1);}}class yx{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=er();const r=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0;}));}broadcast(t,e,r){He(this.actors,((r,n)=>{r.send(t,e,n);}),r=r||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove();})),this.actors=[],this.workerPool.release(this.id);}}yx.Actor=mx;var gx={workerUrl:\"\",workerClass:null,workerParams:void 0};function xx(){return null!=gx.workerClass?new gx.workerClass:new self.Worker(gx.workerUrl,gx.workerParams)}const bx=\"mapboxgl_preloaded_worker_pool\";class vx{constructor(){this.active={};}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[bx]}numActive(){return Object.keys(this.active).length}}let _x;function wx(){return _x||(_x=new vx),_x}vx.workerCount=2;let Mx,Ax,Sx,Ix,kx,Px=null;function Ex(){return mr()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Ax||n.DRACO_URL}function zx(){if(mr()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Ix)return Ix;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if(\"object\"!=typeof WebAssembly)throw new Error(\"WebAssembly not supported, cannot instantiate meshoptimizer\");return Ix=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,Ix}const Tx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Bx={5120:\"DT_INT8\",5121:\"DT_UINT8\",5122:\"DT_INT16\",5123:\"DT_UINT16\",5125:\"DT_UINT32\",5126:\"DT_FLOAT32\"},Cx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Rx(t,e,r){const n=r.json.bufferViews.length,i=r.buffers.length;e.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:t.byteLength},r.buffers[i]=t;}const Vx=\"KHR_draco_mesh_compression\";function Dx(t,e){const r=t.extensions&&t.extensions[Vx];if(!r)return;const n=new Sx.Decoder,i=qx(e,r.bufferView),s=new Sx.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,s))throw new Error(\"Failed to decode Draco mesh\");const a=e.json.accessors[t.indices],o=Tx[a.componentType],l=a.count*o.BYTES_PER_ELEMENT,u=Sx._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(s,l,u):n.GetTrianglesUInt32Array(s,l,u),Rx(Sx.memory.buffer.slice(u,u+l),a,e),Sx._free(u);for(const i of Object.keys(r.attributes)){const a=n.GetAttributeByUniqueId(s,r.attributes[i]),o=e.json.accessors[t.attributes[i]],l=Bx[o.componentType],u=o.count*Cx[o.type]*Tx[o.componentType].BYTES_PER_ELEMENT,c=Sx._malloc(u);n.GetAttributeDataArrayForAllPoints(s,a,Sx[l],u,c),Rx(Sx.memory.buffer.slice(c,c+u),o,e),Sx._free(c);}n.destroy(),s.destroy(),delete t.extensions[Vx];}const Lx=\"EXT_meshopt_compression\";function Fx(t,e){if(!t.extensions||!t.extensions[Lx])return;const r=t.extensions[Lx],n=new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);kx.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=i.buffer,delete t.extensions[Lx];}const Ox=1179937895,Ux=new TextDecoder(\"utf8\");function Nx(t,e){return new URL(t,e).href}function jx(t,e,r,n){return fetch(Nx(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[r]=t;}))}function qx(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function $x(t,e,r,n){if(t.uri){const i=Nx(t.uri,n);return fetch(i).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[r]=t;}))}if(void 0!==t.bufferView){const n=qx(e,t.bufferView),i=new Blob([n],{type:t.mimeType});return createImageBitmap(i).then((t=>{e.images[r]=t;}))}}function Gx(t,e=0,r){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Ox){const r=new Uint32Array(t,e);let i=2;const s=(r[i++]>>2)-3,a=r[i++]>>2;if(i++,n.json=JSON.parse(Ux.decode(r.subarray(i,i+a))),i+=a,i{const t=[],e=o&&o.includes(Vx),i=o&&o.includes(Lx);if(e&&t.push(function(){if(!Sx)return Mx||(Mx=function(t){let e,r=null;function n(){e=new Uint8Array(r.buffer);}function i(){throw new Error(\"Unexpected Draco error.\")}const s={a:{a:i,d:function(t,r,n){return e.copyWithin(t,r,r+n)},c:function(t){const i=e.length,s=Math.max(t>>>0,Math.ceil(1.2*i)),a=Math.ceil((s-i)/65536);try{return r.grow(a),n(),!0}catch(t){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,s):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,s)))).then((t=>{const{Rb:i,Qb:s,P:a,T:o,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:f,eb:d,jb:m,f:y,e:g,yb:x,zb:b,Ab:v,Bb:_,Db:w,Gb:M}=t.instance.exports;r=g;const A=(()=>{let t=0,r=0,n=0,a=0;return o=>{n&&(i(a),i(t),r+=n,n=t=0),t||(r+=128,t=s(r));const l=o.length+7&-8;let u=t;l>=r&&(n=l,u=a=s(l));for(let t=0;t{Sx=t,Mx=void 0;})))}()),i&&t.push(function(){if(kx)return;const t=function(t){let e;const r=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors();})),n={NONE:\"\",OCTAHEDRAL:\"meshopt_decodeFilterOct\",QUATERNION:\"meshopt_decodeFilterQuat\",EXPONENTIAL:\"meshopt_decodeFilterExp\"},i={ATTRIBUTES:\"meshopt_decodeVertexBuffer\",TRIANGLES:\"meshopt_decodeIndexBuffer\",INDICES:\"meshopt_decodeIndexSequence\"};return {ready:r,supported:!0,decodeGltfBuffer(t,r,s,a,o,l){!function(t,e,r,n,i,s,a){const o=t.exports.sbrk,l=n+3&-4,u=o(l*i),c=o(s.length),h=new Uint8Array(t.exports.memory.buffer);h.set(s,c);const p=e(u,n,i,c,s.length);if(0===p&&a&&a(u,l,i),r.set(h.subarray(u,u+n*i)),o(u-o(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(e,e.exports[i[o]],t,r,s,a,e.exports[n[l]]);}}}(fetch(zx()));return t.ready.then((()=>{kx=t;}))}()),s)for(let e=0;e{if(e&&a)for(const{primitives:t}of a)for(const e of t)Dx(e,n);if(i&&a&&l)for(const t of l)Fx(t,n);return n}))}))}class Qx{constructor(t,e,r,n){if(this.triangleCount=e.length/3,this.min=new Ue(0,0),this.max=new Ue(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===t.length)return;const[i,s]=[t[0].clone(),t[0].clone()];for(let e=1;et.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let u=0;for(;uthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let t=0;t0){for(let i=0;i0){s.texcoordArray=new Tl;const t=e.json.accessors[i.TEXCOORD_0];s.texcoordArray.resize(t.count);const r=Xx(e,t);Zx(e,t,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const t=e.json.accessors[i._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes(\"EXT_meshopt_compression\")&&(s.featureData=Xx(e,t));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(Xx(e,e.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=t.material;return s.material=function(t,e){const{emissiveFactor:r=[0,0,0],alphaMode:n=\"OPAQUE\",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:a,emissiveTexture:o,doubleSided:l}=t,{baseColorFactor:u=[1,1,1,1],metallicFactor:c=1,roughnessFactor:h=1,baseColorTexture:p,metallicRoughnessTexture:f}=t.pbrMetallicRoughness||{},d=a?e[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&d){const t=a.extensions.KHR_texture_transform;d.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]];}return {pbrMetallicRoughness:{baseColorFactor:new jn(...u),metallicFactor:c,roughnessFactor:h,baseColorTexture:p?e[p.index]:void 0,metallicRoughnessTexture:f?e[f.index]:void 0},doubleSided:l,emissiveFactor:r,alphaMode:n,alphaCutoff:i,normalTexture:s?e[s.index]:void 0,occlusionTexture:d,emissionTexture:o?e[o.index]:void 0,defined:void 0===t.defined}}(void 0!==h?e.json.materials[h]:{defined:!1},r),s}function Wx(e,r,n){const{matrix:i,rotation:s,translation:a,scale:o,mesh:l,extras:u,children:c}=e,h={};if(h.matrix=i||t.a9.fromRotationTranslationScale([],s||[0,0,0,1],a||[0,0,0],o||[1,1,1]),void 0!==l){h.meshes=n[l];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:r,max:n}=e.aabb;t[0]+=r[0]+n[0],t[1]+=r[1]+n[1];}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2);}if(u&&(u.id&&(h.id=u.id),u.lights&&(h.lights=function(t){if(!t.length)return [];const e=function(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let t=0;t0&&n.reverse();const s=Op(n.flatMap((t=>[t.x,t.y])),[]);return 0===s.length?null:{vertices:n,indices:s}}function tb(e,r){const n=[],i=[];let s=0;const a=[];for(const o of e){s=n.length;const e=o.vertexArray.float32,l=o.indexArray.uint16;for(let i=0;i0&&([i[t+1],i[t+2]]=[i[t+2],i[t+1]]);}return {vertices:n,indices:i}}function eb(t){const e=function(t,e){const r=[],n=WebGL2RenderingContext;if(t.json.textures)for(const i of t.json.textures){const s={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(s,t.json.samplers[i.sampler]),r.push({image:e[i.source],sampler:s,uploaded:!1});}return r}(t,t.images),r=function(t,e){const r=[];for(const n of t.json.meshes){const i=[];for(const r of n.primitives)i.push(Kx(r,t,e));r.push(i);}return r}(t,e),{scenes:n,scene:i,nodes:s}=t.json,a=n?n[i||0].nodes:s,o=[];for(const e of a)o.push(Wx(s[e],t,r));return function(t,e,r){const n={},i=new Set;for(let s=0;s0){const e=Array.from(i.values()).sort(((t,e)=>t-e));for(let r=e.length-1;r>=0;r--)t.splice(e[r],1);}}(o,a,t.json.nodes),o}function rb(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,n=t.aabb.min[1]-1,i=sx/(t.aabb.max[0]-r+2),s=sx/(t.aabb.max[1]-n+2);for(let a=0;at.heightmap[u*sx+l]&&(t.heightmap[u*sx+l]=o);}}function nb(e,r){const n={};n.indexArray=new ql,n.indexArray.reserve(4*e.length),n.vertexArray=new Wl,n.vertexArray.reserve(10*e.length),n.colorArray=new zl,n.vertexArray.reserve(10*e.length);let i=0;for(const s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*r,a=[-s.normal[1],s.normal[0],0],o=Math.min(.29,.1*s.width/s.depth),l=s.width-2*s.depth*r*(o+.01),u=t.Q.scaleAndAdd([],s.pos,a,l/2),c=t.Q.scaleAndAdd([],s.pos,a,-l/2),h=[u[0],u[1],u[2]+s.height],p=[c[0],c[1],c[2]+s.height],f=t.Q.scaleAndAdd([],s.normal,a,o);t.Q.scale(f,f,e);const d=t.Q.scaleAndAdd([],s.normal,a,-o);t.Q.scale(d,d,e),t.Q.add(f,u,f),t.Q.add(d,c,d),u[2]+=.1,c[2]+=.1,n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-o,-1,m,.8),n.colorArray.emplaceBack(m+o,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+o,-.8,m,.7),n.colorArray.emplaceBack(m+o,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+o,-1.2,m,.8),n.colorArray.emplaceBack(m+o,-1.2,m,.8),n.indexArray.emplaceBack(6+i,4+i,8+i),n.indexArray.emplaceBack(7+i,9+i,5+i),n.indexArray.emplaceBack(0+i,1+i,2+i),n.indexArray.emplaceBack(1+i,3+i,2+i),i+=10;}const s={defined:!0,emissiveFactor:[0,0,0]},a={};return a.baseColorFactor=jn.white,s.pbrMetallicRoughness=a,n.material=s,n.aabb=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}fo(Qx,\"TriangleGridIndex\");class ib{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new pf(new wm(this.rawTileData)).layers,this.sourceLayerCoder=new ib(this.vtLayers?Object.keys(this.vtLayers).sort():[\"_geojsonTileLayer\"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},s=nl(i.filter),a=t.tileResult,o=t.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,r,n)=>Hc(a.bufferedTilespaceGeometry,t,e,r,n)));u.sort(ub);let c=null;o.elevation&&u.length>0&&(c=Rf.create(o.elevation,this.tileID));const h={};let p;for(let l=0;l(m||(m=Lc(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(a,e,n,m,this.z,t.transform,t.pixelPosMatrix,c,i))));}return h}loadMatchingFeature(t,e,r,n,i,s,a,o,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,f=this.bucketLayerIDs[c];if(n&&!function(t,e){for(let r=0;r=0)return !0;return !1}(n,f))return;const d=this.sourceLayerCoder.decode(h),m=this.vtLayers[d].feature(u);if(r.needGeometry){const t=Fc(m,!0);if(!r.filter(new Uo(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Uo(this.tileID.overscaledZ),m))return;const y=this.getId(m,d);for(let e=0;e{const a=e instanceof Xo?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function ub(t,e){return e-t}fo(ob,\"FeatureIndex\",{omit:[\"rawTileData\",\"sourceLayerCoder\"]});const cb=new Float32Array(262144),hb=new Uint8Array(262144);function pb(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,pb(r));return e}function fb(t,e,r){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&r.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)fb(n,e,r);}const db=[\"\",\"wall\",\"door\",\"roof\",\"window\",\"lamp\",\"logo\"];class mb{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:\"Point\",id:t.id,geometry:[],properties:{height:pb(t)}};}getLocalBounds(){if(!this.node.meshes)return new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==t&&e.encapsulate(r.aabb),t++;this.aabb=mh.applyTransform(e,this.node.matrix);}return this.aabb}}class yb{constructor(t,e,r,n,i,s){this.id=e,this.modelTraits|=ax.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,r&&(this.modelTraits|=ax.HasMapboxMeshFeatures),n&&(this.modelTraits|=ax.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:\"mercator\"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=i,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new mb(e)),fb(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);}update(){console.log(\"Update 3D model bucket\");}populate(){console.log(\"populate 3D model bucket\");}uploadPending(){return !this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const r of e){const e=r.node;this.uploaded?this.updatePbrBuffer(e):cx(e,t,!0);}for(const t of e)hx(t.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const r of t.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),e=!0);return e}needsReEvaluation(t,e,r){const n=t.transform.projectionOptions,i=t.style.getBrightness(),s=this.brightness!==i;return !!(!this.uploaded||this.dirty||n.name!==this.projection.name||gb(r.paint.get(\"model-color\").value,s)||gb(r.paint.get(\"model-color-mix-intensity\").value,s)||gb(r.paint.get(\"model-roughness\").value,s)||gb(r.paint.get(\"model-emissive-strength\").value,s)||gb(r.paint.get(\"model-height-based-emissive-strength-multiplier\").value,s))&&(this.projection=n,this.brightness=i,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const t of r){const r=t.feature;t.evaluatedScale=e.paint.get(\"model-scale\").evaluate(r,{},n);}}evaluate(t){const e=this.getNodesInfo();for(const r of e){if(!r.node.meshes)continue;const e=r.feature,n=r.node.meshes&&r.node.meshes[0].featureData,i=r.evaluatedColor[2],s=r.evaluatedRMEA[2],a=this.id.canonical;if(r.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const h=cb[u],p=Math.abs(h);p>o&&(a=h,o=p,l=i,c=e);}if(o>.1){const s=1-(t+.5*Math.abs(l*c))/u;let o=e._dem.get(n,r)+a*s;const h=e._dem.get(n+l,r+c),p=e._dem.get(n-l,r-c,!0);(o-h)*(o-p)>0&&(o=(h+p)/2),cb[i]=e._dem.set(n,r,o),hb[i]=t;}}}}}a&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=Tr.now());}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)hx(e.node),px(e.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint));}}getHeightAtTileCoord(e,r){const n=this.getNodesInfo(),i=[],s=[0,0,0];for(let a=0;au.max[0]||r>u.max[1])continue;const c=(e-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*sx|0,h=Math.min(63,(r-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*sx|0)*sx+Math.min(63,c);if(s[2]=l.heightmap[h],t.Q.transformMat4(s,s,o.node.matrix),!(l.heightmap[h]<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return {height:s[2],maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new Ue(e,r),new Ue(e,r),i),i.length>0)return {height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function gb(t,e){return !t.isLightConstant&&e}function xb(t,e,r,n,i,s,a,o){let l=(61440&e|(61440&e)>>4)>>8,u=(3840&e|(3840&e)>>4)>>4,c=240&e|(240&e)>>4;r[3]>0&&(l=qn(l,255*r[0],r[3]),u=qn(u,255*r[1],r[3]),c=qn(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),f=function(t){const e=Ze(t,0,2);return Math.min(Math.round(.5*e*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],d=Ze(i[0],0,1),m=Ze(i[1],0,1),y=Ze(i[2],0,1),g=Ze(i[3],0,1);let x,b,v,_;if(d!==m&&a!==s&&m!==d){const t=a-s;b=1/(t*(m-d)),v=-(s+t*d)/(t*(m-d));const e=Ze(i[4],-1,1);_=Math.pow(10,e),x=255*y<<8|255*g;}else x=65535,b=0,v=1,_=1;if(t.emplaceBack(h,p,f,x,b,v,_),o){const t=o.length;o.clear();for(let e=0;e>16&65535,o=s?e>>16&65535:65535&e,l=(15&o)<8?15&o:0,u=t.evaluatedRMEA[l],c=t.evaluatedColor[l],h=t.emissionHeightBasedParams[l];let p;if(a&&2===l&&n.lights&&(p=new Jl,p.resize(10*n.lights.length)),xb(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&a){a=!1;const t=n.meshes[n.lightMeshIndex];t.featureArray=p,t.featureArray._trim();}}r.featureArray._trim(),i++;}}function vb(t,e,r,n){const i=1<t.polygon)).flat());const g=d?l:null,[x,b]=function(e,r,n,i,s,a,o,l,u,c,h){return \"globe\"===e.projection.name?function(e,r,n,i,s,a,o,l,u,c,h){const p=[],f=[],d=e.projection.upVectorScale(h,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],y=[0,0,0,1],g=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},x=ad();n>0&&(n+=x),i+=x;for(const x of r){const r=[],b=[];for(const p of x){const f=p.x+s.x,x=p.y+s.y,v=e.projection.projectTilePoint(f,x,h),_=e.projection.upVector(h,p.x,p.y);let w=n,M=i;if(o){const t=dd(f,x,n,i,o,l,u,c);w+=t.base,M+=t.top;}0!==n?g(m,v.x+_[0]*d*w,v.y+_[1]*d*w,v.z+_[2]*d*w):g(m,v.x,v.y,v.z),g(y,v.x+_[0]*d*M,v.y+_[1]*d*M,v.z+_[2]*d*M),t.Q.transformMat4(m,m,a),t.Q.transformMat4(y,y,a),r.push(new hd(m[0],m[1],m[2])),b.push(new hd(y[0],y[1],y[2]));}p.push(r),f.push(b);}return [p,f]}(e,r,n,i,s,a,o,l,u,c,h):o?function(e,r,n,i,s,a,o,l,u){const c=[],h=[],p=[0,0,0,1];for(const f of e){const e=[],d=[];for(const c of f){const h=c.x+i.x,f=c.y+i.y,m=dd(h,f,r,n,a,o,l,u);p[0]=h,p[1]=f,p[2]=m.base,p[3]=1,t.aa.transformMat4(p,p,s),p[3]=Math.max(p[3],1e-5);const y=new hd(p[0]/p[3],p[1]/p[3],p[2]/p[3]);p[0]=h,p[1]=f,p[2]=m.top,p[3]=1,t.aa.transformMat4(p,p,s),p[3]=Math.max(p[3],1e-5);const g=new hd(p[0]/p[3],p[1]/p[3],p[2]/p[3]);e.push(y),d.push(g);}c.push(e),h.push(d);}return [c,h]}(r,n,i,s,a,o,l,u,c):function(t,e,r,n,i){const s=[],a=[],o=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x+n.x,a=s.y+n.y,m=i[0]*e+i[4]*a+i[12],y=i[1]*e+i[5]*a+i[13],g=i[2]*e+i[6]*a+i[14],x=i[3]*e+i[7]*a+i[15],b=m+o,v=y+l,_=g+u,w=Math.max(x+c,1e-5),M=m+h,A=y+p,S=g+f,I=Math.max(x+d,1e-5);t.push(new hd(b/w,v/w,_/w)),r.push(new hd(M/I,A/I,S/I));}s.push(t),a.push(r);}return [s,a]}(r,n,i,s,a)}(a,i,p,h,c,o,g,f,m,a.center.lat,e.tileID.canonical),v=e.queryGeometry;return function(t,e,r){let n=1/0;$c(r,e)&&(n=fd(r,e[0]));for(let i=0;i=3)for(let e=0;e\n * @license BSD-3-Clause\n * @version 11.2.6\n */\nclass Ab{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev);}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null);}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0));}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,n=this.resetTtl){let i;if(r||this.has(t)){if(i=this.items[t],i.value=e,!1===r&&n&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,r=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==r&&(r.next=e),null!==e&&(e.prev=r);}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function Sb(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let r=e[3];for(let n=2;n>=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function kb(t,e){switch(e){case\"uint32\":return t;case\"uint16\":for(let e=0;e>4|(61440&r)>>8|(240&n)<<4|61440&n,t[e+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return t;case\"uint8\":for(let e=0;e>6|(192&n)>>4|(192&i)>>2|192&s,t[e+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,t[e+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,t[e+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return t;default:throw new Error(`Invalid pixel format, \"${e}\"`)}}class Pb extends Error{constructor(t){super(t),this.name=\"MRTError\";}}var Eb=Uint8Array,zb=Uint16Array,Tb=Int32Array,Bb=new Eb([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]),Cb=new Eb([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]),Rb=new Eb([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vb=function(t,e){for(var r=new zb(31),n=0;n<31;++n)r[n]=e+=1<>1|(21845&Nb)<<1;Ub[Nb]=((65280&(jb=(61680&(jb=(52428&jb)>>2|(13107&jb)<<2))>>4|(3855&jb)<<4))>>8|(255&jb)<<8)>>1;}var qb=function(t,e,r){for(var n=t.length,i=0,s=new zb(e);i>l]=u;}else for(a=new zb(n),i=0;i>15-t[i]);return a},$b=new Eb(288);for(Nb=0;Nb<144;++Nb)$b[Nb]=8;for(Nb=144;Nb<256;++Nb)$b[Nb]=9;for(Nb=256;Nb<280;++Nb)$b[Nb]=7;for(Nb=280;Nb<288;++Nb)$b[Nb]=8;var Gb=new Eb(32);for(Nb=0;Nb<32;++Nb)Gb[Nb]=5;var Qb=qb($b,9,1),Yb=qb(Gb,5,1),Xb=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},Zb=function(t,e,r){var n=e/8|0;return (t[n]|t[n+1]<<8)>>(7&e)&r},Kb=function(t,e){var r=e/8|0;return (t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&e)},Wb=[\"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\"],Hb=function(t,e,r){var n=new Error(e||Wb[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,Hb),!r)throw n;return n},Jb=new Eb(0),tv=\"undefined\"!=typeof TextDecoder&&new TextDecoder;try{tv.decode(Jb,{stream:!0});}catch(t){}const ev={gzip_data:\"gzip\"};const rv={0:\"uint32\",1:\"uint32\",2:\"uint16\",3:\"uint8\"},nv={uint32:1,uint16:2,uint8:4},iv={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class sv{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t;}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),r=new DataView(t);if(13!==e[0])throw new Pb(\"File is not a valid MRT.\");return r.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),r=this.getHeaderLength(t);if(e.length= ${r} but got buffer of length ${e.length}`);const n=new wm(e.subarray(0,r)),i=wb.read(n);if(!isNaN(this.x)&&(this.x!==i.x||this.y!==i.y||this.z!==i.z))throw new Pb(`Invalid attempt to parse header ${i.z}/${i.x}/${i.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=i.x,this.y=i.y,this.z=i.z;for(const t of i.layers)this.layers[t.name]=new av(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],r=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:s,lastByte:a,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map((t=>t.filter))};r._blocksInProgress.add(n),e.push(o);}return new ov(e,(()=>{e.forEach((t=>r._blocksInProgress.delete(t.blockIndex)));}),((t,n)=>{if(e.forEach((t=>r._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t);}));}))}}class av{constructor({version:t,name:e,units:r,tilesize:n,pixel_format:i,buffer:s,data_index:a},o){if(this.version=t,1!==this.version)throw new Pb(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=rv[i],this.dataIndex=a,this.bandShape=[n+2*s,n+2*s,nv[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,r=!1){if(isNaN(t)||t<0)throw new TypeError(\"Invalid max value\");if(isNaN(e)||e<0)throw new TypeError(\"Invalid ttl value\");if(\"boolean\"!=typeof r)throw new TypeError(\"Invalid resetTtl value\");return new Ab(t,e,r)}(o?o.cacheSize:5),this._blocksInProgress=new Set;}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.set(e,t.data);}getBlockForBand(t){let e=0;switch(typeof t){case\"string\":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===t)return {bandIndex:e+i,blockIndex:r,blockBandIndex:i};e+=n.bands.length;}break;case\"number\":for(const[r,n]of this.dataIndex.entries()){if(t>=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:r}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Pb(`Data for band ${JSON.stringify(t)} of layer \"${this.name}\" not decoded.`);const i=this.dataIndex[e],s=this.bandShape.reduce(((t,e)=>t*e),1),a=r*s,o=n.subarray(a,a+s);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:i.offset,scale:i.scale}}}class ov{constructor(t,e,r){this.tasks=t,this._onCancel=e,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0);}}sv.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:r,firstByte:n,lastByte:i,pixelFormat:s,blockShape:a,blockIndex:o,filters:l,codec:u}=e,c=new Uint8Array(t).subarray(n,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let p;if(\"gzip_data\"!==u)throw new Error(`Unhandled codec: ${u}`);return p=function(t,e){if(!globalThis.DecompressionStream&&\"gzip_data\"===e)return Promise.resolve(((s=function(t){31==t[0]&&139==t[1]&&8==t[2]||Hb(6,\"invalid gzip data\");var e=t[3],r=10;4&e&&(r+=2+(t[10]|t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(2&e)}(i=t))+8>i.length&&Hb(6,\"invalid gzip data\"),function(t,e,r,n){var i=t.length;if(!i||e.f&&!e.l)return r||new Eb(0);var s=!r,a=s||2!=e.i,o=e.i;s&&(r=new Eb(3*i));var l,u,c=function(t){var e=r.length;if(t>e){var n=new Eb(Math.max(2*e,t));n.set(r),r=n;}},h=e.f||0,p=e.p||0,f=e.b||0,d=e.l,m=e.d,y=e.m,g=e.n,x=8*i;do{if(!d){h=Zb(t,p,1);var b=Zb(t,p+1,3);if(p+=3,!b){var v=t[(T=4+((p+7)/8|0))-4]|t[T-3]<<8,_=T+v;if(_>i){o&&Hb(0);break}a&&c(f+v),r.set(t.subarray(T,_),f),e.b=f+=v,e.p=p=8*_,e.f=h;continue}if(1==b)d=Qb,m=Yb,y=9,g=5;else if(2==b){var w=Zb(t,p,31)+257,M=Zb(t,p+10,15)+4,A=w+Zb(t,p+5,31)+1;p+=14;for(var S=new Eb(A),I=new Eb(19),k=0;k>4)<16)S[k++]=T;else {var C=0,R=0;for(16==T?(R=3+Zb(t,p,3),p+=2,C=S[k-1]):17==T?(R=3+Zb(t,p,7),p+=3):18==T&&(R=11+Zb(t,p,127),p+=7);R--;)S[k++]=C;}}var V=S.subarray(0,w),D=S.subarray(w);y=Xb(V),g=Xb(D),d=qb(V,y,1),m=qb(D,g,1);}else Hb(1);if(p>x){o&&Hb(0);break}}a&&c(f+131072);for(var L=(1<>4;if((p+=15&C)>x){o&&Hb(0);break}if(C||Hb(2),U<256)r[f++]=U;else {if(256==U){O=p,d=null;break}var N=U-254;U>264&&(N=Zb(t,p,(1<<($=Bb[k=U-257]))-1)+Lb[k],p+=$);var j=m[Kb(t,p)&F],q=j>>4;if(j||Hb(3),p+=15&j,D=Ob[q],q>3){var $=Cb[q];D+=Kb(t,p)&(1<<$)-1,p+=$;}if(p>x){o&&Hb(0);break}a&&c(f+131072);var G=f+N;if(fl.length)&&(u=l.length),new Eb(l.subarray(0,u))):r.subarray(0,f)}(i.subarray(s,-8),{i:2},new Eb(((r=i)[(n=r.length)-4]|r[n-3]<<8|r[n-2]<<16|r[n-1]<<24)>>>0))));var r,n,i,s;const a=ev[e];if(!a)throw new Error(`Unhandled codec: ${e}`);const o=new globalThis.DecompressionStream(a);return new Response(new Blob([t]).stream().pipeThrough(o)).arrayBuffer().then((t=>new Uint8Array(t)))}(c,u).then((t=>{const e=Mb.read(new wm(t));if(\"uint32_values\"===e.values)return e.uint32_values.readValuesInto(h),new(0,iv[s])(h.buffer);throw new Error(`Unhandled numeric data \"${e.values}\"`)})),p.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case\"delta_filter\":Sb(t,a);break;case\"zigzag_filter\":Ib(t);break;case\"bitshuffle_filter\":kb(t,s);break;default:throw new Error(`Unhandled filter \"${l[e]}\"`)}return {layerName:r,blockIndex:o,data:t}})).catch((t=>{throw t}))})))},fo(ov,\"MRTDecodingBatch\",{omit:[\"_onCancel\",\"_onComplete\"]});const lv=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class uv{static from(t){if(!(t instanceof ArrayBuffer))throw new Error(\"Data must be an instance of ArrayBuffer.\");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error(\"Data does not appear to be in a KDBush format.\");const n=r>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=lv[15&r];if(!i)throw new Error(\"Unrecognized array type.\");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new uv(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=lv.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return cv(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error(\"Data not yet indexed - call index.finish().\");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error(\"Data not yet indexed - call index.finish().\");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)dv(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];dv(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function cv(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;hv(t,e,a,n,i,s),cv(t,e,r,n,a-1,1-s),cv(t,e,r,a+1,i,1-s);}function hv(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);hv(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(pv(t,e,n,r),e[2*i+s]>a&&pv(t,e,n,i);o