|
|
Highlight
<H1> | <H2> | <H3> | <H4> | <H5> | <H6> | <B> | <U> | <I> | <EM> | <STRONG> | Total | 1 | 6 | 9 | 0 | 0 | 0 | 0 | 0 | 57 | 0 | 7 | 80 | Excellent! The page is using HTML headings (<H1> - <H6>) and inline emphasis tags (<EM><B><I><EM><STRONG>)
|
<H1> (1) | | <H2> (6) | Poznaj nowoczesne formy finansowania stworzone dla dynamicznych przedsiębiorców i klientów indywidualnych, które pozwolą Ci pozostać w ruchu. Postaw na elastyczność inteligentnych rozwiązań. Czym jest KINTO? Poznaj naszą wizję PRODUKTY KINTO Szeroka sieć dilerska Wypełnij formularz, a my skontaktujemy się z Tobą
| <H3> (9) | Elastyczność Komfort Doświadczenie Zaufanie LEASINGNIŻSZYCH RAT LEASINGKONSUMENCKI KINTO WYNAJEMI ZARZĄDZANIE FLOTĄ LEASINGDLA PRACOWNIKÓW NAJEM
| <I> (57) | this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()=2&&e[0]instanceof B&&e[0].equals(e[i-1])&&e.pop(),e},_setLatLngs:function(t){Ri.prototype._setLatLngs.call(this,t),_i(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return _i(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,e=this.options.weight,i=new P(e,e);if(t=new k(t.min.subtract(i),t.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var n,r=0,o=this._rings.length;rt.y!=n.y>t.y&&t.x0&&r.push(r[0].slice()),r}function Zi(t,i){return t.feature?e({},t.feature,{geometry:i}):qi(i)}function qi(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}var Hi={toGeoJSON:function(t){return Zi(this,{type:"Point",coordinates:ji(this.getLatLng(),t)})}};function Wi(t,e){return new Bi(t,e)}$i.include(Hi),zi.include(Hi),ki.include(Hi),Ri.include({toGeoJSON:function(t){var e=!_i(this._latlngs);return Zi(this,{type:(e?"Multi":"")+"LineString",coordinates:Gi(this._latlngs,e?1:0,!1,t)})}}),Oi.include({toGeoJSON:function(t){var e=!_i(this._latlngs),i=e&&!_i(this._latlngs[0]),n=Gi(this._latlngs,i?2:e?1:0,!0,t);return e||(n=[n]),Zi(this,{type:(i?"Multi":"")+"Polygon",coordinates:n})}}),Ci.include({toMultiPoint:function(t){var e=[];return this.eachLayer((function(i){e.push(i.toGeoJSON(t).geometry.coordinates)})),Zi(this,{type:"MultiPoint",coordinates:e})},toGeoJSON:function(t){var e=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===e)return this.toMultiPoint(t);var i="GeometryCollection"===e,n=[];return this.eachLayer((function(e){if(e.toGeoJSON){var r=e.toGeoJSON(t);if(i)n.push(r.geometry);else{var o=qi(r);"FeatureCollection"===o.type?n.push.apply(n,o.features):n.push(o)}}})),i?Zi(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}});var Yi=Wi,Xi=Ei.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(t,e,i){this._url=t,this._bounds=O(e),d(this,i)},onAdd:function(){this._image||(this._initImage(),this.options.opacity0?r:[e.src]}else{_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(e.style,"objectFit")&&(e.style.objectFit="fill"),e.autoplay=!!this.options.autoplay,e.loop=!!this.options.loop,e.muted=!!this.options.muted,e.playsInline=!!this.options.playsInline;for(var s=0;s×',Ce(n,"click",(function(t){Oe(t),this.close()}),this)}},_updateLayout:function(){var t=this._contentNode,e=t.style;e.width="",e.whiteSpace="nowrap";var i=t.offsetWidth;i=Math.min(i,this.options.maxWidth),i=Math.max(i,this.options.minWidth),e.width=i+1+"px",e.whiteSpace="",e.height="";var n=t.offsetHeight,r=this.options.maxHeight,o="leaflet-popup-scrolled";r&&n>r?(e.height=r+"px",he(t,o)):ue(t,o),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();ge(this._container,e.add(i))},_adjustPan:function(){if(this.options.autoPan)if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var t=this._map,e=parseInt(ne(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+e,n=this._containerWidth,r=new P(this._containerLeft,-i-this._containerBottom);r._add(ye(this._container));var o=t.layerPointToContainerPoint(r),s=D(this.options.autoPanPadding),a=D(this.options.autoPanPaddingTopLeft||s),l=D(this.options.autoPanPaddingBottomRight||s),c=t.getSize(),h=0,u=0;o.x+n+l.x>c.x&&(h=o.x+n-c.x+l.x),o.x-h-a.xc.y&&(u=o.y+i-c.y+l.y),o.y-u-a.ythis.options.maxZoom||in&&this._retainParent(r,o,s,n))},_retainChildren:function(t,e,i,n){for(var r=2*t;rthis.options.maxZoom||void 0!==this.options.minZoom&&r1)this._setView(t,i);else{for(var u=r.min.y;ui.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return O(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),r=n.add(i);return[e.unproject(n,t.z),e.unproject(r,t.z)]},_tileCoordsToBounds:function(t){var e=this._tileCoordsToNwSe(t),i=new R(e[0],e[1]);return this.options.noWrap||(i=this._map.wrapLatLngBounds(i)),i},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),i=new P(+e[0],+e[1]);return i.z=+e[2],i},_removeTile:function(t){var e=this._tiles[t];e&&(oe(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){he(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=l,t.onmousemove=l,kt.ielt9&&this.options.opacity0?(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom=Math.min(e.maxZoom,e.minZoom+1)):(e.zoomOffset++,e.maxZoom=Math.max(e.minZoom,e.maxZoom-1)),e.minZoom=Math.max(0,e.minZoom)):e.zoomReverse?e.minZoom=Math.min(e.maxZoom,e.minZoom):e.maxZoom=Math.max(e.minZoom,e.maxZoom),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(t,e){return this._url===t&&void 0===e&&(e=!0),this._url=t,e||this.redraw(),this},createTile:function(t,e){var i=document.createElement("img");return Ce(i,"load",n(this._tileOnLoad,this,e,i)),Ce(i,"error",n(this._tileOnError,this,e,i)),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),"string"==typeof this.options.referrerPolicy&&(i.referrerPolicy=this.options.referrerPolicy),i.alt="",i.src=this.getTileUrl(t),i},getTileUrl:function(t){var i={r:kt.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var n=this._globalTileRange.max.y-t.y;this.options.tms&&(i.y=n),i["-y"]=n}return m(this._url,e(i,this.options))},_tileOnLoad:function(t,e){kt.ielt9?setTimeout(n(t,this,null,e),0):t(null,e)},_tileOnError:function(t,e,i){var n=this.options.errorTileUrl;n&&e.getAttribute("src")!==n&&(e.src=n),t(i,e)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,e=this.options.maxZoom;return this.options.zoomReverse&&(t=e-t),t+this.options.zoomOffset},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,e;for(t in this._tiles)if(this._tiles[t].coords.z!==this._tileZoom&&((e=this._tiles[t].el).onload=l,e.onerror=l,!e.complete)){e.src=y;var i=this._tiles[t].coords;oe(e),delete this._tiles[t],this.fire("tileabort",{tile:e,coords:i})}},_removeTile:function(t){var e=this._tiles[t];if(e)return e.el.setAttribute("src",y),rn.prototype._removeTile.call(this,t)},_tileReady:function(t,e,i){if(this._map&&(!i||i.getAttribute("src")!==y))return rn.prototype._tileReady.call(this,t,e,i)}});function sn(t,e){return new on(t,e)}var an=on.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,i){this._url=t;var n=e({},this.defaultWmsParams);for(var r in i)r in this.options||(n[r]=i[r]);var o=(i=d(this,i)).detectRetina&&kt.retina?2:1,s=this.getTileSize();n.width=s.x*o,n.height=s.y*o,this.wmsParams=n},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,on.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._tileCoordsToNwSe(t),i=this._crs,n=z(i.project(e[0]),i.project(e[1])),r=n.min,o=n.max,s=(this._wmsVersion>=1.3&&this._crs===Si?[r.y,r.x,o.y,o.x]:[r.x,r.y,o.x,o.y]).join(","),a=on.prototype.getTileUrl.call(this,t);return a+p(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+s},setParams:function(t,i){return e(this.wmsParams,t),i||this.redraw(),this}});on.WMS=an,sn.wms=function(t,e){return new an(t,e)};var ln=Ei.extend({options:{padding:.1},initialize:function(t){d(this,t),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),he(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,e){var i=this._map.getZoomScale(e,this._zoom),n=this._map.getSize().multiplyBy(.5+this.options.padding),r=this._map.project(this._center,e),o=n.multiplyBy(-i).add(r).subtract(this._map._getNewPixelOrigin(t,e));kt.any3d?_e(this._container,o,i):ge(this._container,o)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,e=this._map.getSize(),i=this._map.containerPointToLayerPoint(e.multiplyBy(-t)).round();this._bounds=new k(i,i.add(e.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),cn=ln.extend({options:{tolerance:0},getEvents:function(){var t=ln.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){ln.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");Ce(t,"mousemove",this._onMouseMove,this),Ce(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ce(t,"mouseout",this._handleMouseOut,this),t._leaflet_disable_events=!0,this._ctx=t.getContext("2d")},_destroyContainer:function(){M(this._redrawRequest),delete this._ctx,oe(this._container),Ae(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){ln.prototype._update.call(this);var t=this._bounds,e=this._container,i=t.getSize(),n=kt.retina?2:1;ge(e,t.min),e.width=n*i.x,e.height=n*i.y,e.style.width=i.x+"px",e.style.height=i.y+"px",kt.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){ln.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[o(t)]=t;var e=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var e=t._order,i=e.next,n=e.prev;i?i.prev=n:this._drawLast=n,n?n.next=i:this._drawFirst=i,delete t._order,delete this._layers[o(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if("string"==typeof t.options.dashArray){var e,i,n=t.options.dashArray.split(/[, ]+/),r=[];for(i=0;i')}}catch(t){}return function(t){return document.createElement("')}}(),dn={_initContainer:function(){this._container=re("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(ln.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=un("shape");he(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=un("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[o(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;oe(e),t.removeInteractiveTarget(e),delete this._layers[o(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,r=t._container;r.stroked=!!n.stroke,r.filled=!!n.fill,n.stroke?(e||(e=t._stroke=un("stroke")),r.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=_(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(r.removeChild(e),t._stroke=null),n.fill?(i||(i=t._fill=un("fill")),r.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(r.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){ae(t._container)},_bringToBack:function(t){le(t._container)}},pn=kt.vml?un:Y,fn=ln.extend({_initContainer:function(){this._container=pn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=pn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){oe(this._container),Ae(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!this._map._animatingZoom||!this._bounds){ln.prototype._update.call(this);var t=this._bounds,e=t.getSize(),i=this._container;this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),ge(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}},_initPath:function(t){var e=t._path=pn("path");t.options.className&&he(e,t.options.className),t.options.interactive&&he(e,"leaflet-interactive"),this._updateStyle(t),this._layers[o(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){oe(t._path),t.removeInteractiveTarget(t._path),delete this._layers[o(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,i=t.options;e&&(i.stroke?(e.setAttribute("stroke",i.color),e.setAttribute("stroke-opacity",i.opacity),e.setAttribute("stroke-width",i.weight),e.setAttribute("stroke-linecap",i.lineCap),e.setAttribute("stroke-linejoin",i.lineJoin),i.dashArray?e.setAttribute("stroke-dasharray",i.dashArray):e.removeAttribute("stroke-dasharray"),i.dashOffset?e.setAttribute("stroke-dashoffset",i.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),i.fill?(e.setAttribute("fill",i.fillColor||i.color),e.setAttribute("fill-opacity",i.fillOpacity),e.setAttribute("fill-rule",i.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,X(t._parts,e))},_updateCircle:function(t){var e=t._point,i=Math.max(Math.round(t._radius),1),n="a"+i+","+(Math.max(Math.round(t._radiusY),1)||i)+" 0 1,0 ",r=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+n+2*i+",0 "+n+2*-i+",0 ";this._setPath(t,r)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){ae(t._path)},_bringToBack:function(t){le(t._path)}});function mn(t){return kt.svg||kt.vml?new fn(t):null}kt.vml&&fn.include(dn),qe.include({getRenderer:function(t){var e=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var e=this._paneRenderers[t];return void 0===e&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&hn(t)||mn(t)}});var _n=Oi.extend({initialize:function(t,e){Oi.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=O(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});fn.create=pn,fn.pointsToPath=X,Bi.geometryToLayer=Fi,Bi.coordsToLatLng=Ui,Bi.coordsToLatLngs=Vi,Bi.latLngToCoords=ji,Bi.latLngsToCoords=Gi,Bi.getFeature=Zi,Bi.asFeature=qi,qe.mergeOptions({boxZoom:!0});var gn=Qe.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){Ce(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Ae(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){oe(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Wt(),xe(),this._startPoint=this._map.mouseEventToContainerPoint(t),Ce(document,{contextmenu:Be,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=re("div","leaflet-zoom-box",this._container),he(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new k(this._point,this._startPoint),i=e.getSize();ge(this._box,e.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(oe(this._box),ue(this._container,"leaflet-crosshair")),Yt(),be(),Ae(document,{contextmenu:Be,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(n(this._resetState,this),0);var e=new R(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});qe.addInitHook("addHandler","boxZoom",gn),qe.mergeOptions({doubleClickZoom:!0});var yn=Qe.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,r=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(r):e.setZoomAround(t.containerPoint,r)}});qe.addInitHook("addHandler","doubleClickZoom",yn),qe.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var vn=Qe.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ii(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}he(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){ue(this._map._container,"leaflet-grab"),ue(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=O(this._map.options.maxBounds);this._offsetLimit=z(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(i),this._times.push(e),this._prunePositions(e)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;this._positions.length>1&&t-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,e){return t-(t-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;t.xe.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,r=(n-e+i)%t+e-i,o=(n+e+i)%t-e-i,s=Math.abs(r+i)0?o:-o))-e;this._delta=0,this._startTime=null,s&&("center"===t.options.scrollWheelZoom?t.setZoom(e+s):t.setZoomAround(this._lastMousePos,e+s))}});qe.addInitHook("addHandler","scrollWheelZoom",bn);qe.mergeOptions({tapHold:kt.touchNative&&kt.safari&&kt.mobile,tapTolerance:15});var wn=Qe.extend({addHooks:function(){Ce(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Ae(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(clearTimeout(this._holdTimeout),1===t.touches.length){var e=t.touches[0];this._startPos=this._newPos=new P(e.clientX,e.clientY),this._holdTimeout=setTimeout(n((function(){this._cancel(),this._isTapValid()&&(Ce(document,"touchend",Oe),Ce(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",e))}),this),600),Ce(document,"touchend touchcancel contextmenu",this._cancel,this),Ce(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function t(){Ae(document,"touchend",Oe),Ae(document,"touchend touchcancel",t)},_cancel:function(){clearTimeout(this._holdTimeout),Ae(document,"touchend touchcancel contextmenu",this._cancel,this),Ae(document,"touchmove",this._onMove,this)},_onMove:function(t){var e=t.touches[0];this._newPos=new P(e.clientX,e.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)e.getMaxZoom()&&o>1)&&(this._zoom=e._limitZoom(this._zoom)),"center"===e.options.touchZoom){if(this._center=this._startLatLng,1===o)return}else{var s=i._add(r)._divideBy(2)._subtract(this._centerPoint);if(1===o&&0===s.x&&0===s.y)return;this._center=e.unproject(e.project(this._pinchStartLatLng,this._zoom).subtract(s),this._zoom)}this._moved||(e._moveStart(!0,!1),this._moved=!0),M(this._animRequest);var a=n(e._move,e,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=S(a,this,!0),Oe(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,M(this._animRequest),Ae(document,"touchmove",this._onTouchMove,this),Ae(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});qe.addInitHook("addHandler","touchZoom",Tn),qe.BoxZoom=gn,qe.DoubleClickZoom=yn,qe.Drag=vn,qe.Keyboard=xn,qe.ScrollWheelZoom=bn,qe.TapHold=wn,qe.TouchZoom=Tn,t.Bounds=k,t.Browser=kt,t.CRS=U,t.Canvas=cn,t.Circle=zi,t.CircleMarker=ki,t.Class=C,t.Control=He,t.DivIcon=nn,t.DivOverlay=Qi,t.DomEvent=Ge,t.DomUtil=Ee,t.Draggable=ii,t.Evented=A,t.FeatureGroup=Ii,t.GeoJSON=Bi,t.GridLayer=rn,t.Handler=Qe,t.Icon=Ai,t.ImageOverlay=Xi,t.LatLng=B,t.LatLngBounds=R,t.Layer=Ei,t.LayerGroup=Ci,t.LineUtil=vi,t.Map=qe,t.Marker=$i,t.Mixin=ti,t.Path=Di,t.Point=P,t.PolyUtil=ai,t.Polygon=Oi,t.Polyline=Ri,t.Popup=tn,t.PosAnimation=Ze,t.Projection=wi,t.Rectangle=_n,t.Renderer=ln,t.SVG=fn,t.SVGOverlay=Ji,t.TileLayer=on,t.Tooltip=en,t.Transformation=Z,t.Util=E,t.VideoOverlay=Ki,t.bind=n,t.bounds=z,t.canvas=hn,t.circle=function(t,e,i){return new zi(t,e,i)},t.circleMarker=function(t,e){return new ki(t,e)},t.control=We,t.divIcon=function(t){return new nn(t)},t.extend=e,t.featureGroup=function(t,e){return new Ii(t,e)},t.geoJSON=Wi,t.geoJson=Yi,t.gridLayer=function(t){return new rn(t)},t.icon=function(t){return new Ai(t)},t.imageOverlay=function(t,e,i){return new Xi(t,e,i)},t.latLng=F,t.latLngBounds=O,t.layerGroup=function(t,e){return new Ci(t,e)},t.map=function(t,e){return new qe(t,e)},t.marker=function(t,e){return new $i(t,e)},t.point=D,t.polygon=function(t,e){return new Oi(t,e)},t.polyline=function(t,e){return new Ri(t,e)},t.popup=function(t,e){return new tn(t,e)},t.rectangle=function(t,e){return new _n(t,e)},t.setOptions=d,t.stamp=o,t.svg=mn,t.svgOverlay=function(t,e,i){return new Ji(t,e,i)},t.tileLayer=sn,t.tooltip=function(t,e){return new en(t,e)},t.transformation=q,t.version="1.9.4",t.videoOverlay=function(t,e,i){return new Ki(t,e,i)};var Sn=window.L;t.noConflict=function(){return window.L=Sn,this},window.L=t}(e)},3559:function(t,e,i){var n,r,o;r=[i(3481),i(842)],void 0===(o="function"==typeof(n=function(t,e){t.MapboxGL=t.Layer.extend({options:{updateInterval:32,padding:.1,interactive:!1,pane:"tilePane"},initialize:function(i){t.setOptions(this,i),i.accessToken&&(e.accessToken=i.accessToken),this._throttledUpdate=t.Util.throttle(this._update,this.options.updateInterval,this)},onAdd:function(e){this._container||this._initContainer();var i=this.getPaneName();e.getPane(i).appendChild(this._container),this._initGL(),this._offset=this._map.containerPointToLayerPoint([0,0]),e.options.zoomAnimation&&t.DomEvent.on(e._proxy,t.DomUtil.TRANSITION_END,this._transitionEnd,this),e._addZoomLimit(this)},onRemove:function(e){this._map._proxy&&this._map.options.zoomAnimation&&t.DomEvent.off(this._map._proxy,t.DomUtil.TRANSITION_END,this._transitionEnd,this);var i=this.getPaneName();e.getPane(i).removeChild(this._container)},getEvents:function(){return{move:this._throttledUpdate,zoomanim:this._animateZoom,zoom:this._pinchZoom,zoomstart:this._zoomStart,zoomend:this._zoomEnd,resize:this._resize}},getMapboxMap:function(){return this._glMap},getCanvas:function(){return this._glMap.getCanvas()},getSize:function(){return this._map.getSize().multiplyBy(1+2*this.options.padding)},getBounds:function(){var e=this.getSize().multiplyBy(.5),i=this._map.latLngToContainerPoint(this._map.getCenter());return t.latLngBounds(this._map.containerPointToLatLng(i.subtract(e)),this._map.containerPointToLatLng(i.add(e)))},getContainer:function(){return this._container},getPaneName:function(){return this._map.getPane(this.options.pane)?this.options.pane:"tilePane"},_initContainer:function(){var e=this._container=t.DomUtil.create("div","leaflet-gl-layer"),i=this.getSize(),n=this._map.getSize().multiplyBy(this.options.padding);e.style.width=i.x+"px",e.style.height=i.y+"px";var r=this._map.containerPointToLayerPoint([0,0]).subtract(n);t.DomUtil.setPosition(e,r)},_initGL:function(){var i=this._map.getCenter(),n=t.extend({},this.options,{container:this._container,center:[i.lng,i.lat],zoom:this._map.getZoom()-1,attributionControl:!1});this._glMap?(this._glMap.setCenter(n.center),this._glMap.setZoom(n.zoom)):this._glMap=new e.Map(n),this._glMap.transform.latRange=null,this._transformGL(this._glMap),this._glMap._canvas.canvas?this._glMap._actualCanvas=this._glMap._canvas.canvas:this._glMap._actualCanvas=this._glMap._canvas;var r=this._glMap._actualCanvas;t.DomUtil.addClass(r,"leaflet-image-layer"),t.DomUtil.addClass(r,"leaflet-zoom-animated"),this.options.interactive&&t.DomUtil.addClass(r,"leaflet-interactive"),this.options.className&&t.DomUtil.addClass(r,this.options.className)},_update:function(e){if(this._map&&(this._offset=this._map.containerPointToLayerPoint([0,0]),!this._zooming)){var i=this.getSize(),n=this._container,r=this._glMap,o=this._map.getSize().multiplyBy(this.options.padding),s=this._map.containerPointToLayerPoint([0,0]).subtract(o);t.DomUtil.setPosition(n,s),this._transformGL(r);var a=Math.round(i.x),l=Math.round(i.y);Math.round(r.transform.width)!==a||Math.round(r.transform.height)!==l?(n.style.width=a+"px",n.style.height=l+"px",null!==r._resize&&void 0!==r._resize?r._resize():r.resize()):null!==r._update&&void 0!==r._update?r._update():r.update()}},_transformGL:function(t){var i=this._map.getCenter(),n=t.transform;n.center=e.LngLat.convert([i.lng,i.lat]),n.zoom=this._map.getZoom()-1},_pinchZoom:function(t){this._glMap.jumpTo({zoom:this._map.getZoom()-1,center:this._map.getCenter()})},_animateZoom:function(e){var i=this._map.getZoomScale(e.zoom),n=this._map.getSize().multiplyBy(this.options.padding*i),r=this.getSize()._divideBy(2),o=this._map.project(e.center,e.zoom)._subtract(r)._add(this._map._getMapPanePos().add(n))._round(),s=this._map.project(this._map.getBounds().getNorthWest(),e.zoom)._subtract(o);t.DomUtil.setTransform(this._glMap._actualCanvas,s.subtract(this._offset),i)},_zoomStart:function(t){this._zooming=!0},_zoomEnd:function(){var e=this._map.getZoomScale(this._map.getZoom());t.DomUtil.setTransform(this._glMap._actualCanvas,null,e),this._zooming=!1,this._update()},_transitionEnd:function(e){t.Util.requestAnimFrame((function(){var e=this._map.getZoom(),i=this._map.getCenter(),n=this._map.latLngToContainerPoint(this._map.getBounds().getNorthWest());t.DomUtil.setTransform(this._glMap._actualCanvas,n,1),this._glMap.once("moveend",t.Util.bind((function(){this._zoomEnd()}),this)),this._glMap.jumpTo({center:i,zoom:e-1})}),this)},_resize:function(t){this._transitionEnd(t)}}),t.mapboxGL=function(e){return new t.MapboxGL(e)}})?n.apply(e,r):n)||(t.exports=o)},842:function(t){t.exports=function(){"use strict";var t,e,i;function n(n,r){if(t)if(e){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",s={};t(s),i=r(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=r;else t=r}return n(0,(function(t){function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var i,n={},r={};function o(){if(i)return r;i=1,Object.defineProperty(r,"__esModule",{value:!0}),r.setMatrixArrayType=function(t){r.ARRAY_TYPE=e=t},r.toRadian=function(t){return t*o},r.equals=function(e,i){return Math.abs(e-i)0?(n[0]=2*(c*l+d*r+h*a-u*o)/p,n[1]=2*(h*l+d*o+u*r-c*a)/p,n[2]=2*(u*l+d*a+c*o-h*r)/p):(n[0]=2*(c*l+d*r+h*a-u*o),n[1]=2*(h*l+d*o+u*r-c*a),n[2]=2*(u*l+d*a+c*o-h*r)),s(t,i,n),t},_.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},_.getScaling=a,_.getRotation=function(t,i){var n=new e.ARRAY_TYPE(3);a(n,i);var r=1/n[0],o=1/n[1],s=1/n[2],l=i[0]*r,c=i[1]*o,h=i[2]*s,u=i[4]*r,d=i[5]*o,p=i[6]*s,f=i[8]*r,m=i[9]*o,_=i[10]*s,g=l+d+_,y=0;return g>0?(y=2*Math.sqrt(g+1),t[3]=.25*y,t[0]=(p-m)/y,t[1]=(f-h)/y,t[2]=(c-u)/y):l>d&&l>_?(y=2*Math.sqrt(1+l-d-_),t[3]=(p-m)/y,t[0]=.25*y,t[1]=(c+u)/y,t[2]=(f+h)/y):d>_?(y=2*Math.sqrt(1+d-l-_),t[3]=(f-h)/y,t[0]=(c+u)/y,t[1]=.25*y,t[2]=(p+m)/y):(y=2*Math.sqrt(1+_-l-d),t[3]=(c-u)/y,t[0]=(f+h)/y,t[1]=(p+m)/y,t[2]=.25*y),t},_.fromRotationTranslationScale=function(t,e,i,n){var r=e[0],o=e[1],s=e[2],a=e[3],l=r+r,c=o+o,h=s+s,u=r*l,d=r*c,p=r*h,f=o*c,m=o*h,_=s*h,g=a*l,y=a*c,v=a*h,x=n[0],b=n[1],w=n[2];return t[0]=(1-(f+_))*x,t[1]=(d+v)*x,t[2]=(p-y)*x,t[3]=0,t[4]=(d-v)*b,t[5]=(1-(u+_))*b,t[6]=(m+g)*b,t[7]=0,t[8]=(p+y)*w,t[9]=(m-g)*w,t[10]=(1-(u+f))*w,t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1,t},_.fromRotationTranslationScaleOrigin=function(t,e,i,n,r){var o=e[0],s=e[1],a=e[2],l=e[3],c=o+o,h=s+s,u=a+a,d=o*c,p=o*h,f=o*u,m=s*h,_=s*u,g=a*u,y=l*c,v=l*h,x=l*u,b=n[0],w=n[1],T=n[2],S=r[0],M=r[1],E=r[2],C=(1-(m+g))*b,I=(p+x)*b,A=(f-v)*b,L=(p-x)*w,P=(1-(d+g))*w,$=(_+y)*w,D=(f+v)*T,k=(_-y)*T,z=(1-(d+m))*T;return t[0]=C,t[1]=I,t[2]=A,t[3]=0,t[4]=L,t[5]=P,t[6]=$,t[7]=0,t[8]=D,t[9]=k,t[10]=z,t[11]=0,t[12]=i[0]+S-(C*S+L*M+D*E),t[13]=i[1]+M-(I*S+P*M+k*E),t[14]=i[2]+E-(A*S+$*M+z*E),t[15]=1,t},_.fromQuat=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=i+i,a=n+n,l=r+r,c=i*s,h=n*s,u=n*a,d=r*s,p=r*a,f=r*l,m=o*s,_=o*a,g=o*l;return t[0]=1-u-f,t[1]=h+g,t[2]=d-_,t[3]=0,t[4]=h-g,t[5]=1-c-f,t[6]=p+m,t[7]=0,t[8]=d+_,t[9]=p-m,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},_.frustum=function(t,e,i,n,r,o,s){var a=1/(i-e),l=1/(r-n),c=1/(o-s);return t[0]=2*o*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*l,t[6]=0,t[7]=0,t[8]=(i+e)*a,t[9]=(r+n)*l,t[10]=(s+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*c,t[15]=0,t},_.perspectiveNO=l,_.perspectiveZO=function(t,e,i,n,r){var o,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=r&&r!==1/0?(t[10]=r*(o=1/(n-r)),t[14]=r*n*o):(t[10]=-1,t[14]=-n),t},_.perspectiveFromFieldOfView=function(t,e,i,n){var r=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(r+o);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(s-a)*l*.5,t[9]=(r-o)*c*.5,t[10]=n/(i-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*i/(i-n),t[15]=0,t},_.orthoNO=c,_.orthoZO=function(t,e,i,n,r,o,s){var a=1/(e-i),l=1/(n-r),c=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+i)*a,t[13]=(r+n)*l,t[14]=o*c,t[15]=1,t},_.lookAt=function(t,i,r,o){var s,a,l,c,h,u,d,p,f,m,_=i[0],g=i[1],y=i[2],v=o[0],x=o[1],b=o[2],w=r[0],T=r[1],S=r[2];return Math.abs(_-w)0&&(h*=p=1/Math.sqrt(p),u*=p,d*=p);var f=l*d-c*u,m=c*h-a*d,_=a*u-l*h;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),t[0]=f,t[1]=m,t[2]=_,t[3]=0,t[4]=u*_-d*m,t[5]=d*f-h*_,t[6]=h*m-u*f,t[7]=0,t[8]=h,t[9]=u,t[10]=d,t[11]=0,t[12]=r,t[13]=o,t[14]=s,t[15]=1,t},_.str=function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},_.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},_.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t[6]=e[6]+i[6],t[7]=e[7]+i[7],t[8]=e[8]+i[8],t[9]=e[9]+i[9],t[10]=e[10]+i[10],t[11]=e[11]+i[11],t[12]=e[12]+i[12],t[13]=e[13]+i[13],t[14]=e[14]+i[14],t[15]=e[15]+i[15],t},_.subtract=h,_.multiplyScalar=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12]*i,t[13]=e[13]*i,t[14]=e[14]*i,t[15]=e[15]*i,t},_.multiplyScalarAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t[3]=e[3]+i[3]*n,t[4]=e[4]+i[4]*n,t[5]=e[5]+i[5]*n,t[6]=e[6]+i[6]*n,t[7]=e[7]+i[7]*n,t[8]=e[8]+i[8]*n,t[9]=e[9]+i[9]*n,t[10]=e[10]+i[10]*n,t[11]=e[11]+i[11]*n,t[12]=e[12]+i[12]*n,t[13]=e[13]+i[13]*n,t[14]=e[14]+i[14]*n,t[15]=e[15]+i[15]*n,t},_.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},_.equals=function(t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],v=i[0],x=i[1],b=i[2],w=i[3],T=i[4],S=i[5],M=i[6],E=i[7],C=i[8],I=i[9],A=i[10],L=i[11],P=i[12],$=i[13],D=i[14],k=i[15];return Math.abs(n-v)0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t},x.dot=d,x.cross=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return t[0]=r*l-o*a,t[1]=o*s-n*l,t[2]=n*a-r*s,t},x.lerp=function(t,e,i,n){var r=e[0],o=e[1],s=e[2];return t[0]=r+n*(i[0]-r),t[1]=o+n*(i[1]-o),t[2]=s+n*(i[2]-s),t},x.hermite=function(t,e,i,n,r,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),h=s*(3-2*o);return t[0]=e[0]*a+i[0]*l+n[0]*c+r[0]*h,t[1]=e[1]*a+i[1]*l+n[1]*c+r[1]*h,t[2]=e[2]*a+i[2]*l+n[2]*c+r[2]*h,t},x.bezier=function(t,e,i,n,r,o){var s=1-o,a=s*s,l=o*o,c=a*s,h=3*o*a,u=3*l*s,d=l*o;return t[0]=e[0]*c+i[0]*h+n[0]*u+r[0]*d,t[1]=e[1]*c+i[1]*h+n[1]*u+r[1]*d,t[2]=e[2]*c+i[2]*h+n[2]*u+r[2]*d,t},x.random=function(t,i){i=i||1;var n=2*e.RANDOM()*Math.PI,r=2*e.RANDOM()-1,o=Math.sqrt(1-r*r)*i;return t[0]=Math.cos(n)*o,t[1]=Math.sin(n)*o,t[2]=r*i,t},x.transformMat4=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return t[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),t[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,t[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,t},x.transformMat3=function(t,e,i){var n=e[0],r=e[1],o=e[2];return t[0]=n*i[0]+r*i[3]+o*i[6],t[1]=n*i[1]+r*i[4]+o*i[7],t[2]=n*i[2]+r*i[5]+o*i[8],t},x.transformQuat=function(t,e,i){var n=i[0],r=i[1],o=i[2],s=e[0],a=e[1],l=e[2],c=r*l-o*a,h=o*s-n*l,u=n*a-r*s,d=r*u-o*h,p=o*c-n*u,f=n*h-r*c,m=2*i[3];return h*=m,u*=m,p*=2,f*=2,t[0]=s+(c*=m)+(d*=2),t[1]=a+h+p,t[2]=l+u+f,t},x.rotateX=function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},x.rotateY=function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},x.rotateZ=function(t,e,i,n){var r=[],o=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],t[0]=o[0]+i[0],t[1]=o[1]+i[1],t[2]=o[2]+i[2],t},x.angle=function(t,e){var i=t[0],n=t[1],r=t[2],o=e[0],s=e[1],a=e[2],l=Math.sqrt(i*i+n*n+r*r)*Math.sqrt(o*o+s*s+a*a),c=l&&d(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))},x.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},x.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},x.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},x.equals=function(t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return Math.abs(n-s)0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=n*s,t[2]=r*s,t[3]=o*s,t},S.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},S.cross=function(t,e,i,n){var r=i[0]*n[1]-i[1]*n[0],o=i[0]*n[2]-i[2]*n[0],s=i[0]*n[3]-i[3]*n[0],a=i[1]*n[2]-i[2]*n[1],l=i[1]*n[3]-i[3]*n[1],c=i[2]*n[3]-i[3]*n[2],h=e[0],u=e[1],d=e[2],p=e[3];return t[0]=u*c-d*l+p*a,t[1]=-h*c+d*s-p*o,t[2]=h*l-u*s+p*r,t[3]=-h*a+u*o-d*r,t},S.lerp=function(t,e,i,n){var r=e[0],o=e[1],s=e[2],a=e[3];return t[0]=r+n*(i[0]-r),t[1]=o+n*(i[1]-o),t[2]=s+n*(i[2]-s),t[3]=a+n*(i[3]-a),t},S.random=function(t,i){var n,r,o,s,a,l;i=i||1;do{a=(n=2*e.RANDOM()-1)*n+(r=2*e.RANDOM()-1)*r}while(a>=1);do{l=(o=2*e.RANDOM()-1)*o+(s=2*e.RANDOM()-1)*s}while(l>=1);var c=Math.sqrt((1-a)/l);return t[0]=i*n,t[1]=i*r,t[2]=i*o*c,t[3]=i*s*c,t},S.transformMat4=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3];return t[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,t[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,t[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,t[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,t},S.transformQuat=function(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],l=i[2],c=i[3],h=c*n+a*o-l*r,u=c*r+l*n-s*o,d=c*o+s*r-a*n,p=-s*n-a*r-l*o;return t[0]=h*c+p*-s+u*-l-d*-a,t[1]=u*c+p*-a+d*-s-h*-l,t[2]=d*c+p*-l+h*-a-u*-s,t[3]=e[3],t},S.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},S.str=function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},S.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},S.equals=function(t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return Math.abs(n-a)e.EPSILON?(t[0]=i[0]/r,t[1]=i[1]/r,t[2]=i[2]/r):(t[0]=1,t[1]=0,t[2]=0),n},v.getAngle=function(t,e){var i=g(t,e);return Math.acos(2*i*i-1)},v.multiply=h,v.rotateX=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l+s*a,t[1]=r*l+o*a,t[2]=o*l-r*a,t[3]=s*l-n*a,t},v.rotateY=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l-o*a,t[1]=r*l+s*a,t[2]=o*l+n*a,t[3]=s*l-r*a,t},v.rotateZ=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l+r*a,t[1]=r*l-n*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t},v.calculateW=function(t,e){var i=e[0],n=e[1],r=e[2];return t[0]=i,t[1]=n,t[2]=r,t[3]=Math.sqrt(Math.abs(1-i*i-n*n-r*r)),t},v.exp=u,v.ln=d,v.pow=function(t,e,i){return d(t,e),_(t,t,i),u(t,t),t},v.slerp=p,v.random=function(t){var i=e.RANDOM(),n=e.RANDOM(),r=e.RANDOM(),o=Math.sqrt(1-i),s=Math.sqrt(i);return t[0]=o*Math.sin(2*Math.PI*n),t[1]=o*Math.cos(2*Math.PI*n),t[2]=s*Math.sin(2*Math.PI*r),t[3]=s*Math.cos(2*Math.PI*r),t},v.invert=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=i*i+n*n+r*r+o*o,a=s?1/s:0;return t[0]=-i*a,t[1]=-n*a,t[2]=-r*a,t[3]=o*a,t},v.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},v.fromMat3=m,v.fromEuler=function(t,e,i,n){var r=.5*Math.PI/180;e*=r,i*=r,n*=r;var o=Math.sin(e),s=Math.cos(e),a=Math.sin(i),l=Math.cos(i),c=Math.sin(n),h=Math.cos(n);return t[0]=o*l*h-s*a*c,t[1]=s*a*h+o*l*c,t[2]=s*l*c-o*a*h,t[3]=s*l*h+o*a*c,t},v.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},v.setAxes=v.sqlerp=v.rotationTo=v.equals=v.exactEquals=v.normalize=v.sqrLen=v.squaredLength=v.len=v.length=v.lerp=v.dot=v.scale=v.mul=v.add=v.set=v.copy=v.fromValues=v.clone=void 0;var e=a(o()),i=a(f()),n=a(b()),r=a(M());function s(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,i=new WeakMap;return(s=function(t){return t?i:e})(t)}function a(e,i){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return{default:e};var n=s(i);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var l=o?Object.getOwnPropertyDescriptor(e,a):null;l&&(l.get||l.set)?Object.defineProperty(r,a,l):r[a]=e[a]}return r.default=e,n&&n.set(e,r),r}function l(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function c(t,e,i){i*=.5;var n=Math.sin(i);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(i),t}function h(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=i[0],l=i[1],c=i[2],h=i[3];return t[0]=n*h+s*a+r*c-o*l,t[1]=r*h+s*l+o*a-n*c,t[2]=o*h+s*c+n*l-r*a,t[3]=s*h-n*a-r*l-o*c,t}function u(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=Math.sqrt(i*i+n*n+r*r),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return t[0]=i*l,t[1]=n*l,t[2]=r*l,t[3]=a*Math.cos(s),t}function d(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=Math.sqrt(i*i+n*n+r*r),a=s>0?Math.atan2(s,o)/s:0;return t[0]=i*a,t[1]=n*a,t[2]=r*a,t[3]=.5*Math.log(i*i+n*n+r*r+o*o),t}function p(t,i,n,r){var o,s,a,l,c,h=i[0],u=i[1],d=i[2],p=i[3],f=n[0],m=n[1],_=n[2],g=n[3];return(s=h*f+u*m+d*_+p*g)e.EPSILON?(o=Math.acos(s),a=Math.sin(o),l=Math.sin((1-r)*o)/a,c=Math.sin(r*o)/a):(l=1-r,c=r),t[0]=l*h+c*f,t[1]=l*u+c*m,t[2]=l*d+c*_,t[3]=l*p+c*g,t}function m(t,e){var i,n=e[0]+e[4]+e[8];if(n>0)i=Math.sqrt(n+1),t[3]=.5*i,t[0]=(e[5]-e[7])*(i=.5/i),t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i;else{var r=0;e[4]>e[0]&&(r=1),e[8]>e[3*r+r]&&(r=2);var o=(r+1)%3,s=(r+2)%3;i=Math.sqrt(e[3*r+r]-e[3*o+o]-e[3*s+s]+1),t[r]=.5*i,t[3]=(e[3*o+s]-e[3*s+o])*(i=.5/i),t[o]=(e[3*o+r]+e[3*r+o])*i,t[s]=(e[3*s+r]+e[3*r+s])*i}return t}v.clone=r.clone,v.fromValues=r.fromValues,v.copy=r.copy,v.set=r.set,v.add=r.add,v.mul=h;var _=r.scale;v.scale=_;var g=r.dot;v.dot=g,v.lerp=r.lerp;var y=r.length;v.length=y,v.len=y;var x=r.squaredLength;v.squaredLength=x,v.sqrLen=x;var w=r.normalize;v.normalize=w,v.exactEquals=r.exactEquals,v.equals=r.equals;var S,E,C,I=(S=n.create(),E=n.fromValues(1,0,0),C=n.fromValues(0,1,0),function(t,e,i){var r=n.dot(e,i);return r.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(n.cross(S,e,i),t[0]=S[0],t[1]=S[1],t[2]=S[2],t[3]=1+r,w(t,t))});v.rotationTo=I;var A,L,P=(A=l(),L=l(),function(t,e,i,n,r,o){return p(A,e,r,o),p(L,i,n,o),p(t,A,L,2*o*(1-o)),t});v.sqlerp=P;var $,D=($=i.create(),function(t,e,i,n){return $[0]=i[0],$[3]=i[1],$[6]=i[2],$[1]=n[0],$[4]=n[1],$[7]=n[2],$[2]=-e[0],$[5]=-e[1],$[8]=-e[2],w(t,m(t,$))});return v.setAxes=D,v}var C,I={};var A,L,P={};function $(){if(A)return P;function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}A=1,Object.defineProperty(P,"__esModule",{value:!0}),P.create=n,P.clone=function(t){var i=new e.ARRAY_TYPE(2);return i[0]=t[0],i[1]=t[1],i},P.fromValues=function(t,i){var n=new e.ARRAY_TYPE(2);return n[0]=t,n[1]=i,n},P.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},P.set=function(t,e,i){return t[0]=e,t[1]=i,t},P.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},P.subtract=r,P.multiply=s,P.divide=a,P.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},P.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},P.min=function(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t},P.max=function(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t},P.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},P.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},P.scaleAndAdd=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t},P.distance=l,P.squaredDistance=c,P.length=h,P.squaredLength=u,P.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},P.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},P.normalize=function(t,e){var i=e[0],n=e[1],r=i*i+n*n;return r>0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t},P.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},P.cross=function(t,e,i){var n=e[0]*i[1]-e[1]*i[0];return t[0]=t[1]=0,t[2]=n,t},P.lerp=function(t,e,i,n){var r=e[0],o=e[1];return t[0]=r+n*(i[0]-r),t[1]=o+n*(i[1]-o),t},P.random=function(t,i){i=i||1;var n=2*e.RANDOM()*Math.PI;return t[0]=Math.cos(n)*i,t[1]=Math.sin(n)*i,t},P.transformMat2=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r,t[1]=i[1]*n+i[3]*r,t},P.transformMat2d=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[2]*r+i[4],t[1]=i[1]*n+i[3]*r+i[5],t},P.transformMat3=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[3]*r+i[6],t[1]=i[1]*n+i[4]*r+i[7],t},P.transformMat4=function(t,e,i){var n=e[0],r=e[1];return t[0]=i[0]*n+i[4]*r+i[12],t[1]=i[1]*n+i[5]*r+i[13],t},P.rotate=function(t,e,i,n){var r=e[0]-i[0],o=e[1]-i[1],s=Math.sin(n),a=Math.cos(n);return t[0]=r*a-o*s+i[0],t[1]=r*s+o*a+i[1],t},P.angle=function(t,e){var i=t[0],n=t[1],r=e[0],o=e[1],s=Math.sqrt(i*i+n*n)*Math.sqrt(r*r+o*o);return Math.acos(Math.min(Math.max(s&&(i*r+n*o)/s,-1),1))},P.zero=function(t){return t[0]=0,t[1]=0,t},P.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},P.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},P.equals=function(t,i){var n=t[0],r=t[1],o=i[0],s=i[1];return Math.abs(n-o)0){i=Math.sqrt(i);var n=e[0]/i,r=e[1]/i,o=e[2]/i,s=e[3]/i,a=e[4],l=e[5],c=e[6],h=e[7],u=n*a+r*l+o*c+s*h;t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=(a-n*u)/i,t[5]=(l-r*u)/i,t[6]=(c-o*u)/i,t[7]=(h-s*u)/i}return t},I.str=function(t){return"quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},I.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]},I.equals=function(t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=i[0],d=i[1],p=i[2],f=i[3],m=i[4],_=i[5],g=i[6],y=i[7];return Math.abs(n-u)1)return 1;for(var i=t,n=0;nr?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},D}(),F=e(B);function N(){if(R)return z;function t(t,e){this.x=t,this.y=e}return R=1,z=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),r=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-n*(this.y-e.y),this.y=r,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},z}var U=e(N());function V(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i=1)return 1;const e=t*t,i=e*t;return 4*(t{e(t,((t,e)=>{t&&(o=t),r[s]=e,0==--n&&i(o,r)}))}))}function et(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let it=1;function nt(){return it++}function rt(t){return t{e[t]&&(e[t]=e[t].bind(e))}))}function st(t,e){return-1!==t.indexOf(e,t.length-e.length)}function at(t,e,i){const n={};for(const i in t)n[i]=e.call(this,t[i],i,t);return n}function lt(t,e,i){const n={};for(const i in t)e.call(this,t[i],i,t)&&(n[i]=t[i]);return n}function ct(t){return Array.isArray(t)?t.map(ct):"object"==typeof t&&t?at(t,ct):t}const ht={};function ut(t){ht[t]||("undefined"!=typeof console&&console.warn(t),ht[t]=!0)}function dt(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function pt(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,n,r)=>{const o=n||r;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let gt,yt=null;function vt(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function xt(t,e,i,n){for(;e>1;t[r]>1;t[r]0?1/(1.001-t):1+t}function Tt(t){return t>0?1-1/(1.001-t):-t}const St={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==gt){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{gt=null!="MISSING_ENV_VAR".API_URL_REGEX?new RegExp("MISSING_ENV_VAR".API_URL_REGEX):t}catch(e){gt=t}}return gt},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!St.API_URL)return null;try{const t=new URL(St.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Mt(t){return St.API_URL_REGEX.test(t)}function Et(t){return St.API_SPRITE_REGEX.test(t)}let Ct,It,At,Lt,Pt,$t;function Dt(){return null==Ct&&(Ct=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Ct}const kt={now:()=>void 0!==Lt?Lt:performance.now(),setNow(t){Lt=t},restoreNow(){Lt=void 0},frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;Pt||(Pt=document.createElement("canvas"));const r=Pt.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return(i>Pt.width||n>Pt.height)&&(Pt.width=i,Pt.height=n),r.clearRect(-e,-e,i+2*e,n+2*e),r.drawImage(t,0,0,i,n),r.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(It||(It=document.createElement("a")),It.href=t,It.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==At&&(At=window.matchMedia("(prefers-reduced-motion: reduce)")),At.matches)},hasCanvasFingerprintNoise(){if(void 0!==$t)return $t;if(!Dt())return $t=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n0?`?${o}`:""}`}const Ot="mapbox-tiles";let Bt=500,Ft=50;const Nt=["language","worldview","jobid"];let Ut,Vt;function jt(){try{return caches}catch(t){}}function Gt(){const t=jt();t&&null==Ut&&(Ut=t.open(Ot))}let Zt=1/0;const qt={supported:!1,testSupport:function(t){!Yt&&Wt&&(Xt?Jt(t):Ht=t)}};let Ht,Wt,Yt=!1,Xt=!1;const Kt="undefined"!=typeof self?self:{};function Jt(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Wt),t.isContextLost())return;qt.supported=!0}catch(t){}t.deleteTexture(e),Yt=!0}Kt.document&&(Wt=Kt.document.createElement("img"),Wt.onload=function(){Ht&&Jt(Ht),Ht=null,Xt=!0},Wt.onerror=function(){Yt=!0,Ht=null},Wt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Qt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Qt);class te extends Error{constructor(t,e,i){401===e&&Mt(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ee=mt()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,ie=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(ee())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:ee(),referrerPolicy:t.referrerPolicy,signal:i.signal});let r=!1,o=!1;const s=(a=n.url).indexOf("sku=")>0&&Mt(a);var a;"json"===t.type&&n.headers.set("Accept","application/json");const l=(i,r,a)=>{if(o)return;if(i&&"SecurityError"!==i.message&&ut(i.toString()),r&&a)return c(r);const l=Date.now();fetch(n).then((i=>{if(i.ok){const t=s?i.clone():null;return c(i,t,l)}return e(new te(i.statusText,i.status,t.url))})).catch((i=>{"AbortError"!==i.name&&e(new Error(`${i.message} ${t.url}`))}))},c=(i,s,a)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{o||(s&&a&&function(t,e,i){if(Gt(),null==Ut)return;const n=_t(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t))),n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const o=r.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i{const i=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,r);var n;Gt(),null!=Ut&&Ut.then((t=>t.put(s,i))).catch((t=>ut(t.message)))}))}(n,s,a),r=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{o||e(new Error(t.message))}))};return s?function(t,e){if(Gt(),null==Ut)return e(null);Ut.then((i=>{let n=Rt(t.url,{persistentParams:Nt});const r=t.headers.get("Range");r&&(n=zt(n,{range:r})),i.match(n).then((t=>{const r=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=_t(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(t);i.delete(n),r&&i.put(n,t.clone()),e(null,t,r)})).catch(e)})).catch(e)}(n,l):l(null,null),{cancel:()=>{o=!0,r||i.abort()}}}(t,e);if(mt()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.statusi.abort()}}(t,e)},ne=function(t,e){return ie(et(t,{type:"arrayBuffer"}),e)};function re(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const oe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let se,ae;se=[],ae=0;const le=function(t,e){if(qt.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ae>=St.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return se.push(i),i}ae++;let i=!1;const n=()=>{if(!i)for(i=!0,ae--;se.length&&ae{n(),t?e(t):i&&(self.createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,r,o))):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=oe}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(n):oe}(i,((t,i)=>e(t,i,r,o))))}));return{cancel:()=>{r.cancel(),n()}}};var ce,he,ue,de={exports:{}},pe={exports:{}},fe={exports:{}},me=function(){if(ue)return de.exports;ue=1;var t=(ce||(ce=1,pe.exports=function(t,e){var i,n,r,o,s,a,l,c;for(n=t.length-(i=3&t.length),r=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>19))+((5*(r>>>16)&65535)>>16)&65535)>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>16))+((2246822507*(r>>>16)&65535)>>13))+((3266489909*(r>>>16)&65535)>>16)>>>0}),pe.exports),e=(he||(he=1,fe.exports=function(t,e){for(var i,n=t.length,r=e^n,o=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))>>16)&65535)>>16)&65535)>>24))+((1540483477*(i>>>16)&65535)>>16)&65535)>>13))+((1540483477*(r>>>16)&65535)>>15)>>>0}),fe.exports);return de.exports=t,de.exports.murmur3=t,de.exports.murmur2=e,de.exports}(),_e=e(me);class ge{constructor(t,...e){et(this,e[0]||{}),this.type=t}}class ye extends ge{constructor(t,e={}){super("error",et({error:t},e))}}function ve(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function xe(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class be{on(t,e){return this._listeners=this._listeners||{},ve(t,e,this._listeners),this}off(t,e){return xe(t,e,this._listeners),xe(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ve(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const i="string"==typeof t?new ge(t,e):t,n=i.type;if(this.listens(n)){i.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,i);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)xe(n,t,this._oneTimeListeners),t.call(this,i);const r=this._eventedParent;r&&(et(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(i))}else i instanceof ye&&console.error(i.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var we,Te={},Se=function(){if(we)return Te;we=1;var t={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function e(t){return(t=Math.round(t))255?255:t}function i(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))1?1:e;var e}function r(t,e,i){return i1&&(i-=1),6*i=0&&s>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)=0&&s>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var h=a.substr(0,l),u=a.substr(l+1,c-(l+1)).split(","),d=1;switch(h){case"rgba":if(4!==u.length)return null;d=n(u.pop());case"rgb":return 3!==u.length?null:[i(u[0]),i(u[1]),i(u[2]),d];case"hsla":if(4!==u.length)return null;d=n(u.pop());case"hsl":if(3!==u.length)return null;var p=(parseFloat(u[0])%360+360)%360/360,f=n(u[1]),m=n(u[2]),_=m=_.length)throw new Error("out of range");this.r=Ce(Ce(Ce(_[g],_[y],m),Ce(_[v],_[x],m),f),Ce(Ce(_[b],_[w],m),Ce(_[T],_[S],m),f),p)/255*r,this.g=Ce(Ce(Ce(_[g+1],_[y+1],m),Ce(_[v+1],_[x+1],m),f),Ce(Ce(_[b+1],_[w+1],m),Ce(_[T+1],_[S+1],m),f),p)/255*r,this.b=Ce(Ce(Ce(_[g+2],_[y+2],m),Ce(_[v+2],_[x+2],m),f),Ce(Ce(_[b+2],_[w+2],m),Ce(_[T+2],_[S+2],m),f),p)/255*r,this.a=r}else this.r=e,this.g=i,this.b=n,this.a=r}toArray(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*i/n,n]}toArray01(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,i/n,n]}toArray01Scaled(t){const{r:e,g:i,b:n,a:r}=this;return 0===r?[0,0,0]:[e/r*t,i/r*t,n/r*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:n}=this;return[t,e,i,n]}toArray01Linear(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(i/n,2.2),n]}}function Ce(t,e,i){return t*(1-i)+e*i}function Ie(t,e,i){return t.map(((t,n)=>Ce(t,e[n],i)))}Me.black=new Me(0,0,0,1),Me.white=new Me(1,1,1,1),Me.transparent=new Me(0,0,0,0),Me.red=new Me(1,0,0,1),Me.blue=new Me(0,0,1,1);var Ae=Object.freeze({__proto__:null,array:Ie,color:function(t,e,i){return new Me(Ce(t.r,e.r,i),Ce(t.g,e.g,i),Ce(t.b,e.b,i),Ce(t.a,e.a,i))},number:Ce});function Le(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class Pe extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class $e{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new $e(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const De={kind:"null"},ke={kind:"number"},ze={kind:"string"},Re={kind:"boolean"},Oe={kind:"color"},Be={kind:"object"},Fe={kind:"value"},Ne={kind:"collator"},Ue={kind:"formatted"},Ve={kind:"resolvedImage"};function je(t,e){return{kind:"array",itemType:t,N:e}}function Ge(t){if("array"===t.kind){const e=Ge(t.itemType);return"number"==typeof t.N?`array`:"value"===t.itemType.kind?"array":`array`}return t.kind}const Ze=[De,ke,ze,Re,Oe,Ue,Be,je(Fe),Ve];function qe(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!qe(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Ze)if(!qe(t,e))return null}return`Expected ${Ge(t)} but found ${Ge(e)} instead.`}function He(t,e){return e.some((e=>e.kind===t.kind))}function We(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class Ye{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Xe{constructor(t,e,i,n,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=r}}class Ke{constructor(t){this.sections=t}static fromString(t){return new Ke([new Xe(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof Ke?t:Ke.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toRenderColor(null).toArray())),t.push(i)}return t}}class Je{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new Je({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function Qe(t,e,i,n){return"number"==typeof t&&t>=0&&t=0&&e=0&&i=0&&n2){const i=t[1];if("string"!=typeof i||!(i in oi)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=oi[i],n++}else r=Fe;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}class ai{constructor(t){this.type=Ue,this.sections=t}static parse(t,e){if(t.length{const i=e.content.evaluate(t);return ei(i)===Ve?new Xe("",i,null,null,null):new Xe(ii(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class li{constructor(t,e){this.type=Ve,this.inputPrimary=t,this.inputSecondary=e}static parse(t,e){if(t.length-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function ci(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const hi={"to-boolean":Re,"to-color":Oe,"to-number":ke,"to-string":ze};class ui{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length0&&ti(t[1][0])))return null;r=je(ei(t[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Qe(e[0],e[1],e[2],e[3]),!i))return new Me(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ri(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ri(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Ke.fromString(ii(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Je.fromString(ii(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ii(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new ai([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new li(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const di=["Unknown","Point","LineString","Polygon"];class pi{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?di[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Me.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class fi{constructor(t,e,i,n,r){this.name=t,this.type=e,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(t){if(!this._evaluate){const t=fi.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=fi.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new Dn(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const o=[];let h=!1;for(let e=1;et))).map(mi).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/20&&yi(t,i,n);s0;)a--}0===r(t[i],o)?yi(t,i,a):(a++,yi(t,a,n)),ae?1:0}function xi(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r=e[2]||t[1]=e[3])}function Ti(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o(r=t)[1]!=(s=h)[1]>r[1]&&r[0]0&&a0}function Ei(t,e,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-r[1]*o[0]&&!(!Mi(t,e,i,n)||!Mi(i,n,t,e));var r,o}const Ci=8192;function Ii(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*Ci),Math.round(n*r*Ci)]}function Ai(t,e){for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}bi(e,t)}function Ri(t,e,i,n){const r=Math.pow(2,n.z)*Ci,o=[n.x*Ci,n.y*Ci],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];zi(n,e,i,r),s.push(n)}return s}function Oi(t,e,i,n){const r=Math.pow(2,n.z)*Ci,o=[n.x*Ci,n.y*Ci],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];bi(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]e)return Zi(r,o,(e-(i-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,i){let[n,r]=e,o=qi(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const e=(qi(t[0]-n)*this.kx*o+(t[1]-r)*this.ky*s)/(o*o+s*s);e>1?(n=i[0],r=i[1]):e>0&&(n+=o/this.kx*e,r+=s/this.ky*e)}return o=qi(t[0]-n)*this.kx,s=(t[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let i=1/0,n=t[0][0],r=t[0][1],o=0,s=0;for(let a=0;a1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=qi(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=h*h+u*u;pr.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!Gi(i[s],o[0])&&st&&0===r.length&&r.push(Zi(s,a,(t-(n-l))/l)),n>=e)return r.push(Zi(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return qi(t[0]-e[0])>=0&&qi(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class Hi{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var Wi=8192;function Yi(t,e){return e.dist-t.dist}function Xi(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=Ki(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function tn(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!Ji(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(wi(r,o)){if(mn(t,e))return 0}else if(mn(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(Ki(c)=s)continue;const h=o.range1,u=o.range2;if(Ki(h)=o)&&(o=Math.min(o,vn(t,e,r,!0,n,o)),0===o))return o;return o}function bn(t,e,i,n,r=1/0){let o=r;const s=tn(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&nn(s,en(r),n)>=o)continue;const i=yn(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function wn(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Tn{constructor(t,e){this.type=ke,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(ti(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class En{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=Fe),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof ni))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof ni?new En(i,ii(n.value),ii(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new En(i,ii(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let h=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),h=r.evaluate(t),t.scope=e}return n&&(h=Sn(n,h)),void 0===h||void 0===s&&void 0===a&&void 0===l||("number"==typeof h?h=Mn(h,s,a,l):Array.isArray(h)&&(h=h.map((t=>"number"==typeof t?Mn(t,s,a,l):t)))),void 0!==r&&void 0!==h&&o&&!o.includes(h)&&(h=c,n&&(h=Sn(n,h))),(n&&n!==this.type||void 0!==h&&ei(h)!==this.type)&&(h=Sn(this.type.kind,h)),h}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Cn(t){if(t instanceof fi){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;let e=!0;return t.eachChild((t=>{e&&!Cn(t)&&(e=!1)})),e}function In(t){if(t instanceof fi&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!In(t)&&(e=!1)})),e}function An(t){if(t instanceof En)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...An(t)])})),e}function Ln(t,e){if(t instanceof fi&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ln(t,e)&&(i=!1)})),i}class Pn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Pn(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class $n{constructor(t,e=[],i,n=new $e,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,null,i,n)._parse(t,r):this._parse(t,r)}parseObjectValue(t,e,i,n,r,o={}){return this.concat(e,i,n,r)._parse(t,o)}_parse(t,e){function i(t,e,i){return"assert"===i?new si(e,[t]):"coerce"===i?new ui(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ni)&&"resolvedImage"!==r.type.kind&&kn(r)){const e=new pi(this._scope,this.options);try{r=new ni(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return ui.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i,n){let r="number"==typeof t?this.path.concat(t):this.path;r="string"==typeof e?r.concat(e):r;const o=n?this.scope.concat(n):this.scope;return new $n(this.registry,r,i||null,o,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Pe(i,t))}checkSubtype(t,e){const i=qe(t,e);return i&&this.error(i),i}}var Dn=$n;function kn(t){if(t instanceof Pn)return kn(t.boundExpression);if(t instanceof fi&&"error"===t.name)return!1;if(t instanceof _i)return!1;if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;if(t instanceof En)return!1;const e=t instanceof ui||t instanceof si;let i=!0;return t.eachChild((t=>{i=e?i&&kn(t):i&&t instanceof ni})),!!i&&Cn(t)&&Ln(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function zn(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new ri("Input is not a number.");s=a-1}return 0}class Rn{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new Rn(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[zn(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const On=.95047,Bn=1.08883,Fn=4/29,Nn=6/29,Un=3*Nn*Nn,Vn=Nn*Nn*Nn,jn=Math.PI/180,Gn=180/Math.PI;function Zn(t){return t>Vn?Math.pow(t,1/3):t/Un+Fn}function qn(t){return t>Nn?t*t*t:Un*(t-Fn)}function Hn(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new er(a,i,n,r,s):e.error(`Type ${Ge(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=zn(e,n),s=er.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Ae[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Qn.reverse(Qn.interpolate(Qn.forward(a),Qn.forward(l),s)):Jn.reverse(Jn.interpolate(Jn.forward(a),Jn.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tqe(n,t.type)));return new nr(o?Fe:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof Je&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class rr{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new ri(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ri(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sr{constructor(t,e){this.type=Re,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);return i&&n?He(i.type,[Re,ze,ke,De,Fe])?new sr(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ar{constructor(t,e,i){this.type=ke,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);if(!i||!n)return null;if(!He(i.type,[Re,ze,ke,De,Fe]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new ar(i,n,r):null}return new ar(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class lr{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ei(t)))return null}else i=ei(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const h=e.parse(l,s,n);if(!h)return null;n=n||h.type,o.push(h)}const s=e.parse(t[1],1,Fe);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new lr(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(ei(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class cr{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class hr{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,ke);if(!i||!n)return null;if(!He(i.type,[je(Fe),ze,Fe]))return e.error(`Expected first argument to be of type array or string, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new hr(i.type,i,n,r):null}return new hr(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!We(e,["string","array"]))throw new ri(`Expected first argument to be of type array or string, but found ${Ge(ei(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ur(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function dr(t,e,i,n){return 0===n.compare(e,i)}function pr(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Re,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,Fe);if(!o)return null;if(!ur(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ge(o.type)}'.`);let s=e.parse(t[2],2,Fe);if(!s)return null;if(!ur(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ge(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${Ge(o.type)}' and '${Ge(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new si(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new si(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ne),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=ei(o),i=ei(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ri(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ei(o),i=ei(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const fr=pr("==",(function(t,e,i){return e===i}),dr),mr=pr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!dr(0,e,i,n)})),_r=pr("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),yr=pr("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class xr{constructor(t,e,i,n,r,o){this.type=ze,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ke);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parseObjectValue(n.locale,2,"locale",ze),!r))return null;let o=null;if(n.currency&&(o=e.parseObjectValue(n.currency,2,"currency",ze),!o))return null;let s=null;if(n.unit&&(s=e.parseObjectValue(n.unit,2,"unit",ze),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",ke),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",ke),!l)?null:new xr(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class br{constructor(t){this.type=ke,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Ge(i.type)} instead.`):new br(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ri(`Expected value to be of type string or array, but found ${Ge(ei(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function wr(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Tr={"==":fr,"!=":mr,">":gr,"=":vr,"=0&&t=0&&e=0&&i=0&&n-1}function $r(t){return"data-driven"===t["property-type"]}function Dr(t){return Pr(t.expression,"measure-light")}function kr(t){return Pr(t.expression,"zoom")}function zr(t){return!!t.expression&&t.expression.interpolated}function Rr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Or(t){return t}function Br(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(zr(e)?"exponential":"interval");if(i&&((t=Le({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Me.parse(t[1])]))),t.default=Me.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!tr[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=Vr;else if("interval"===o)s=Ur;else if("categorical"===o){s=Nr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=jr}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>Vr({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:er.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?Fr(t.default,e.default):s(t,e,r,a,l)}}}function Fr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Nr(t,e,i,n,r){return Fr(typeof i===r?n[i]:void 0,t.default,e.default)}function Ur(t,e,i){if("number"!==ci(i))return Fr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=zn(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function Vr(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==ci(i))return Fr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=zn(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Ae[e.type]||Or;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=tr[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function jr(t,e,i){return"color"===e.type?i=Me.parse(i):"formatted"===e.type?i=Ke.fromString(i.toString()):"resolvedImage"===e.type?i=Je.fromString(i.toString()):ci(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Fr(i,t.default,e.default)}fi.register(Tr,{error:[{kind:"error"},[ze],(t,[e])=>{throw new ri(e.evaluate(t))}],typeof:[ze,[Fe],(t,[e])=>Ge(ei(e.evaluate(t)))],"to-rgba":[je(ke,4),[Oe],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Oe,[ke,ke,ke],Sr],rgba:[Oe,[ke,ke,ke,ke],Sr],hsl:[Oe,[ke,ke,ke],Mr],hsla:[Oe,[ke,ke,ke,ke],Mr],has:{type:Re,overloads:[[[ze],(t,[e])=>Er(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Er(e.evaluate(t),i.evaluate(t))]]},get:{type:Fe,overloads:[[[ze],(t,[e])=>Cr(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Cr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Fe,[ze],(t,[e])=>Cr(e.evaluate(t),t.featureState||{})],properties:[Be,[],t=>t.properties()],"geometry-type":[ze,[],t=>t.geometryType()],id:[Fe,[],t=>t.id()],zoom:[ke,[],t=>t.globals.zoom],pitch:[ke,[],t=>t.globals.pitch||0],"distance-from-center":[ke,[],t=>t.distanceFromCenter()],"measure-light":[ke,[ze],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[ke,[],t=>t.globals.heatmapDensity||0],"line-progress":[ke,[],t=>t.globals.lineProgress||0],"raster-value":[ke,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[ke,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[ke,[],t=>t.globals.skyRadialProgress||0],accumulated:[Fe,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ke,Ir(ke),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[ke,Ir(ke),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:ke,overloads:[[[ke,ke],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ke],(t,[e])=>-e.evaluate(t)]]},"/":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ke,[ke],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))],log2:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ke,[ke],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ke,[ke],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ke,[ke],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ke,[ke],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ke,[ke],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ke,[ke],(t,[e])=>Math.atan(e.evaluate(t))],min:[ke,Ir(ke),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ke,Ir(ke),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ke,[ke],(t,[e])=>Math.abs(e.evaluate(t))],round:[ke,[ke],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[ke,[ke],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Re,[ze,Fe],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Re,[Fe],(t,[e])=>t.id()===e.value],"filter-type-==":[Re,[ze],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Re,[Fe],(t,[e])=>e.value in t.properties()],"filter-has-id":[Re,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Re,[je(ze)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Re,[je(Fe)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Re,[ze,je(Fe)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Re,[ze,je(Fe)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Re,[Re],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Re,[ze],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ze,[ze],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ze,[ze],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ze,Ir(Fe),(t,e)=>e.map((e=>ii(e.evaluate(t)))).join("")],"resolved-locale":[ze,[Ne],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[ke,[ke,ke,Fe],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Zr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Tr}function qr(t,e,i,n){const r=new Dn(Tr,[],e?function(t){const e={color:Oe,string:ze,number:ke,enum:ze,boolean:Re,formatted:Ue,resolvedImage:Ve};return"array"===t.type?je(e[t.value]||Fe,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Ar(new Gr(o,e,i,n)):Lr(r.errors)}class Hr{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!In(e.expression),this.configDependencies=An(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class Wr{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!In(e.expression),this.isLightConstant=r,this.configDependencies=An(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?er.interpolationFactor(this.interpolationType,t,e,i):0}}function Yr(t,e,i,n){if("error"===(t=qr(t,e,i,n)).result)return t;const r=t.value.expression,o=Cn(r);if(!o&&!$r(e))return Lr([new Pe("","data expressions not supported")]);const s=Ln(r,["zoom","pitch","distance-from-center"]);if(!s&&!kr(e))return Lr([new Pe("","zoom expressions not supported")]);const a=Ln(r,["measure-light"]);if(!a&&!Dr(e))return Lr([new Pe("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=Kr(r);return c||s||l?c instanceof Pe?Lr([c]):c instanceof er&&!zr(e)?Lr([new Pe("",'"interpolate" expressions cannot be used with this property')]):Ar(c?new Wr(o?"camera":"composite",t.value,c.labels,c instanceof er?c.interpolation:void 0,a):new Hr(o?"constant":"source",t.value,a)):Lr([new Pe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Xr{constructor(t,e){this._parameters=t,this._specification=e,Le(this,Br(this._parameters,this._specification))}static deserialize(t){return new Xr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Kr(t){let e=null;if(t instanceof rr)e=Kr(t.result);else if(t instanceof nr){for(const i of t.args)if(e=Kr(i),e)break}else(t instanceof Rn||t instanceof er)&&t.input instanceof fi&&"zoom"===t.input.name&&(e=t);return e instanceof Pe||t.eachChild((t=>{const i=Kr(t);i instanceof Pe?e=i:e&&i&&e!==i&&(e=new Pe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var Jr,Qr,to=function(){if(Qr)return Jr;Qr=1,Jr=e;var t=3;function e(e,i,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var o=new Int32Array(this.arrayBuffer);e=o[0],this.d=(i=o[1])+2*(n=o[2]);for(var s=0;s=h[p+0]&&n>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},e.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(n),d=l;d=0||(r[i]=so(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function ao(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||ro(t)||oo(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(ao);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,ao(t[i]));return e}if("Set"===e){const e=new Set;for(const i of Object.keys(t))"$name"!==i&&e.add(ao(t[i]));return e}const{klass:i}=io[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=ao(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const lo=t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(_s="error"),ms&&ms(t)};function vs(){xs.fire(new ge("pluginStateChange",{pluginStatus:_s,pluginURL:gs}))}const xs=new be,bs=function(){return _s},ws=function(){if(_s!==ds||!gs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_s=ps,vs(),gs&&ne({url:gs},(t=>{t?ys(t):(_s=fs,vs())}))},Ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_s===fs||null!=Ts.applyArabicShaping,isLoading:()=>_s===ps,setState(t){_s=t.pluginStatus,gs=t.pluginURL},isParsed:()=>null!=Ts.applyArabicShaping&&null!=Ts.processBidirectionalText&&null!=Ts.processStyledBidirectionalText,getPluginURL:()=>gs};class Ss{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!hs(i.charCodeAt(0),e))return!1;return!0}(t,Ts.isLoaded())}}class Ms{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(Rr(t))return new Xr(t,e);if(Zr(t)||Array.isArray(t)&&t.length>0){const r=Yr(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Me.parse(t)),{kind:"constant",configDependencies:new Set,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Es{constructor(t,e,i){this.property=t,this.value=new Ms(t,void 0,e,i)}transitioned(t,e){return new Is(this.property,this.value,e,et({},t.transition,this.transition),t.now)}untransitioned(){return new Is(this.property,this.value,null,{},0)}}class Cs{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.configDependencies=new Set}getValue(t){return ct(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property,this._scope,this._options)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:ct(e),this._scope,this._options),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]))}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(st(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ct(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property)),this._values[t].transition=ct(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new As(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new As(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Is{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};Ns(t)||(t=Ws(t));const r=t;let o=!0;try{o=function(t){if(!Gs(t))return t;let e=Fs(t);return js(e),e=Vs(e),e}(r)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `)}const s=Os[`filter_${n}`],a=qr(o,s,e,i);let l=null;if("error"===a.result)throw new Error(a.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(t,e,i)=>a.value.evaluate(t,e,{},i);let c=null,h=null;if(o!==r){const t=qr(r,s,e,i);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));c=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),h=!Cn(t.value.expression)}return{filter:l,dynamicFilter:c||void 0,needGeometry:Hs(o),needFeature:!!h}}function Vs(t){if(!Array.isArray(t))return t;const e=function(t){if(Zs.has(t[0]))for(let e=1;eVs(t)))}function js(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function Hs(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?Ys(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(Ws))):"all"===e?["all"].concat(t.slice(1).map(Ws)):"none"===e?["all"].concat(t.slice(1).map(Ws).map(Js)):"in"===e?Xs(t[1],t.slice(2)):"!in"===e?Js(Xs(t[1],t.slice(2))):"has"===e?Ks(t[1]):"!has"!==e||Js(Ks(t[1]));var i}function Ys(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Xs(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(qs)]]:["filter-in-small",t,["literal",e]]}}function Ks(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Js(t){return["!",t]}const Qs="";function ta(t,e){return e?`${t}${Qs}${e}`:t}const ea="-transition",ia=new Set(["fill","line","background","hillshade","raster"]);class na extends be{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=ta(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Ls(e.layout,this.scope,r),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),e.paint)){this._transitionablePaint=new Cs(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $s(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return!this.is3D()&&ia.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return st(t,ea)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(st(t,ea)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=st(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return lt({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Ps&&$r(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(t){this._filterCompiled||(this._featureFilter=Us(this.filter,this.scope,t),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const ra={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class oa{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class sa{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function aa(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=ra[t.type].BYTES_PER_ELEMENT,o=i=la(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:la(i,Math.max(n,e)),alignment:e}}function la(t,e){return Math.ceil(t/e)*e}class ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}ca.prototype.bytesPerElement=4,no(ca,"StructArrayLayout2i4");class ha extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}ha.prototype.bytesPerElement=6,no(ha,"StructArrayLayout3i6");class ua extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}ua.prototype.bytesPerElement=8,no(ua,"StructArrayLayout4i8");class da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}da.prototype.bytesPerElement=10,no(da,"StructArrayLayout5i10");class pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,t}}pa.prototype.bytesPerElement=12,no(pa,"StructArrayLayout2i4ub1f12");class fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}fa.prototype.bytesPerElement=16,no(fa,"StructArrayLayout4f16");class ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}ma.prototype.bytesPerElement=12,no(ma,"StructArrayLayout3f12");class _a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}_a.prototype.bytesPerElement=12,no(_a,"StructArrayLayout4ui1f12");class ga extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}ga.prototype.bytesPerElement=8,no(ga,"StructArrayLayout4ui8");class ya extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}ya.prototype.bytesPerElement=12,no(ya,"StructArrayLayout6i12");class va extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,n,r,o,s,a,l,c,h,u)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}va.prototype.bytesPerElement=24,no(va,"StructArrayLayout4i4ui4i24");class xa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}xa.prototype.bytesPerElement=20,no(xa,"StructArrayLayout3i3f20");class ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ba.prototype.bytesPerElement=4,no(ba,"StructArrayLayout1ul4");class wa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}wa.prototype.bytesPerElement=4,no(wa,"StructArrayLayout2ui4");class Ta extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,h,u,d)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,t}}Ta.prototype.bytesPerElement=40,no(Ta,"StructArrayLayout5i4f1i1ul2ui40");class Sa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Sa.prototype.bytesPerElement=16,no(Sa,"StructArrayLayout3i2i2i16");class Ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Ma.prototype.bytesPerElement=16,no(Ma,"StructArrayLayout2f1f2i16");class Ea extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=20*t,l=5*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Ea.prototype.bytesPerElement=20,no(Ea,"StructArrayLayout2ub4f20");class Ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Ca.prototype.bytesPerElement=6,no(Ca,"StructArrayLayout3ui6");class Ia extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Ia.prototype.bytesPerElement=60,no(Ia,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Aa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P){const $=this.length;return this.resize($+1),this.emplace($,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P,$){const D=20*t,k=40*t,z=80*t;return this.float32[D+0]=e,this.float32[D+1]=i,this.int16[k+4]=n,this.int16[k+5]=r,this.int16[k+6]=o,this.int16[k+7]=s,this.int16[k+8]=a,this.int16[k+9]=l,this.int16[k+10]=c,this.int16[k+11]=h,this.int16[k+12]=u,this.uint16[k+13]=d,this.uint16[k+14]=p,this.uint16[k+15]=f,this.uint16[k+16]=m,this.uint16[k+17]=_,this.uint16[k+18]=g,this.uint16[k+19]=y,this.uint16[k+20]=v,this.uint16[k+21]=x,this.uint16[k+22]=b,this.uint16[k+23]=w,this.uint16[k+24]=T,this.uint16[k+25]=S,this.uint16[k+26]=M,this.uint16[k+27]=E,this.uint32[D+14]=C,this.float32[D+15]=I,this.float32[D+16]=A,this.float32[D+17]=L,this.float32[D+18]=P,this.uint8[z+76]=$,t}}Aa.prototype.bytesPerElement=80,no(Aa,"StructArrayLayout2f9i15ui1ul4f1ub80");class La extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}La.prototype.bytesPerElement=4,no(La,"StructArrayLayout1f4");class Pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}Pa.prototype.bytesPerElement=20,no(Pa,"StructArrayLayout5f20");class $a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}$a.prototype.bytesPerElement=28,no($a,"StructArrayLayout7f28");class Da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}Da.prototype.bytesPerElement=12,no(Da,"StructArrayLayout1ul3ui12");class ka extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ka.prototype.bytesPerElement=2,no(ka,"StructArrayLayout1ui2");class za extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}za.prototype.bytesPerElement=8,no(za,"StructArrayLayout2f8");class Ra extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}Ra.prototype.bytesPerElement=64,no(Ra,"StructArrayLayout16f64");class Oa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}Oa.prototype.bytesPerElement=20,no(Oa,"StructArrayLayout4ui3f20");class Ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}Ba.prototype.bytesPerElement=2,no(Ba,"StructArrayLayout1i2");class Fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Fa.prototype.bytesPerElement=1,no(Fa,"StructArrayLayout1ub1");class Na extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Na.prototype.size=40;class Ua extends Ta{get(t){return new Na(this,t)}}no(Ua,"CollisionBoxArray");class Va extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}Va.prototype.size=60;class ja extends Ia{get(t){return new Va(this,t)}}no(ja,"PlacedSymbolArray");class Ga extends oa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ga.prototype.size=80;class Za extends Aa{get(t){return new Ga(this,t)}}no(Za,"SymbolInstanceArray");class qa extends La{getoffsetX(t){return this.float32[1*t+0]}}no(qa,"GlyphOffsetArray");class Ha extends ca{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}no(Ha,"SymbolLineVertexArray");class Wa extends oa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Wa.prototype.size=12;class Ya extends Da{get(t){return new Wa(this,t)}}no(Ya,"FeatureIndexArray");class Xa extends wa{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}no(Xa,"FillExtrusionCentroidArray");class Ka extends oa{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Ka.prototype.size=6;class Ja extends ha{get(t){return new Ka(this,t)}}no(Ja,"FillExtrusionWallArray");const Qa=aa([{name:"a_pos",components:2,type:"Int16"}],4),tl=aa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class el{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>el.MAX_VERTEX_ARRAY_LENGTH&&ut(`Max vertices per segment is ${el.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>el.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new el([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function il(t,e){return 256*(t=K(Math.floor(t),0,255))+K(Math.floor(e),0,255)}el.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,no(el,"SegmentVector");const nl=aa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),rl=aa([{name:"a_dash",components:4,type:"Uint16"}]);class ol{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(sl(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=sl(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return al(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new ol;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function sl(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;ll(t,o,s),ll(e,3*o,3*s),ll(e,3*o+1,3*s+1),ll(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Me?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new ml(t):new ul(t)}}class Tl{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new fl(t):new ul(t)}}class Sl{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ss(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=bl(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ss(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ss(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=bl(i.toRenderColor(r.lut)),o=bl(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof Ps&&$r(o.property.specification)))continue;const s=Ll(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const e=Dl(r,l,"source");this.binders[r]=h?new El(a,s,l,e,t.id):new Sl(a,s,l,e),n.push(`/a_${r}`)}else{const t=Dl(r,l,"composite");this.binders[r]=new Ml(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=h?new Tl(a.value,s):new wl(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Sl||e instanceof Ml?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Sl||l instanceof Ml||l instanceof El)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Tl&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),h=0!==c.length,u=h?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const d=this.binders[c];if(d.context=this.context,(d instanceof Sl||d instanceof Ml||d instanceof El)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=r.paint.get(c);d.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}if(!h)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof wl||i instanceof Tl)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Sl||i instanceof Ml||i instanceof El)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Cl(n,e,i);this.needsUpload=!1,this._featureMap=new ol,this._featureMapWithoutIds=new ol,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Al={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Ll(t,e){return Al[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Pl={"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a},"line-dasharray":{source:ga,composite:ga}},$l={color:{source:za,composite:fa},number:{source:La,composite:za}};function Dl(t,e,i){const n=Pl[t];return n&&n[i]||$l[e][i]}no(wl,"ConstantBinder"),no(Tl,"PatternConstantBinder"),no(Sl,"SourceExpressionBinder"),no(El,"PatternCompositeBinder"),no(Ml,"CompositeExpressionBinder"),no(Cl,"ProgramConfiguration",{omit:["_buffers"]}),no(Il,"ProgramConfigurationSet");const kl=Wi/Math.PI/2,zl=64,Rl=[zl,32,16],Ol=-kl,Bl=kl;function Fl(t,e,i,n=kl){return i=Z(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function Nl(t,e,i){return Fl(Math.cos(Z(t)),Math.sin(Z(t)),e,i)}const Ul=6371008.8,Vl=2*Math.PI*Ul;class jl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Gl{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}setSouthWest(t){return this._sw=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof jl)n=t,r=t;else{if(!(t instanceof Gl))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Gl.convert(t)):this.extend(jl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(jl.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new jl(n.lng,n.lat),this._ne=new jl(r.lng,r.lat)),this}getCenter(){return new jl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new jl(this.getWest(),this.getNorth())}getSouthEast(){return new jl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=jl.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat=l?(rc(t,e,i,c,h,o,u,a,l),rc(t,c,h,n,r,u,s,a,l)):t.push(s)}function oc(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&ut("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function uc(t,e,i){const n=t.loadGeometry(),r=t.extent,o=Wi/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Yl((e.x+t.x/r)/o),n=Xl((e.y+t.y/r)/o),h=c.project(i,n);t.x=(h.x*s-a)*r,t.y=(h.y*s-l)*r};for(let e=0;e=r||i.y=r||(h(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)hc(e,o);return n}function dc(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?uc(t):[]}}function pc(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function fc(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class mc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ca,this.indexArray=new Ca,this.segments=new el,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new ya,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,tl.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=Wi||n=Wi)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;fc(s,t,e),fc(s,t,e),fc(s,t,e),fc(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;pc(this.layoutVertexArray,i,n,-1,-1),pc(this.layoutVertexArray,i,n,1,-1),pc(this.layoutVertexArray,i,n,1,1),pc(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function _c(t,e){for(let i=0;i1){if(xc(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function Sc(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new U(e,i),new U(e,r),new U(n,r),new U(n,i)];if(t.length>2)for(const e of o)if(Mc(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=dt(t,e,i[0]);return o!==dt(t,e,i[1])||o!==dt(t,e,i[2])||o!==dt(t,e,i[3])}function Ic(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o0;o--)n=1this.canonical.z?new Uc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Uc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Vc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Vc(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Uc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Uc(e,this.wrap,e,i,n),new Uc(e,this.wrap,e,i+1,n),new Uc(e,this.wrap,e,i,n+1),new Uc(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=0;if(0===o)return 0;o!==e.length&&(i=!1)}return i?2:1}function Jc(t,e){for(const i of t.projections){const n=Xc(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function Qc(t,e){let i=0;const n=[0,0,0,0];for(let r=0;r=0&&i++;return i}class th{constructor(t,e){this.points=t||new Array(8).fill([0,0,0]),this.planes=e||new Array(6).fill([0,0,0,0]),this.bounds=eh.fromPoints(this.points),this.projections=[],this.frustumEdges=[O.vec3.sub([],this.points[2],this.points[3]),O.vec3.sub([],this.points[0],this.points[3]),O.vec3.sub([],this.points[4],this.points[0]),O.vec3.sub([],this.points[5],this.points[1]),O.vec3.sub([],this.points[6],this.points[2]),O.vec3.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:Xc(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:Xc(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(t,e,i,n){const r=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=O.vec4.transformMat4([],i,t),s=1/o[3]/e*r;return O.vec4.mul(o,o,[s,s,n?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=O.vec3.sub([],o[t[0]],o[t[1]]),i=O.vec3.sub([],o[t[2]],o[t[1]]),n=O.vec3.normalize([],O.vec3.cross([],e,i)),r=-O.vec3.dot(n,o[t[1]]);return n.concat(r)})),a=[];for(let t=0;ts[1]||s[0]>o[1])return 0}return 1}containsPoint(t){for(const e of this.planes){const i=e[3];if(O.vec3.dot([e[0],e[1],e[2]],t)+it.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,K(i,0,1))+t.center[e]}function ah(t){if(t.z0){for(const t of a)O.vec3.min(h,h,t),O.vec3.max(c,c,t);return new eh(h,c)}const u=[o[12]*r,o[13]*r,o[14]*r],d=s.getCenter(),p=K(t.center.lat,-Jl,Jl),f=K(d.lat,-Jl,Jl),m=ql(t.center.lng),_=Hl(p);let g=m-ql(d.lng);const y=_-Hl(f);g>.5?g-=1:gMath.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const t=[o[4]*r,o[5]*r,o[6]*r],e=-Math.sin(Z(y>=0?s.getSouth():s.getNorth()))*kl;O.vec3.scaleAndAdd(u,u,t,e)}const x=a[v],b=a[(v+1)%4],w=new oh(x,b,u),T=[sh(w,0)||x[0],sh(w,1)||x[1],sh(w,2)||x[2]],S=bh(t.zoom);if(S>0){const n=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?d=-1:pMath.PI/2*1.01}const Sh=Z(85),Mh=Math.cos(Sh),Eh=Math.sin(Sh),Ch=O.mat4.create(),Ih=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function Ah(t,e,i,n,r,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of e)for(const e of u){const u=e.add(a),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const t=i.projection.upVector(c,u.x,u.y);p.x+=t[0]*h*d,p.y+=t[1]*h*d,p.z+=t[2]*h*d}const f=o?u:Lh(p.x,p.y,p.z,n),m=o?t.tilespaceRays.map((t=>Dh(t,d))):t.queryGeometry.screenGeometry,_=O.vec4.transformMat4([],[p.x,p.y,p.z,1],n);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const t=Xl((e.y/Wi+c.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,h=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Kh(o,s,i,a,l,c,0),s}function Yh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=_u(r/n|0,t[r],t[r+1],o);return o&&hu(o,o.next)&&(gu(o),o=o.next),o}function Xh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!hu(n,n.next)&&0!==cu(n.prev,n,n.next))n=n.next;else{if(gu(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Kh(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=ou(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n >1;t[r]>1;t[r]0?1/(1.001-t):1+t}function Tt(t){return t>0?1-1/(1.001-t):-t}const St={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==gt){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{gt=null!="MISSING_ENV_VAR".API_URL_REGEX?new RegExp("MISSING_ENV_VAR".API_URL_REGEX):t}catch(e){gt=t}}return gt},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!St.API_URL)return null;try{const t=new URL(St.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Mt(t){return St.API_URL_REGEX.test(t)}function Et(t){return St.API_SPRITE_REGEX.test(t)}let Ct,It,At,Lt,Pt,$t;function Dt(){return null==Ct&&(Ct=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Ct}const kt={now:()=>void 0!==Lt?Lt:performance.now(),setNow(t){Lt=t},restoreNow(){Lt=void 0},frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;Pt||(Pt=document.createElement("canvas"));const r=Pt.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return(i>Pt.width||n>Pt.height)&&(Pt.width=i,Pt.height=n),r.clearRect(-e,-e,i+2*e,n+2*e),r.drawImage(t,0,0,i,n),r.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(It||(It=document.createElement("a")),It.href=t,It.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==At&&(At=window.matchMedia("(prefers-reduced-motion: reduce)")),At.matches)},hasCanvasFingerprintNoise(){if(void 0!==$t)return $t;if(!Dt())return $t=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n0?`?${o}`:""}`}const Ot="mapbox-tiles";let Bt=500,Ft=50;const Nt=["language","worldview","jobid"];let Ut,Vt;function jt(){try{return caches}catch(t){}}function Gt(){const t=jt();t&&null==Ut&&(Ut=t.open(Ot))}let Zt=1/0;const qt={supported:!1,testSupport:function(t){!Yt&&Wt&&(Xt?Jt(t):Ht=t)}};let Ht,Wt,Yt=!1,Xt=!1;const Kt="undefined"!=typeof self?self:{};function Jt(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Wt),t.isContextLost())return;qt.supported=!0}catch(t){}t.deleteTexture(e),Yt=!0}Kt.document&&(Wt=Kt.document.createElement("img"),Wt.onload=function(){Ht&&Jt(Ht),Ht=null,Xt=!0},Wt.onerror=function(){Yt=!0,Ht=null},Wt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Qt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Qt);class te extends Error{constructor(t,e,i){401===e&&Mt(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ee=mt()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,ie=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(ee())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const i=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:ee(),referrerPolicy:t.referrerPolicy,signal:i.signal});let r=!1,o=!1;const s=(a=n.url).indexOf("sku=")>0&&Mt(a);var a;"json"===t.type&&n.headers.set("Accept","application/json");const l=(i,r,a)=>{if(o)return;if(i&&"SecurityError"!==i.message&&ut(i.toString()),r&&a)return c(r);const l=Date.now();fetch(n).then((i=>{if(i.ok){const t=s?i.clone():null;return c(i,t,l)}return e(new te(i.statusText,i.status,t.url))})).catch((i=>{"AbortError"!==i.name&&e(new Error(`${i.message} ${t.url}`))}))},c=(i,s,a)=>{("arrayBuffer"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text()).then((t=>{o||(s&&a&&function(t,e,i){if(Gt(),null==Ut)return;const n=_t(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const r={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>r.headers.set(e,t))),n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString());const o=r.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i{const i=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,r);var n;Gt(),null!=Ut&&Ut.then((t=>t.put(s,i))).catch((t=>ut(t.message)))}))}(n,s,a),r=!0,e(null,t,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((t=>{o||e(new Error(t.message))}))};return s?function(t,e){if(Gt(),null==Ut)return e(null);Ut.then((i=>{let n=Rt(t.url,{persistentParams:Nt});const r=t.headers.get("Range");r&&(n=zt(n,{range:r})),i.match(n).then((t=>{const r=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=_t(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(t);i.delete(n),r&&i.put(n,t.clone()),e(null,t,r)})).catch(e)})).catch(e)}(n,l):l(null,null),{cancel:()=>{o=!0,r||i.abort()}}}(t,e);if(mt()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(t,e){const i=new XMLHttpRequest;i.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(i.responseType="arraybuffer");for(const e in t.headers)i.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===t.credentials,i.onerror=()=>{e(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.statusi.abort()}}(t,e)},ne=function(t,e){return ie(et(t,{type:"arrayBuffer"}),e)};function re(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const oe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let se,ae;se=[],ae=0;const le=function(t,e){if(qt.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),ae>=St.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return se.push(i),i}ae++;let i=!1;const n=()=>{if(!i)for(i=!0,ae--;se.length&&ae{n(),t?e(t):i&&(self.createImageBitmap?function(t,e){const i=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(i).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(i,((t,i)=>e(t,i,r,o))):function(t,e){const i=new Image;i.onload=()=>{e(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=oe}))},i.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});i.src=t.byteLength?URL.createObjectURL(n):oe}(i,((t,i)=>e(t,i,r,o))))}));return{cancel:()=>{r.cancel(),n()}}};var ce,he,ue,de={exports:{}},pe={exports:{}},fe={exports:{}},me=function(){if(ue)return de.exports;ue=1;var t=(ce||(ce=1,pe.exports=function(t,e){var i,n,r,o,s,a,l,c;for(n=t.length-(i=3&t.length),r=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>19))+((5*(r>>>16)&65535)>>16)&65535)>>16)*s&65535)>>17))*a+(((l>>>16)*a&65535)>>16))+((2246822507*(r>>>16)&65535)>>13))+((3266489909*(r>>>16)&65535)>>16)>>>0}),pe.exports),e=(he||(he=1,fe.exports=function(t,e){for(var i,n=t.length,r=e^n,o=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))>>16)&65535)>>16)&65535)>>24))+((1540483477*(i>>>16)&65535)>>16)&65535)>>13))+((1540483477*(r>>>16)&65535)>>15)>>>0}),fe.exports);return de.exports=t,de.exports.murmur3=t,de.exports.murmur2=e,de.exports}(),_e=e(me);class ge{constructor(t,...e){et(this,e[0]||{}),this.type=t}}class ye extends ge{constructor(t,e={}){super("error",et({error:t},e))}}function ve(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function xe(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class be{on(t,e){return this._listeners=this._listeners||{},ve(t,e,this._listeners),this}off(t,e){return xe(t,e,this._listeners),xe(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ve(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const i="string"==typeof t?new ge(t,e):t,n=i.type;if(this.listens(n)){i.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,i);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)xe(n,t,this._oneTimeListeners),t.call(this,i);const r=this._eventedParent;r&&(et(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(i))}else i instanceof ye&&console.error(i.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var we,Te={},Se=function(){if(we)return Te;we=1;var t={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function e(t){return(t=Math.round(t))255?255:t}function i(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))1?1:e;var e}function r(t,e,i){return i1&&(i-=1),6*i=0&&s>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)=0&&s>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var h=a.substr(0,l),u=a.substr(l+1,c-(l+1)).split(","),d=1;switch(h){case"rgba":if(4!==u.length)return null;d=n(u.pop());case"rgb":return 3!==u.length?null:[i(u[0]),i(u[1]),i(u[2]),d];case"hsla":if(4!==u.length)return null;d=n(u.pop());case"hsl":if(3!==u.length)return null;var p=(parseFloat(u[0])%360+360)%360/360,f=n(u[1]),m=n(u[2]),_=m=_.length)throw new Error("out of range");this.r=Ce(Ce(Ce(_[g],_[y],m),Ce(_[v],_[x],m),f),Ce(Ce(_[b],_[w],m),Ce(_[T],_[S],m),f),p)/255*r,this.g=Ce(Ce(Ce(_[g+1],_[y+1],m),Ce(_[v+1],_[x+1],m),f),Ce(Ce(_[b+1],_[w+1],m),Ce(_[T+1],_[S+1],m),f),p)/255*r,this.b=Ce(Ce(Ce(_[g+2],_[y+2],m),Ce(_[v+2],_[x+2],m),f),Ce(Ce(_[b+2],_[w+2],m),Ce(_[T+2],_[S+2],m),f),p)/255*r,this.a=r}else this.r=e,this.g=i,this.b=n,this.a=r}toArray(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*i/n,n]}toArray01(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,i/n,n]}toArray01Scaled(t){const{r:e,g:i,b:n,a:r}=this;return 0===r?[0,0,0]:[e/r*t,i/r*t,n/r*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:n}=this;return[t,e,i,n]}toArray01Linear(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(i/n,2.2),n]}}function Ce(t,e,i){return t*(1-i)+e*i}function Ie(t,e,i){return t.map(((t,n)=>Ce(t,e[n],i)))}Me.black=new Me(0,0,0,1),Me.white=new Me(1,1,1,1),Me.transparent=new Me(0,0,0,0),Me.red=new Me(1,0,0,1),Me.blue=new Me(0,0,1,1);var Ae=Object.freeze({__proto__:null,array:Ie,color:function(t,e,i){return new Me(Ce(t.r,e.r,i),Ce(t.g,e.g,i),Ce(t.b,e.b,i),Ce(t.a,e.a,i))},number:Ce});function Le(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class Pe extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class $e{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new $e(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const De={kind:"null"},ke={kind:"number"},ze={kind:"string"},Re={kind:"boolean"},Oe={kind:"color"},Be={kind:"object"},Fe={kind:"value"},Ne={kind:"collator"},Ue={kind:"formatted"},Ve={kind:"resolvedImage"};function je(t,e){return{kind:"array",itemType:t,N:e}}function Ge(t){if("array"===t.kind){const e=Ge(t.itemType);return"number"==typeof t.N?`array`:"value"===t.itemType.kind?"array":`array`}return t.kind}const Ze=[De,ke,ze,Re,Oe,Ue,Be,je(Fe),Ve];function qe(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!qe(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Ze)if(!qe(t,e))return null}return`Expected ${Ge(t)} but found ${Ge(e)} instead.`}function He(t,e){return e.some((e=>e.kind===t.kind))}function We(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class Ye{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Xe{constructor(t,e,i,n,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=r}}class Ke{constructor(t){this.sections=t}static fromString(t){return new Ke([new Xe(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof Ke?t:Ke.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toRenderColor(null).toArray())),t.push(i)}return t}}class Je{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new Je({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function Qe(t,e,i,n){return"number"==typeof t&&t>=0&&t=0&&e=0&&i=0&&n2){const i=t[1];if("string"!=typeof i||!(i in oi)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=oi[i],n++}else r=Fe;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}class ai{constructor(t){this.type=Ue,this.sections=t}static parse(t,e){if(t.length{const i=e.content.evaluate(t);return ei(i)===Ve?new Xe("",i,null,null,null):new Xe(ii(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class li{constructor(t,e){this.type=Ve,this.inputPrimary=t,this.inputSecondary=e}static parse(t,e){if(t.length-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function ci(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const hi={"to-boolean":Re,"to-color":Oe,"to-number":ke,"to-string":ze};class ui{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length0&&ti(t[1][0])))return null;r=je(ei(t[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Qe(e[0],e[1],e[2],e[3]),!i))return new Me(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ri(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ri(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Ke.fromString(ii(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Je.fromString(ii(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ii(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new ai([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new li(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const di=["Unknown","Point","LineString","Polygon"];class pi{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?di[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Me.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class fi{constructor(t,e,i,n,r){this.name=t,this.type=e,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(t){if(!this._evaluate){const t=fi.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=fi.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new Dn(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const o=[];let h=!1;for(let e=1;et))).map(mi).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/20&&yi(t,i,n);s0;)a--}0===r(t[i],o)?yi(t,i,a):(a++,yi(t,a,n)),ae?1:0}function xi(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r=e[2]||t[1]=e[3])}function Ti(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o(r=t)[1]!=(s=h)[1]>r[1]&&r[0]0&&a0}function Ei(t,e,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-r[1]*o[0]&&!(!Mi(t,e,i,n)||!Mi(i,n,t,e));var r,o}const Ci=8192;function Ii(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*Ci),Math.round(n*r*Ci)]}function Ai(t,e){for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}bi(e,t)}function Ri(t,e,i,n){const r=Math.pow(2,n.z)*Ci,o=[n.x*Ci,n.y*Ci],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];zi(n,e,i,r),s.push(n)}return s}function Oi(t,e,i,n){const r=Math.pow(2,n.z)*Ci,o=[n.x*Ci,n.y*Ci],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];bi(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]e)return Zi(r,o,(e-(i-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,i){let[n,r]=e,o=qi(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const e=(qi(t[0]-n)*this.kx*o+(t[1]-r)*this.ky*s)/(o*o+s*s);e>1?(n=i[0],r=i[1]):e>0&&(n+=o/this.kx*e,r+=s/this.ky*e)}return o=qi(t[0]-n)*this.kx,s=(t[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let i=1/0,n=t[0][0],r=t[0][1],o=0,s=0;for(let a=0;a1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=qi(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=h*h+u*u;pr.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!Gi(i[s],o[0])&&st&&0===r.length&&r.push(Zi(s,a,(t-(n-l))/l)),n>=e)return r.push(Zi(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return qi(t[0]-e[0])>=0&&qi(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class Hi{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var Wi=8192;function Yi(t,e){return e.dist-t.dist}function Xi(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=Ki(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function tn(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!Ji(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(wi(r,o)){if(mn(t,e))return 0}else if(mn(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(Ki(c)=s)continue;const h=o.range1,u=o.range2;if(Ki(h)=o)&&(o=Math.min(o,vn(t,e,r,!0,n,o)),0===o))return o;return o}function bn(t,e,i,n,r=1/0){let o=r;const s=tn(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&nn(s,en(r),n)>=o)continue;const i=yn(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function wn(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Tn{constructor(t,e){this.type=ke,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(ti(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class En{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=Fe),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof ni))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof ni?new En(i,ii(n.value),ii(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new En(i,ii(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let h=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),h=r.evaluate(t),t.scope=e}return n&&(h=Sn(n,h)),void 0===h||void 0===s&&void 0===a&&void 0===l||("number"==typeof h?h=Mn(h,s,a,l):Array.isArray(h)&&(h=h.map((t=>"number"==typeof t?Mn(t,s,a,l):t)))),void 0!==r&&void 0!==h&&o&&!o.includes(h)&&(h=c,n&&(h=Sn(n,h))),(n&&n!==this.type||void 0!==h&&ei(h)!==this.type)&&(h=Sn(this.type.kind,h)),h}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Cn(t){if(t instanceof fi){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;let e=!0;return t.eachChild((t=>{e&&!Cn(t)&&(e=!1)})),e}function In(t){if(t instanceof fi&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!In(t)&&(e=!1)})),e}function An(t){if(t instanceof En)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...An(t)])})),e}function Ln(t,e){if(t instanceof fi&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ln(t,e)&&(i=!1)})),i}class Pn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Pn(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class $n{constructor(t,e=[],i,n=new $e,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,null,i,n)._parse(t,r):this._parse(t,r)}parseObjectValue(t,e,i,n,r,o={}){return this.concat(e,i,n,r)._parse(t,o)}_parse(t,e){function i(t,e,i){return"assert"===i?new si(e,[t]):"coerce"===i?new ui(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ni)&&"resolvedImage"!==r.type.kind&&kn(r)){const e=new pi(this._scope,this.options);try{r=new ni(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return ui.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i,n){let r="number"==typeof t?this.path.concat(t):this.path;r="string"==typeof e?r.concat(e):r;const o=n?this.scope.concat(n):this.scope;return new $n(this.registry,r,i||null,o,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Pe(i,t))}checkSubtype(t,e){const i=qe(t,e);return i&&this.error(i),i}}var Dn=$n;function kn(t){if(t instanceof Pn)return kn(t.boundExpression);if(t instanceof fi&&"error"===t.name)return!1;if(t instanceof _i)return!1;if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;if(t instanceof En)return!1;const e=t instanceof ui||t instanceof si;let i=!0;return t.eachChild((t=>{i=e?i&&kn(t):i&&t instanceof ni})),!!i&&Cn(t)&&Ln(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function zn(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new ri("Input is not a number.");s=a-1}return 0}class Rn{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new Rn(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[zn(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const On=.95047,Bn=1.08883,Fn=4/29,Nn=6/29,Un=3*Nn*Nn,Vn=Nn*Nn*Nn,jn=Math.PI/180,Gn=180/Math.PI;function Zn(t){return t>Vn?Math.pow(t,1/3):t/Un+Fn}function qn(t){return t>Nn?t*t*t:Un*(t-Fn)}function Hn(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new er(a,i,n,r,s):e.error(`Type ${Ge(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=zn(e,n),s=er.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Ae[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Qn.reverse(Qn.interpolate(Qn.forward(a),Qn.forward(l),s)):Jn.reverse(Jn.interpolate(Jn.forward(a),Jn.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tqe(n,t.type)));return new nr(o?Fe:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof Je&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class rr{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new ri(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ri(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sr{constructor(t,e){this.type=Re,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);return i&&n?He(i.type,[Re,ze,ke,De,Fe])?new sr(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ar{constructor(t,e,i){this.type=ke,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);if(!i||!n)return null;if(!He(i.type,[Re,ze,ke,De,Fe]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new ar(i,n,r):null}return new ar(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class lr{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ei(t)))return null}else i=ei(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const h=e.parse(l,s,n);if(!h)return null;n=n||h.type,o.push(h)}const s=e.parse(t[1],1,Fe);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new lr(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(ei(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class cr{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class hr{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,ke);if(!i||!n)return null;if(!He(i.type,[je(Fe),ze,Fe]))return e.error(`Expected first argument to be of type array or string, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new hr(i.type,i,n,r):null}return new hr(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!We(e,["string","array"]))throw new ri(`Expected first argument to be of type array or string, but found ${Ge(ei(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ur(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function dr(t,e,i,n){return 0===n.compare(e,i)}function pr(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Re,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,Fe);if(!o)return null;if(!ur(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ge(o.type)}'.`);let s=e.parse(t[2],2,Fe);if(!s)return null;if(!ur(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ge(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${Ge(o.type)}' and '${Ge(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new si(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new si(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ne),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=ei(o),i=ei(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ri(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ei(o),i=ei(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const fr=pr("==",(function(t,e,i){return e===i}),dr),mr=pr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!dr(0,e,i,n)})),_r=pr("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),yr=pr("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class xr{constructor(t,e,i,n,r,o){this.type=ze,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ke);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parseObjectValue(n.locale,2,"locale",ze),!r))return null;let o=null;if(n.currency&&(o=e.parseObjectValue(n.currency,2,"currency",ze),!o))return null;let s=null;if(n.unit&&(s=e.parseObjectValue(n.unit,2,"unit",ze),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",ke),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",ke),!l)?null:new xr(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class br{constructor(t){this.type=ke,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Ge(i.type)} instead.`):new br(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ri(`Expected value to be of type string or array, but found ${Ge(ei(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function wr(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Tr={"==":fr,"!=":mr,">":gr,"=":vr,"=0&&t=0&&e=0&&i=0&&n-1}function $r(t){return"data-driven"===t["property-type"]}function Dr(t){return Pr(t.expression,"measure-light")}function kr(t){return Pr(t.expression,"zoom")}function zr(t){return!!t.expression&&t.expression.interpolated}function Rr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Or(t){return t}function Br(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(zr(e)?"exponential":"interval");if(i&&((t=Le({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Me.parse(t[1])]))),t.default=Me.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!tr[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=Vr;else if("interval"===o)s=Ur;else if("categorical"===o){s=Nr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=jr}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>Vr({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:er.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?Fr(t.default,e.default):s(t,e,r,a,l)}}}function Fr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Nr(t,e,i,n,r){return Fr(typeof i===r?n[i]:void 0,t.default,e.default)}function Ur(t,e,i){if("number"!==ci(i))return Fr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=zn(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function Vr(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==ci(i))return Fr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=zn(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Ae[e.type]||Or;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=tr[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function jr(t,e,i){return"color"===e.type?i=Me.parse(i):"formatted"===e.type?i=Ke.fromString(i.toString()):"resolvedImage"===e.type?i=Je.fromString(i.toString()):ci(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Fr(i,t.default,e.default)}fi.register(Tr,{error:[{kind:"error"},[ze],(t,[e])=>{throw new ri(e.evaluate(t))}],typeof:[ze,[Fe],(t,[e])=>Ge(ei(e.evaluate(t)))],"to-rgba":[je(ke,4),[Oe],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Oe,[ke,ke,ke],Sr],rgba:[Oe,[ke,ke,ke,ke],Sr],hsl:[Oe,[ke,ke,ke],Mr],hsla:[Oe,[ke,ke,ke,ke],Mr],has:{type:Re,overloads:[[[ze],(t,[e])=>Er(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Er(e.evaluate(t),i.evaluate(t))]]},get:{type:Fe,overloads:[[[ze],(t,[e])=>Cr(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Cr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Fe,[ze],(t,[e])=>Cr(e.evaluate(t),t.featureState||{})],properties:[Be,[],t=>t.properties()],"geometry-type":[ze,[],t=>t.geometryType()],id:[Fe,[],t=>t.id()],zoom:[ke,[],t=>t.globals.zoom],pitch:[ke,[],t=>t.globals.pitch||0],"distance-from-center":[ke,[],t=>t.distanceFromCenter()],"measure-light":[ke,[ze],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[ke,[],t=>t.globals.heatmapDensity||0],"line-progress":[ke,[],t=>t.globals.lineProgress||0],"raster-value":[ke,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[ke,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[ke,[],t=>t.globals.skyRadialProgress||0],accumulated:[Fe,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ke,Ir(ke),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[ke,Ir(ke),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:ke,overloads:[[[ke,ke],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ke],(t,[e])=>-e.evaluate(t)]]},"/":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ke,[ke],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))],log2:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ke,[ke],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ke,[ke],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ke,[ke],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ke,[ke],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ke,[ke],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ke,[ke],(t,[e])=>Math.atan(e.evaluate(t))],min:[ke,Ir(ke),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ke,Ir(ke),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ke,[ke],(t,[e])=>Math.abs(e.evaluate(t))],round:[ke,[ke],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[ke,[ke],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Re,[ze,Fe],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Re,[Fe],(t,[e])=>t.id()===e.value],"filter-type-==":[Re,[ze],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Re,[Fe],(t,[e])=>e.value in t.properties()],"filter-has-id":[Re,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Re,[je(ze)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Re,[je(Fe)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Re,[ze,je(Fe)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Re,[ze,je(Fe)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Re,[Re],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Re,[ze],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ze,[ze],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ze,[ze],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ze,Ir(Fe),(t,e)=>e.map((e=>ii(e.evaluate(t)))).join("")],"resolved-locale":[ze,[Ne],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[ke,[ke,ke,Fe],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Zr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Tr}function qr(t,e,i,n){const r=new Dn(Tr,[],e?function(t){const e={color:Oe,string:ze,number:ke,enum:ze,boolean:Re,formatted:Ue,resolvedImage:Ve};return"array"===t.type?je(e[t.value]||Fe,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Ar(new Gr(o,e,i,n)):Lr(r.errors)}class Hr{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!In(e.expression),this.configDependencies=An(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class Wr{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!In(e.expression),this.isLightConstant=r,this.configDependencies=An(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?er.interpolationFactor(this.interpolationType,t,e,i):0}}function Yr(t,e,i,n){if("error"===(t=qr(t,e,i,n)).result)return t;const r=t.value.expression,o=Cn(r);if(!o&&!$r(e))return Lr([new Pe("","data expressions not supported")]);const s=Ln(r,["zoom","pitch","distance-from-center"]);if(!s&&!kr(e))return Lr([new Pe("","zoom expressions not supported")]);const a=Ln(r,["measure-light"]);if(!a&&!Dr(e))return Lr([new Pe("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=Kr(r);return c||s||l?c instanceof Pe?Lr([c]):c instanceof er&&!zr(e)?Lr([new Pe("",'"interpolate" expressions cannot be used with this property')]):Ar(c?new Wr(o?"camera":"composite",t.value,c.labels,c instanceof er?c.interpolation:void 0,a):new Hr(o?"constant":"source",t.value,a)):Lr([new Pe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Xr{constructor(t,e){this._parameters=t,this._specification=e,Le(this,Br(this._parameters,this._specification))}static deserialize(t){return new Xr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Kr(t){let e=null;if(t instanceof rr)e=Kr(t.result);else if(t instanceof nr){for(const i of t.args)if(e=Kr(i),e)break}else(t instanceof Rn||t instanceof er)&&t.input instanceof fi&&"zoom"===t.input.name&&(e=t);return e instanceof Pe||t.eachChild((t=>{const i=Kr(t);i instanceof Pe?e=i:e&&i&&e!==i&&(e=new Pe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var Jr,Qr,to=function(){if(Qr)return Jr;Qr=1,Jr=e;var t=3;function e(e,i,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var o=new Int32Array(this.arrayBuffer);e=o[0],this.d=(i=o[1])+2*(n=o[2]);for(var s=0;s=h[p+0]&&n>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},e.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(n),d=l;d=0||(r[i]=so(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function ao(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||ro(t)||oo(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(ao);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,ao(t[i]));return e}if("Set"===e){const e=new Set;for(const i of Object.keys(t))"$name"!==i&&e.add(ao(t[i]));return e}const{klass:i}=io[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=ao(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const lo=t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(_s="error"),ms&&ms(t)};function vs(){xs.fire(new ge("pluginStateChange",{pluginStatus:_s,pluginURL:gs}))}const xs=new be,bs=function(){return _s},ws=function(){if(_s!==ds||!gs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_s=ps,vs(),gs&&ne({url:gs},(t=>{t?ys(t):(_s=fs,vs())}))},Ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_s===fs||null!=Ts.applyArabicShaping,isLoading:()=>_s===ps,setState(t){_s=t.pluginStatus,gs=t.pluginURL},isParsed:()=>null!=Ts.applyArabicShaping&&null!=Ts.processBidirectionalText&&null!=Ts.processStyledBidirectionalText,getPluginURL:()=>gs};class Ss{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!hs(i.charCodeAt(0),e))return!1;return!0}(t,Ts.isLoaded())}}class Ms{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(Rr(t))return new Xr(t,e);if(Zr(t)||Array.isArray(t)&&t.length>0){const r=Yr(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Me.parse(t)),{kind:"constant",configDependencies:new Set,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Es{constructor(t,e,i){this.property=t,this.value=new Ms(t,void 0,e,i)}transitioned(t,e){return new Is(this.property,this.value,e,et({},t.transition,this.transition),t.now)}untransitioned(){return new Is(this.property,this.value,null,{},0)}}class Cs{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.configDependencies=new Set}getValue(t){return ct(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property,this._scope,this._options)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:ct(e),this._scope,this._options),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]))}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(st(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ct(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property)),this._values[t].transition=ct(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new As(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new As(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Is{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};Ns(t)||(t=Ws(t));const r=t;let o=!0;try{o=function(t){if(!Gs(t))return t;let e=Fs(t);return js(e),e=Vs(e),e}(r)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `)}const s=Os[`filter_${n}`],a=qr(o,s,e,i);let l=null;if("error"===a.result)throw new Error(a.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(t,e,i)=>a.value.evaluate(t,e,{},i);let c=null,h=null;if(o!==r){const t=qr(r,s,e,i);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));c=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),h=!Cn(t.value.expression)}return{filter:l,dynamicFilter:c||void 0,needGeometry:Hs(o),needFeature:!!h}}function Vs(t){if(!Array.isArray(t))return t;const e=function(t){if(Zs.has(t[0]))for(let e=1;eVs(t)))}function js(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function Hs(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?Ys(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(Ws))):"all"===e?["all"].concat(t.slice(1).map(Ws)):"none"===e?["all"].concat(t.slice(1).map(Ws).map(Js)):"in"===e?Xs(t[1],t.slice(2)):"!in"===e?Js(Xs(t[1],t.slice(2))):"has"===e?Ks(t[1]):"!has"!==e||Js(Ks(t[1]));var i}function Ys(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Xs(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(qs)]]:["filter-in-small",t,["literal",e]]}}function Ks(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Js(t){return["!",t]}const Qs="";function ta(t,e){return e?`${t}${Qs}${e}`:t}const ea="-transition",ia=new Set(["fill","line","background","hillshade","raster"]);class na extends be{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=ta(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Ls(e.layout,this.scope,r),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),e.paint)){this._transitionablePaint=new Cs(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $s(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return!this.is3D()&&ia.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return st(t,ea)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(st(t,ea)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=st(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return lt({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Ps&&$r(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(t){this._filterCompiled||(this._featureFilter=Us(this.filter,this.scope,t),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const ra={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class oa{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class sa{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function aa(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=ra[t.type].BYTES_PER_ELEMENT,o=i=la(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:la(i,Math.max(n,e)),alignment:e}}function la(t,e){return Math.ceil(t/e)*e}class ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}ca.prototype.bytesPerElement=4,no(ca,"StructArrayLayout2i4");class ha extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}ha.prototype.bytesPerElement=6,no(ha,"StructArrayLayout3i6");class ua extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}ua.prototype.bytesPerElement=8,no(ua,"StructArrayLayout4i8");class da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}da.prototype.bytesPerElement=10,no(da,"StructArrayLayout5i10");class pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,t}}pa.prototype.bytesPerElement=12,no(pa,"StructArrayLayout2i4ub1f12");class fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}fa.prototype.bytesPerElement=16,no(fa,"StructArrayLayout4f16");class ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}ma.prototype.bytesPerElement=12,no(ma,"StructArrayLayout3f12");class _a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}_a.prototype.bytesPerElement=12,no(_a,"StructArrayLayout4ui1f12");class ga extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}ga.prototype.bytesPerElement=8,no(ga,"StructArrayLayout4ui8");class ya extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}ya.prototype.bytesPerElement=12,no(ya,"StructArrayLayout6i12");class va extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,n,r,o,s,a,l,c,h,u)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}va.prototype.bytesPerElement=24,no(va,"StructArrayLayout4i4ui4i24");class xa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}xa.prototype.bytesPerElement=20,no(xa,"StructArrayLayout3i3f20");class ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ba.prototype.bytesPerElement=4,no(ba,"StructArrayLayout1ul4");class wa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}wa.prototype.bytesPerElement=4,no(wa,"StructArrayLayout2ui4");class Ta extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,h,u,d)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,t}}Ta.prototype.bytesPerElement=40,no(Ta,"StructArrayLayout5i4f1i1ul2ui40");class Sa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Sa.prototype.bytesPerElement=16,no(Sa,"StructArrayLayout3i2i2i16");class Ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Ma.prototype.bytesPerElement=16,no(Ma,"StructArrayLayout2f1f2i16");class Ea extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=20*t,l=5*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Ea.prototype.bytesPerElement=20,no(Ea,"StructArrayLayout2ub4f20");class Ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Ca.prototype.bytesPerElement=6,no(Ca,"StructArrayLayout3ui6");class Ia extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Ia.prototype.bytesPerElement=60,no(Ia,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Aa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P){const $=this.length;return this.resize($+1),this.emplace($,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P,$){const D=20*t,k=40*t,z=80*t;return this.float32[D+0]=e,this.float32[D+1]=i,this.int16[k+4]=n,this.int16[k+5]=r,this.int16[k+6]=o,this.int16[k+7]=s,this.int16[k+8]=a,this.int16[k+9]=l,this.int16[k+10]=c,this.int16[k+11]=h,this.int16[k+12]=u,this.uint16[k+13]=d,this.uint16[k+14]=p,this.uint16[k+15]=f,this.uint16[k+16]=m,this.uint16[k+17]=_,this.uint16[k+18]=g,this.uint16[k+19]=y,this.uint16[k+20]=v,this.uint16[k+21]=x,this.uint16[k+22]=b,this.uint16[k+23]=w,this.uint16[k+24]=T,this.uint16[k+25]=S,this.uint16[k+26]=M,this.uint16[k+27]=E,this.uint32[D+14]=C,this.float32[D+15]=I,this.float32[D+16]=A,this.float32[D+17]=L,this.float32[D+18]=P,this.uint8[z+76]=$,t}}Aa.prototype.bytesPerElement=80,no(Aa,"StructArrayLayout2f9i15ui1ul4f1ub80");class La extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}La.prototype.bytesPerElement=4,no(La,"StructArrayLayout1f4");class Pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}Pa.prototype.bytesPerElement=20,no(Pa,"StructArrayLayout5f20");class $a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}$a.prototype.bytesPerElement=28,no($a,"StructArrayLayout7f28");class Da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}Da.prototype.bytesPerElement=12,no(Da,"StructArrayLayout1ul3ui12");class ka extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ka.prototype.bytesPerElement=2,no(ka,"StructArrayLayout1ui2");class za extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}za.prototype.bytesPerElement=8,no(za,"StructArrayLayout2f8");class Ra extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}Ra.prototype.bytesPerElement=64,no(Ra,"StructArrayLayout16f64");class Oa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}Oa.prototype.bytesPerElement=20,no(Oa,"StructArrayLayout4ui3f20");class Ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}Ba.prototype.bytesPerElement=2,no(Ba,"StructArrayLayout1i2");class Fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Fa.prototype.bytesPerElement=1,no(Fa,"StructArrayLayout1ub1");class Na extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Na.prototype.size=40;class Ua extends Ta{get(t){return new Na(this,t)}}no(Ua,"CollisionBoxArray");class Va extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}Va.prototype.size=60;class ja extends Ia{get(t){return new Va(this,t)}}no(ja,"PlacedSymbolArray");class Ga extends oa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ga.prototype.size=80;class Za extends Aa{get(t){return new Ga(this,t)}}no(Za,"SymbolInstanceArray");class qa extends La{getoffsetX(t){return this.float32[1*t+0]}}no(qa,"GlyphOffsetArray");class Ha extends ca{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}no(Ha,"SymbolLineVertexArray");class Wa extends oa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Wa.prototype.size=12;class Ya extends Da{get(t){return new Wa(this,t)}}no(Ya,"FeatureIndexArray");class Xa extends wa{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}no(Xa,"FillExtrusionCentroidArray");class Ka extends oa{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Ka.prototype.size=6;class Ja extends ha{get(t){return new Ka(this,t)}}no(Ja,"FillExtrusionWallArray");const Qa=aa([{name:"a_pos",components:2,type:"Int16"}],4),tl=aa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class el{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>el.MAX_VERTEX_ARRAY_LENGTH&&ut(`Max vertices per segment is ${el.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>el.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new el([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function il(t,e){return 256*(t=K(Math.floor(t),0,255))+K(Math.floor(e),0,255)}el.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,no(el,"SegmentVector");const nl=aa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),rl=aa([{name:"a_dash",components:4,type:"Uint16"}]);class ol{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(sl(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=sl(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return al(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new ol;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function sl(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;ll(t,o,s),ll(e,3*o,3*s),ll(e,3*o+1,3*s+1),ll(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Me?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new ml(t):new ul(t)}}class Tl{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new fl(t):new ul(t)}}class Sl{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ss(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=bl(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ss(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ss(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=bl(i.toRenderColor(r.lut)),o=bl(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof Ps&&$r(o.property.specification)))continue;const s=Ll(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const e=Dl(r,l,"source");this.binders[r]=h?new El(a,s,l,e,t.id):new Sl(a,s,l,e),n.push(`/a_${r}`)}else{const t=Dl(r,l,"composite");this.binders[r]=new Ml(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=h?new Tl(a.value,s):new wl(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Sl||e instanceof Ml?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Sl||l instanceof Ml||l instanceof El)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Tl&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),h=0!==c.length,u=h?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const d=this.binders[c];if(d.context=this.context,(d instanceof Sl||d instanceof Ml||d instanceof El)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=r.paint.get(c);d.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}if(!h)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof wl||i instanceof Tl)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Sl||i instanceof Ml||i instanceof El)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Cl(n,e,i);this.needsUpload=!1,this._featureMap=new ol,this._featureMapWithoutIds=new ol,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Al={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Ll(t,e){return Al[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Pl={"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a},"line-dasharray":{source:ga,composite:ga}},$l={color:{source:za,composite:fa},number:{source:La,composite:za}};function Dl(t,e,i){const n=Pl[t];return n&&n[i]||$l[e][i]}no(wl,"ConstantBinder"),no(Tl,"PatternConstantBinder"),no(Sl,"SourceExpressionBinder"),no(El,"PatternCompositeBinder"),no(Ml,"CompositeExpressionBinder"),no(Cl,"ProgramConfiguration",{omit:["_buffers"]}),no(Il,"ProgramConfigurationSet");const kl=Wi/Math.PI/2,zl=64,Rl=[zl,32,16],Ol=-kl,Bl=kl;function Fl(t,e,i,n=kl){return i=Z(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function Nl(t,e,i){return Fl(Math.cos(Z(t)),Math.sin(Z(t)),e,i)}const Ul=6371008.8,Vl=2*Math.PI*Ul;class jl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Gl{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}setSouthWest(t){return this._sw=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof jl)n=t,r=t;else{if(!(t instanceof Gl))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Gl.convert(t)):this.extend(jl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(jl.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new jl(n.lng,n.lat),this._ne=new jl(r.lng,r.lat)),this}getCenter(){return new jl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new jl(this.getWest(),this.getNorth())}getSouthEast(){return new jl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=jl.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat=l?(rc(t,e,i,c,h,o,u,a,l),rc(t,c,h,n,r,u,s,a,l)):t.push(s)}function oc(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&ut("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function uc(t,e,i){const n=t.loadGeometry(),r=t.extent,o=Wi/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Yl((e.x+t.x/r)/o),n=Xl((e.y+t.y/r)/o),h=c.project(i,n);t.x=(h.x*s-a)*r,t.y=(h.y*s-l)*r};for(let e=0;e=r||i.y=r||(h(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)hc(e,o);return n}function dc(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?uc(t):[]}}function pc(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function fc(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class mc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ca,this.indexArray=new Ca,this.segments=new el,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new ya,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,tl.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=Wi||n=Wi)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;fc(s,t,e),fc(s,t,e),fc(s,t,e),fc(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;pc(this.layoutVertexArray,i,n,-1,-1),pc(this.layoutVertexArray,i,n,1,-1),pc(this.layoutVertexArray,i,n,1,1),pc(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function _c(t,e){for(let i=0;i1){if(xc(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function Sc(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new U(e,i),new U(e,r),new U(n,r),new U(n,i)];if(t.length>2)for(const e of o)if(Mc(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=dt(t,e,i[0]);return o!==dt(t,e,i[1])||o!==dt(t,e,i[2])||o!==dt(t,e,i[3])}function Ic(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o0;o--)n=1this.canonical.z?new Uc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Uc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Vc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Vc(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Uc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Uc(e,this.wrap,e,i,n),new Uc(e,this.wrap,e,i+1,n),new Uc(e,this.wrap,e,i,n+1),new Uc(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=0;if(0===o)return 0;o!==e.length&&(i=!1)}return i?2:1}function Jc(t,e){for(const i of t.projections){const n=Xc(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function Qc(t,e){let i=0;const n=[0,0,0,0];for(let r=0;r=0&&i++;return i}class th{constructor(t,e){this.points=t||new Array(8).fill([0,0,0]),this.planes=e||new Array(6).fill([0,0,0,0]),this.bounds=eh.fromPoints(this.points),this.projections=[],this.frustumEdges=[O.vec3.sub([],this.points[2],this.points[3]),O.vec3.sub([],this.points[0],this.points[3]),O.vec3.sub([],this.points[4],this.points[0]),O.vec3.sub([],this.points[5],this.points[1]),O.vec3.sub([],this.points[6],this.points[2]),O.vec3.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:Xc(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:Xc(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(t,e,i,n){const r=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=O.vec4.transformMat4([],i,t),s=1/o[3]/e*r;return O.vec4.mul(o,o,[s,s,n?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=O.vec3.sub([],o[t[0]],o[t[1]]),i=O.vec3.sub([],o[t[2]],o[t[1]]),n=O.vec3.normalize([],O.vec3.cross([],e,i)),r=-O.vec3.dot(n,o[t[1]]);return n.concat(r)})),a=[];for(let t=0;ts[1]||s[0]>o[1])return 0}return 1}containsPoint(t){for(const e of this.planes){const i=e[3];if(O.vec3.dot([e[0],e[1],e[2]],t)+it.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,K(i,0,1))+t.center[e]}function ah(t){if(t.z0){for(const t of a)O.vec3.min(h,h,t),O.vec3.max(c,c,t);return new eh(h,c)}const u=[o[12]*r,o[13]*r,o[14]*r],d=s.getCenter(),p=K(t.center.lat,-Jl,Jl),f=K(d.lat,-Jl,Jl),m=ql(t.center.lng),_=Hl(p);let g=m-ql(d.lng);const y=_-Hl(f);g>.5?g-=1:gMath.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const t=[o[4]*r,o[5]*r,o[6]*r],e=-Math.sin(Z(y>=0?s.getSouth():s.getNorth()))*kl;O.vec3.scaleAndAdd(u,u,t,e)}const x=a[v],b=a[(v+1)%4],w=new oh(x,b,u),T=[sh(w,0)||x[0],sh(w,1)||x[1],sh(w,2)||x[2]],S=bh(t.zoom);if(S>0){const n=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?d=-1:pMath.PI/2*1.01}const Sh=Z(85),Mh=Math.cos(Sh),Eh=Math.sin(Sh),Ch=O.mat4.create(),Ih=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function Ah(t,e,i,n,r,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of e)for(const e of u){const u=e.add(a),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const t=i.projection.upVector(c,u.x,u.y);p.x+=t[0]*h*d,p.y+=t[1]*h*d,p.z+=t[2]*h*d}const f=o?u:Lh(p.x,p.y,p.z,n),m=o?t.tilespaceRays.map((t=>Dh(t,d))):t.queryGeometry.screenGeometry,_=O.vec4.transformMat4([],[p.x,p.y,p.z,1],n);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const t=Xl((e.y/Wi+c.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,h=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Kh(o,s,i,a,l,c,0),s}function Yh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=_u(r/n|0,t[r],t[r+1],o);return o&&hu(o,o.next)&&(gu(o),o=o.next),o}function Xh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!hu(n,n.next)&&0!==cu(n.prev,n,n.next))n=n.next;else{if(gu(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Kh(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=ou(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n 4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Qe(e[0],e[1],e[2],e[3]),!i))return new Me(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ri(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ri(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Ke.fromString(ii(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Je.fromString(ii(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ii(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new ai([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new li(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const di=["Unknown","Point","LineString","Polygon"];class pi{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?di[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Me.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class fi{constructor(t,e,i,n,r){this.name=t,this.type=e,this._evaluate=i,this.args=n,this._overloadIndex=r}evaluate(t){if(!this._evaluate){const t=fi.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=fi.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new Dn(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const o=[];let h=!1;for(let e=1;et))).map(mi).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/20&&yi(t,i,n);s0;)a--}0===r(t[i],o)?yi(t,i,a):(a++,yi(t,a,n)),ae?1:0}function xi(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r=e[2]||t[1]=e[3])}function Ti(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o(r=t)[1]!=(s=h)[1]>r[1]&&r[0]0&&a0}function Ei(t,e,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-r[1]*o[0]&&!(!Mi(t,e,i,n)||!Mi(i,n,t,e));var r,o}const Ci=8192;function Ii(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*Ci),Math.round(n*r*Ci)]}function Ai(t,e){for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}bi(e,t)}function Ri(t,e,i,n){const r=Math.pow(2,n.z)*Ci,o=[n.x*Ci,n.y*Ci],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];zi(n,e,i,r),s.push(n)}return s}function Oi(t,e,i,n){const r=Math.pow(2,n.z)*Ci,o=[n.x*Ci,n.y*Ci],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];bi(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]e)return Zi(r,o,(e-(i-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,i){let[n,r]=e,o=qi(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const e=(qi(t[0]-n)*this.kx*o+(t[1]-r)*this.ky*s)/(o*o+s*s);e>1?(n=i[0],r=i[1]):e>0&&(n+=o/this.kx*e,r+=s/this.ky*e)}return o=qi(t[0]-n)*this.kx,s=(t[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let i=1/0,n=t[0][0],r=t[0][1],o=0,s=0;for(let a=0;a1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=qi(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=h*h+u*u;pr.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!Gi(i[s],o[0])&&st&&0===r.length&&r.push(Zi(s,a,(t-(n-l))/l)),n>=e)return r.push(Zi(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return qi(t[0]-e[0])>=0&&qi(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class Hi{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var Wi=8192;function Yi(t,e){return e.dist-t.dist}function Xi(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=Ki(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function tn(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!Ji(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(wi(r,o)){if(mn(t,e))return 0}else if(mn(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(Ki(c)=s)continue;const h=o.range1,u=o.range2;if(Ki(h)=o)&&(o=Math.min(o,vn(t,e,r,!0,n,o)),0===o))return o;return o}function bn(t,e,i,n,r=1/0){let o=r;const s=tn(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&nn(s,en(r),n)>=o)continue;const i=yn(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function wn(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Tn{constructor(t,e){this.type=ke,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(ti(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class En{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=Fe),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof ni))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof ni?new En(i,ii(n.value),ii(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new En(i,ii(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let h=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),h=r.evaluate(t),t.scope=e}return n&&(h=Sn(n,h)),void 0===h||void 0===s&&void 0===a&&void 0===l||("number"==typeof h?h=Mn(h,s,a,l):Array.isArray(h)&&(h=h.map((t=>"number"==typeof t?Mn(t,s,a,l):t)))),void 0!==r&&void 0!==h&&o&&!o.includes(h)&&(h=c,n&&(h=Sn(n,h))),(n&&n!==this.type||void 0!==h&&ei(h)!==this.type)&&(h=Sn(this.type.kind,h)),h}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Cn(t){if(t instanceof fi){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;let e=!0;return t.eachChild((t=>{e&&!Cn(t)&&(e=!1)})),e}function In(t){if(t instanceof fi&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!In(t)&&(e=!1)})),e}function An(t){if(t instanceof En)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...An(t)])})),e}function Ln(t,e){if(t instanceof fi&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ln(t,e)&&(i=!1)})),i}class Pn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Pn(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class $n{constructor(t,e=[],i,n=new $e,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,null,i,n)._parse(t,r):this._parse(t,r)}parseObjectValue(t,e,i,n,r,o={}){return this.concat(e,i,n,r)._parse(t,o)}_parse(t,e){function i(t,e,i){return"assert"===i?new si(e,[t]):"coerce"===i?new ui(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ni)&&"resolvedImage"!==r.type.kind&&kn(r)){const e=new pi(this._scope,this.options);try{r=new ni(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return ui.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i,n){let r="number"==typeof t?this.path.concat(t):this.path;r="string"==typeof e?r.concat(e):r;const o=n?this.scope.concat(n):this.scope;return new $n(this.registry,r,i||null,o,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Pe(i,t))}checkSubtype(t,e){const i=qe(t,e);return i&&this.error(i),i}}var Dn=$n;function kn(t){if(t instanceof Pn)return kn(t.boundExpression);if(t instanceof fi&&"error"===t.name)return!1;if(t instanceof _i)return!1;if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;if(t instanceof En)return!1;const e=t instanceof ui||t instanceof si;let i=!0;return t.eachChild((t=>{i=e?i&&kn(t):i&&t instanceof ni})),!!i&&Cn(t)&&Ln(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function zn(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new ri("Input is not a number.");s=a-1}return 0}class Rn{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new Rn(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[zn(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const On=.95047,Bn=1.08883,Fn=4/29,Nn=6/29,Un=3*Nn*Nn,Vn=Nn*Nn*Nn,jn=Math.PI/180,Gn=180/Math.PI;function Zn(t){return t>Vn?Math.pow(t,1/3):t/Un+Fn}function qn(t){return t>Nn?t*t*t:Un*(t-Fn)}function Hn(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new er(a,i,n,r,s):e.error(`Type ${Ge(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=zn(e,n),s=er.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Ae[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Qn.reverse(Qn.interpolate(Qn.forward(a),Qn.forward(l),s)):Jn.reverse(Jn.interpolate(Jn.forward(a),Jn.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tqe(n,t.type)));return new nr(o?Fe:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof Je&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class rr{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new ri(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ri(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sr{constructor(t,e){this.type=Re,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);return i&&n?He(i.type,[Re,ze,ke,De,Fe])?new sr(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ar{constructor(t,e,i){this.type=ke,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);if(!i||!n)return null;if(!He(i.type,[Re,ze,ke,De,Fe]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new ar(i,n,r):null}return new ar(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class lr{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ei(t)))return null}else i=ei(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const h=e.parse(l,s,n);if(!h)return null;n=n||h.type,o.push(h)}const s=e.parse(t[1],1,Fe);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new lr(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(ei(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class cr{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class hr{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,ke);if(!i||!n)return null;if(!He(i.type,[je(Fe),ze,Fe]))return e.error(`Expected first argument to be of type array or string, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new hr(i.type,i,n,r):null}return new hr(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!We(e,["string","array"]))throw new ri(`Expected first argument to be of type array or string, but found ${Ge(ei(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ur(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function dr(t,e,i,n){return 0===n.compare(e,i)}function pr(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Re,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,Fe);if(!o)return null;if(!ur(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ge(o.type)}'.`);let s=e.parse(t[2],2,Fe);if(!s)return null;if(!ur(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ge(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${Ge(o.type)}' and '${Ge(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new si(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new si(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ne),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=ei(o),i=ei(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ri(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ei(o),i=ei(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const fr=pr("==",(function(t,e,i){return e===i}),dr),mr=pr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!dr(0,e,i,n)})),_r=pr("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),yr=pr("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class xr{constructor(t,e,i,n,r,o){this.type=ze,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ke);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parseObjectValue(n.locale,2,"locale",ze),!r))return null;let o=null;if(n.currency&&(o=e.parseObjectValue(n.currency,2,"currency",ze),!o))return null;let s=null;if(n.unit&&(s=e.parseObjectValue(n.unit,2,"unit",ze),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",ke),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",ke),!l)?null:new xr(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class br{constructor(t){this.type=ke,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Ge(i.type)} instead.`):new br(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ri(`Expected value to be of type string or array, but found ${Ge(ei(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function wr(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Tr={"==":fr,"!=":mr,">":gr,"=":vr,"=0&&t=0&&e=0&&i=0&&n-1}function $r(t){return"data-driven"===t["property-type"]}function Dr(t){return Pr(t.expression,"measure-light")}function kr(t){return Pr(t.expression,"zoom")}function zr(t){return!!t.expression&&t.expression.interpolated}function Rr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Or(t){return t}function Br(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(zr(e)?"exponential":"interval");if(i&&((t=Le({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Me.parse(t[1])]))),t.default=Me.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!tr[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=Vr;else if("interval"===o)s=Ur;else if("categorical"===o){s=Nr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=jr}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>Vr({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:er.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?Fr(t.default,e.default):s(t,e,r,a,l)}}}function Fr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Nr(t,e,i,n,r){return Fr(typeof i===r?n[i]:void 0,t.default,e.default)}function Ur(t,e,i){if("number"!==ci(i))return Fr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=zn(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function Vr(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==ci(i))return Fr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=zn(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Ae[e.type]||Or;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=tr[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function jr(t,e,i){return"color"===e.type?i=Me.parse(i):"formatted"===e.type?i=Ke.fromString(i.toString()):"resolvedImage"===e.type?i=Je.fromString(i.toString()):ci(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Fr(i,t.default,e.default)}fi.register(Tr,{error:[{kind:"error"},[ze],(t,[e])=>{throw new ri(e.evaluate(t))}],typeof:[ze,[Fe],(t,[e])=>Ge(ei(e.evaluate(t)))],"to-rgba":[je(ke,4),[Oe],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Oe,[ke,ke,ke],Sr],rgba:[Oe,[ke,ke,ke,ke],Sr],hsl:[Oe,[ke,ke,ke],Mr],hsla:[Oe,[ke,ke,ke,ke],Mr],has:{type:Re,overloads:[[[ze],(t,[e])=>Er(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Er(e.evaluate(t),i.evaluate(t))]]},get:{type:Fe,overloads:[[[ze],(t,[e])=>Cr(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Cr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Fe,[ze],(t,[e])=>Cr(e.evaluate(t),t.featureState||{})],properties:[Be,[],t=>t.properties()],"geometry-type":[ze,[],t=>t.geometryType()],id:[Fe,[],t=>t.id()],zoom:[ke,[],t=>t.globals.zoom],pitch:[ke,[],t=>t.globals.pitch||0],"distance-from-center":[ke,[],t=>t.distanceFromCenter()],"measure-light":[ke,[ze],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[ke,[],t=>t.globals.heatmapDensity||0],"line-progress":[ke,[],t=>t.globals.lineProgress||0],"raster-value":[ke,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[ke,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[ke,[],t=>t.globals.skyRadialProgress||0],accumulated:[Fe,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ke,Ir(ke),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[ke,Ir(ke),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:ke,overloads:[[[ke,ke],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ke],(t,[e])=>-e.evaluate(t)]]},"/":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ke,[ke],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))],log2:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ke,[ke],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ke,[ke],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ke,[ke],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ke,[ke],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ke,[ke],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ke,[ke],(t,[e])=>Math.atan(e.evaluate(t))],min:[ke,Ir(ke),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ke,Ir(ke),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ke,[ke],(t,[e])=>Math.abs(e.evaluate(t))],round:[ke,[ke],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[ke,[ke],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Re,[ze,Fe],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Re,[Fe],(t,[e])=>t.id()===e.value],"filter-type-==":[Re,[ze],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Re,[Fe],(t,[e])=>e.value in t.properties()],"filter-has-id":[Re,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Re,[je(ze)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Re,[je(Fe)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Re,[ze,je(Fe)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Re,[ze,je(Fe)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Re,[Re],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Re,[ze],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ze,[ze],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ze,[ze],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ze,Ir(Fe),(t,e)=>e.map((e=>ii(e.evaluate(t)))).join("")],"resolved-locale":[ze,[Ne],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[ke,[ke,ke,Fe],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Zr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Tr}function qr(t,e,i,n){const r=new Dn(Tr,[],e?function(t){const e={color:Oe,string:ze,number:ke,enum:ze,boolean:Re,formatted:Ue,resolvedImage:Ve};return"array"===t.type?je(e[t.value]||Fe,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Ar(new Gr(o,e,i,n)):Lr(r.errors)}class Hr{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!In(e.expression),this.configDependencies=An(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class Wr{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!In(e.expression),this.isLightConstant=r,this.configDependencies=An(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?er.interpolationFactor(this.interpolationType,t,e,i):0}}function Yr(t,e,i,n){if("error"===(t=qr(t,e,i,n)).result)return t;const r=t.value.expression,o=Cn(r);if(!o&&!$r(e))return Lr([new Pe("","data expressions not supported")]);const s=Ln(r,["zoom","pitch","distance-from-center"]);if(!s&&!kr(e))return Lr([new Pe("","zoom expressions not supported")]);const a=Ln(r,["measure-light"]);if(!a&&!Dr(e))return Lr([new Pe("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=Kr(r);return c||s||l?c instanceof Pe?Lr([c]):c instanceof er&&!zr(e)?Lr([new Pe("",'"interpolate" expressions cannot be used with this property')]):Ar(c?new Wr(o?"camera":"composite",t.value,c.labels,c instanceof er?c.interpolation:void 0,a):new Hr(o?"constant":"source",t.value,a)):Lr([new Pe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Xr{constructor(t,e){this._parameters=t,this._specification=e,Le(this,Br(this._parameters,this._specification))}static deserialize(t){return new Xr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Kr(t){let e=null;if(t instanceof rr)e=Kr(t.result);else if(t instanceof nr){for(const i of t.args)if(e=Kr(i),e)break}else(t instanceof Rn||t instanceof er)&&t.input instanceof fi&&"zoom"===t.input.name&&(e=t);return e instanceof Pe||t.eachChild((t=>{const i=Kr(t);i instanceof Pe?e=i:e&&i&&e!==i&&(e=new Pe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var Jr,Qr,to=function(){if(Qr)return Jr;Qr=1,Jr=e;var t=3;function e(e,i,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var o=new Int32Array(this.arrayBuffer);e=o[0],this.d=(i=o[1])+2*(n=o[2]);for(var s=0;s=h[p+0]&&n>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},e.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(n),d=l;d=0||(r[i]=so(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function ao(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||ro(t)||oo(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(ao);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,ao(t[i]));return e}if("Set"===e){const e=new Set;for(const i of Object.keys(t))"$name"!==i&&e.add(ao(t[i]));return e}const{klass:i}=io[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=ao(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const lo=t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(_s="error"),ms&&ms(t)};function vs(){xs.fire(new ge("pluginStateChange",{pluginStatus:_s,pluginURL:gs}))}const xs=new be,bs=function(){return _s},ws=function(){if(_s!==ds||!gs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_s=ps,vs(),gs&&ne({url:gs},(t=>{t?ys(t):(_s=fs,vs())}))},Ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_s===fs||null!=Ts.applyArabicShaping,isLoading:()=>_s===ps,setState(t){_s=t.pluginStatus,gs=t.pluginURL},isParsed:()=>null!=Ts.applyArabicShaping&&null!=Ts.processBidirectionalText&&null!=Ts.processStyledBidirectionalText,getPluginURL:()=>gs};class Ss{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!hs(i.charCodeAt(0),e))return!1;return!0}(t,Ts.isLoaded())}}class Ms{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(Rr(t))return new Xr(t,e);if(Zr(t)||Array.isArray(t)&&t.length>0){const r=Yr(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Me.parse(t)),{kind:"constant",configDependencies:new Set,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Es{constructor(t,e,i){this.property=t,this.value=new Ms(t,void 0,e,i)}transitioned(t,e){return new Is(this.property,this.value,e,et({},t.transition,this.transition),t.now)}untransitioned(){return new Is(this.property,this.value,null,{},0)}}class Cs{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.configDependencies=new Set}getValue(t){return ct(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property,this._scope,this._options)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:ct(e),this._scope,this._options),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]))}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(st(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ct(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property)),this._values[t].transition=ct(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new As(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new As(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Is{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};Ns(t)||(t=Ws(t));const r=t;let o=!0;try{o=function(t){if(!Gs(t))return t;let e=Fs(t);return js(e),e=Vs(e),e}(r)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `)}const s=Os[`filter_${n}`],a=qr(o,s,e,i);let l=null;if("error"===a.result)throw new Error(a.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(t,e,i)=>a.value.evaluate(t,e,{},i);let c=null,h=null;if(o!==r){const t=qr(r,s,e,i);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));c=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),h=!Cn(t.value.expression)}return{filter:l,dynamicFilter:c||void 0,needGeometry:Hs(o),needFeature:!!h}}function Vs(t){if(!Array.isArray(t))return t;const e=function(t){if(Zs.has(t[0]))for(let e=1;eVs(t)))}function js(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function Hs(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?Ys(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(Ws))):"all"===e?["all"].concat(t.slice(1).map(Ws)):"none"===e?["all"].concat(t.slice(1).map(Ws).map(Js)):"in"===e?Xs(t[1],t.slice(2)):"!in"===e?Js(Xs(t[1],t.slice(2))):"has"===e?Ks(t[1]):"!has"!==e||Js(Ks(t[1]));var i}function Ys(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Xs(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(qs)]]:["filter-in-small",t,["literal",e]]}}function Ks(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Js(t){return["!",t]}const Qs="";function ta(t,e){return e?`${t}${Qs}${e}`:t}const ea="-transition",ia=new Set(["fill","line","background","hillshade","raster"]);class na extends be{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=ta(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Ls(e.layout,this.scope,r),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),e.paint)){this._transitionablePaint=new Cs(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $s(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return!this.is3D()&&ia.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return st(t,ea)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(st(t,ea)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=st(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return lt({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Ps&&$r(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(t){this._filterCompiled||(this._featureFilter=Us(this.filter,this.scope,t),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const ra={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class oa{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class sa{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function aa(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=ra[t.type].BYTES_PER_ELEMENT,o=i=la(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:la(i,Math.max(n,e)),alignment:e}}function la(t,e){return Math.ceil(t/e)*e}class ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}ca.prototype.bytesPerElement=4,no(ca,"StructArrayLayout2i4");class ha extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}ha.prototype.bytesPerElement=6,no(ha,"StructArrayLayout3i6");class ua extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}ua.prototype.bytesPerElement=8,no(ua,"StructArrayLayout4i8");class da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}da.prototype.bytesPerElement=10,no(da,"StructArrayLayout5i10");class pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,t}}pa.prototype.bytesPerElement=12,no(pa,"StructArrayLayout2i4ub1f12");class fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}fa.prototype.bytesPerElement=16,no(fa,"StructArrayLayout4f16");class ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}ma.prototype.bytesPerElement=12,no(ma,"StructArrayLayout3f12");class _a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}_a.prototype.bytesPerElement=12,no(_a,"StructArrayLayout4ui1f12");class ga extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}ga.prototype.bytesPerElement=8,no(ga,"StructArrayLayout4ui8");class ya extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}ya.prototype.bytesPerElement=12,no(ya,"StructArrayLayout6i12");class va extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,n,r,o,s,a,l,c,h,u)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}va.prototype.bytesPerElement=24,no(va,"StructArrayLayout4i4ui4i24");class xa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}xa.prototype.bytesPerElement=20,no(xa,"StructArrayLayout3i3f20");class ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ba.prototype.bytesPerElement=4,no(ba,"StructArrayLayout1ul4");class wa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}wa.prototype.bytesPerElement=4,no(wa,"StructArrayLayout2ui4");class Ta extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,h,u,d)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,t}}Ta.prototype.bytesPerElement=40,no(Ta,"StructArrayLayout5i4f1i1ul2ui40");class Sa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Sa.prototype.bytesPerElement=16,no(Sa,"StructArrayLayout3i2i2i16");class Ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Ma.prototype.bytesPerElement=16,no(Ma,"StructArrayLayout2f1f2i16");class Ea extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=20*t,l=5*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Ea.prototype.bytesPerElement=20,no(Ea,"StructArrayLayout2ub4f20");class Ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Ca.prototype.bytesPerElement=6,no(Ca,"StructArrayLayout3ui6");class Ia extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Ia.prototype.bytesPerElement=60,no(Ia,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Aa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P){const $=this.length;return this.resize($+1),this.emplace($,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P,$){const D=20*t,k=40*t,z=80*t;return this.float32[D+0]=e,this.float32[D+1]=i,this.int16[k+4]=n,this.int16[k+5]=r,this.int16[k+6]=o,this.int16[k+7]=s,this.int16[k+8]=a,this.int16[k+9]=l,this.int16[k+10]=c,this.int16[k+11]=h,this.int16[k+12]=u,this.uint16[k+13]=d,this.uint16[k+14]=p,this.uint16[k+15]=f,this.uint16[k+16]=m,this.uint16[k+17]=_,this.uint16[k+18]=g,this.uint16[k+19]=y,this.uint16[k+20]=v,this.uint16[k+21]=x,this.uint16[k+22]=b,this.uint16[k+23]=w,this.uint16[k+24]=T,this.uint16[k+25]=S,this.uint16[k+26]=M,this.uint16[k+27]=E,this.uint32[D+14]=C,this.float32[D+15]=I,this.float32[D+16]=A,this.float32[D+17]=L,this.float32[D+18]=P,this.uint8[z+76]=$,t}}Aa.prototype.bytesPerElement=80,no(Aa,"StructArrayLayout2f9i15ui1ul4f1ub80");class La extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}La.prototype.bytesPerElement=4,no(La,"StructArrayLayout1f4");class Pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}Pa.prototype.bytesPerElement=20,no(Pa,"StructArrayLayout5f20");class $a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}$a.prototype.bytesPerElement=28,no($a,"StructArrayLayout7f28");class Da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}Da.prototype.bytesPerElement=12,no(Da,"StructArrayLayout1ul3ui12");class ka extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ka.prototype.bytesPerElement=2,no(ka,"StructArrayLayout1ui2");class za extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}za.prototype.bytesPerElement=8,no(za,"StructArrayLayout2f8");class Ra extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}Ra.prototype.bytesPerElement=64,no(Ra,"StructArrayLayout16f64");class Oa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}Oa.prototype.bytesPerElement=20,no(Oa,"StructArrayLayout4ui3f20");class Ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}Ba.prototype.bytesPerElement=2,no(Ba,"StructArrayLayout1i2");class Fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Fa.prototype.bytesPerElement=1,no(Fa,"StructArrayLayout1ub1");class Na extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Na.prototype.size=40;class Ua extends Ta{get(t){return new Na(this,t)}}no(Ua,"CollisionBoxArray");class Va extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}Va.prototype.size=60;class ja extends Ia{get(t){return new Va(this,t)}}no(ja,"PlacedSymbolArray");class Ga extends oa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ga.prototype.size=80;class Za extends Aa{get(t){return new Ga(this,t)}}no(Za,"SymbolInstanceArray");class qa extends La{getoffsetX(t){return this.float32[1*t+0]}}no(qa,"GlyphOffsetArray");class Ha extends ca{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}no(Ha,"SymbolLineVertexArray");class Wa extends oa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Wa.prototype.size=12;class Ya extends Da{get(t){return new Wa(this,t)}}no(Ya,"FeatureIndexArray");class Xa extends wa{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}no(Xa,"FillExtrusionCentroidArray");class Ka extends oa{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Ka.prototype.size=6;class Ja extends ha{get(t){return new Ka(this,t)}}no(Ja,"FillExtrusionWallArray");const Qa=aa([{name:"a_pos",components:2,type:"Int16"}],4),tl=aa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class el{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>el.MAX_VERTEX_ARRAY_LENGTH&&ut(`Max vertices per segment is ${el.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>el.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new el([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function il(t,e){return 256*(t=K(Math.floor(t),0,255))+K(Math.floor(e),0,255)}el.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,no(el,"SegmentVector");const nl=aa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),rl=aa([{name:"a_dash",components:4,type:"Uint16"}]);class ol{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(sl(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=sl(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return al(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new ol;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function sl(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;ll(t,o,s),ll(e,3*o,3*s),ll(e,3*o+1,3*s+1),ll(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Me?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new ml(t):new ul(t)}}class Tl{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new fl(t):new ul(t)}}class Sl{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ss(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=bl(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ss(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ss(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=bl(i.toRenderColor(r.lut)),o=bl(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof Ps&&$r(o.property.specification)))continue;const s=Ll(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const e=Dl(r,l,"source");this.binders[r]=h?new El(a,s,l,e,t.id):new Sl(a,s,l,e),n.push(`/a_${r}`)}else{const t=Dl(r,l,"composite");this.binders[r]=new Ml(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=h?new Tl(a.value,s):new wl(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Sl||e instanceof Ml?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Sl||l instanceof Ml||l instanceof El)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Tl&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),h=0!==c.length,u=h?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const d=this.binders[c];if(d.context=this.context,(d instanceof Sl||d instanceof Ml||d instanceof El)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=r.paint.get(c);d.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}if(!h)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof wl||i instanceof Tl)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Sl||i instanceof Ml||i instanceof El)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Cl(n,e,i);this.needsUpload=!1,this._featureMap=new ol,this._featureMapWithoutIds=new ol,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Al={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Ll(t,e){return Al[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Pl={"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a},"line-dasharray":{source:ga,composite:ga}},$l={color:{source:za,composite:fa},number:{source:La,composite:za}};function Dl(t,e,i){const n=Pl[t];return n&&n[i]||$l[e][i]}no(wl,"ConstantBinder"),no(Tl,"PatternConstantBinder"),no(Sl,"SourceExpressionBinder"),no(El,"PatternCompositeBinder"),no(Ml,"CompositeExpressionBinder"),no(Cl,"ProgramConfiguration",{omit:["_buffers"]}),no(Il,"ProgramConfigurationSet");const kl=Wi/Math.PI/2,zl=64,Rl=[zl,32,16],Ol=-kl,Bl=kl;function Fl(t,e,i,n=kl){return i=Z(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function Nl(t,e,i){return Fl(Math.cos(Z(t)),Math.sin(Z(t)),e,i)}const Ul=6371008.8,Vl=2*Math.PI*Ul;class jl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Gl{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}setSouthWest(t){return this._sw=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof jl)n=t,r=t;else{if(!(t instanceof Gl))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Gl.convert(t)):this.extend(jl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(jl.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new jl(n.lng,n.lat),this._ne=new jl(r.lng,r.lat)),this}getCenter(){return new jl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new jl(this.getWest(),this.getNorth())}getSouthEast(){return new jl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=jl.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat=l?(rc(t,e,i,c,h,o,u,a,l),rc(t,c,h,n,r,u,s,a,l)):t.push(s)}function oc(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&ut("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function uc(t,e,i){const n=t.loadGeometry(),r=t.extent,o=Wi/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Yl((e.x+t.x/r)/o),n=Xl((e.y+t.y/r)/o),h=c.project(i,n);t.x=(h.x*s-a)*r,t.y=(h.y*s-l)*r};for(let e=0;e=r||i.y=r||(h(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)hc(e,o);return n}function dc(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?uc(t):[]}}function pc(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function fc(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class mc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ca,this.indexArray=new Ca,this.segments=new el,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new ya,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,tl.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=Wi||n=Wi)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;fc(s,t,e),fc(s,t,e),fc(s,t,e),fc(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;pc(this.layoutVertexArray,i,n,-1,-1),pc(this.layoutVertexArray,i,n,1,-1),pc(this.layoutVertexArray,i,n,1,1),pc(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function _c(t,e){for(let i=0;i1){if(xc(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function Sc(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new U(e,i),new U(e,r),new U(n,r),new U(n,i)];if(t.length>2)for(const e of o)if(Mc(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=dt(t,e,i[0]);return o!==dt(t,e,i[1])||o!==dt(t,e,i[2])||o!==dt(t,e,i[3])}function Ic(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o0;o--)n=1this.canonical.z?new Uc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Uc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Vc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Vc(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Uc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Uc(e,this.wrap,e,i,n),new Uc(e,this.wrap,e,i+1,n),new Uc(e,this.wrap,e,i,n+1),new Uc(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=0;if(0===o)return 0;o!==e.length&&(i=!1)}return i?2:1}function Jc(t,e){for(const i of t.projections){const n=Xc(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function Qc(t,e){let i=0;const n=[0,0,0,0];for(let r=0;r=0&&i++;return i}class th{constructor(t,e){this.points=t||new Array(8).fill([0,0,0]),this.planes=e||new Array(6).fill([0,0,0,0]),this.bounds=eh.fromPoints(this.points),this.projections=[],this.frustumEdges=[O.vec3.sub([],this.points[2],this.points[3]),O.vec3.sub([],this.points[0],this.points[3]),O.vec3.sub([],this.points[4],this.points[0]),O.vec3.sub([],this.points[5],this.points[1]),O.vec3.sub([],this.points[6],this.points[2]),O.vec3.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:Xc(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:Xc(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(t,e,i,n){const r=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=O.vec4.transformMat4([],i,t),s=1/o[3]/e*r;return O.vec4.mul(o,o,[s,s,n?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=O.vec3.sub([],o[t[0]],o[t[1]]),i=O.vec3.sub([],o[t[2]],o[t[1]]),n=O.vec3.normalize([],O.vec3.cross([],e,i)),r=-O.vec3.dot(n,o[t[1]]);return n.concat(r)})),a=[];for(let t=0;ts[1]||s[0]>o[1])return 0}return 1}containsPoint(t){for(const e of this.planes){const i=e[3];if(O.vec3.dot([e[0],e[1],e[2]],t)+it.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,K(i,0,1))+t.center[e]}function ah(t){if(t.z0){for(const t of a)O.vec3.min(h,h,t),O.vec3.max(c,c,t);return new eh(h,c)}const u=[o[12]*r,o[13]*r,o[14]*r],d=s.getCenter(),p=K(t.center.lat,-Jl,Jl),f=K(d.lat,-Jl,Jl),m=ql(t.center.lng),_=Hl(p);let g=m-ql(d.lng);const y=_-Hl(f);g>.5?g-=1:gMath.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const t=[o[4]*r,o[5]*r,o[6]*r],e=-Math.sin(Z(y>=0?s.getSouth():s.getNorth()))*kl;O.vec3.scaleAndAdd(u,u,t,e)}const x=a[v],b=a[(v+1)%4],w=new oh(x,b,u),T=[sh(w,0)||x[0],sh(w,1)||x[1],sh(w,2)||x[2]],S=bh(t.zoom);if(S>0){const n=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?d=-1:pMath.PI/2*1.01}const Sh=Z(85),Mh=Math.cos(Sh),Eh=Math.sin(Sh),Ch=O.mat4.create(),Ih=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function Ah(t,e,i,n,r,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of e)for(const e of u){const u=e.add(a),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const t=i.projection.upVector(c,u.x,u.y);p.x+=t[0]*h*d,p.y+=t[1]*h*d,p.z+=t[2]*h*d}const f=o?u:Lh(p.x,p.y,p.z,n),m=o?t.tilespaceRays.map((t=>Dh(t,d))):t.queryGeometry.screenGeometry,_=O.vec4.transformMat4([],[p.x,p.y,p.z,1],n);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const t=Xl((e.y/Wi+c.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,h=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Kh(o,s,i,a,l,c,0),s}function Yh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=_u(r/n|0,t[r],t[r+1],o);return o&&hu(o,o.next)&&(gu(o),o=o.next),o}function Xh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!hu(n,n.next)&&0!==cu(n.prev,n,n.next))n=n.next;else{if(gu(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Kh(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=ou(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n r.index||n.index===r.index&&n.t>r.t){const t=n;n=r,r=t}const o=[n.point],s=n.index+1,a=r.index;!Gi(i[s],o[0])&&st&&0===r.length&&r.push(Zi(s,a,(t-(n-l))/l)),n>=e)return r.push(Zi(s,a,(e-(n-l))/l)),r;n>t&&r.push(a)}return r}bufferPoint(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[0]+n,t[1]+i]}bufferBBox(t,e){const i=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-i,t[2]+n,t[3]+i]}insideBBox(t,e){return qi(t[0]-e[0])>=0&&qi(t[0]-e[2])=e[1]&&t[1]180;)t-=360;return t}class Hi{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=r}}var Wi=8192;function Yi(t,e){return e.dist-t.dist}function Xi(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let i=0;i=t[0]&&t[1]t[1])return[null,null];const i=Ki(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===i)return[t,null];const e=Math.floor(i/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function tn(t,e){const i=[1/0,1/0,-1/0,-1/0];if(!Ji(e,t.length))return i;for(let n=e[0];ne[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]=n)return n;if(wi(r,o)){if(mn(t,e))return 0}else if(mn(e,t))return 0;let s=n;for(const n of t)for(let t=0,r=n.length,o=r-1;t=o)continue;const c=r.range1;if(Ki(c)=s)continue;const h=o.range1,u=o.range2;if(Ki(h)=o)&&(o=Math.min(o,vn(t,e,r,!0,n,o)),0===o))return o;return o}function bn(t,e,i,n,r=1/0){let o=r;const s=tn(t,[0,t.length-1]);for(const r of i){if(o!==1/0&&nn(s,en(r),n)>=o)continue;const i=yn(t,e,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function wn(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Tn{constructor(t,e){this.type=ke,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(ti(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;ti&&(t=i),t}class En{constructor(t,e,i){this.type=t,this.key=e,this.scope=i}static parse(t,e){let i=e.expectedType;if(null==i&&(i=Fe),t.length3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof ni))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const r=e.parse(t[2],2);return r instanceof ni?new En(i,ii(n.value),ii(r.value)):e.error("Scope of 'config' expression must be a string literal.")}return new En(i,ii(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),i=t.getConfig(e);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(t);let h=c;if(r){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),h=r.evaluate(t),t.scope=e}return n&&(h=Sn(n,h)),void 0===h||void 0===s&&void 0===a&&void 0===l||("number"==typeof h?h=Mn(h,s,a,l):Array.isArray(h)&&(h=h.map((t=>"number"==typeof t?Mn(t,s,a,l):t)))),void 0!==r&&void 0!==h&&o&&!o.includes(h)&&(h=c,n&&(h=Sn(n,h))),(n&&n!==this.type||void 0!==h&&ei(h)!==this.type)&&(h=Sn(this.type.kind,h)),h}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Cn(t){if(t instanceof fi){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;let e=!0;return t.eachChild((t=>{e&&!Cn(t)&&(e=!1)})),e}function In(t){if(t instanceof fi&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!In(t)&&(e=!1)})),e}function An(t){if(t instanceof En)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...An(t)])})),e}function Ln(t,e){if(t instanceof fi&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ln(t,e)&&(i=!1)})),i}class Pn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Pn(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class $n{constructor(t,e=[],i,n=new $e,r=[],o,s){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s}parse(t,e,i,n,r={}){return e||i?this.concat(e,null,i,n)._parse(t,r):this._parse(t,r)}parseObjectValue(t,e,i,n,r,o={}){return this.concat(e,i,n,r)._parse(t,o)}_parse(t,e){function i(t,e,i){return"assert"===i?new si(e,[t]):"coerce"===i?new ui(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let r=n.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,n=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ni)&&"resolvedImage"!==r.type.kind&&kn(r)){const e=new pi(this._scope,this.options);try{r=new ni(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return ui.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i,n){let r="number"==typeof t?this.path.concat(t):this.path;r="string"==typeof e?r.concat(e):r;const o=n?this.scope.concat(n):this.scope;return new $n(this.registry,r,i||null,o,this.errors,this._scope,this.options)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Pe(i,t))}checkSubtype(t,e){const i=qe(t,e);return i&&this.error(i),i}}var Dn=$n;function kn(t){if(t instanceof Pn)return kn(t.boundExpression);if(t instanceof fi&&"error"===t.name)return!1;if(t instanceof _i)return!1;if(t instanceof Bi)return!1;if(t instanceof Tn)return!1;if(t instanceof En)return!1;const e=t instanceof ui||t instanceof si;let i=!0;return t.eachChild((t=>{i=e?i&&kn(t):i&&t instanceof ni})),!!i&&Cn(t)&&Ln(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function zn(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;oe))throw new ri("Input is not a number.");s=a-1}return 0}class Rn{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new Rn(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1]?i[r-1].evaluate(t):i[zn(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const On=.95047,Bn=1.08883,Fn=4/29,Nn=6/29,Un=3*Nn*Nn,Vn=Nn*Nn*Nn,jn=Math.PI/180,Gn=180/Math.PI;function Zn(t){return t>Vn?Math.pow(t,1/3):t/Un+Fn}function qn(t){return t>Nn?t*t*t:Un*(t-Fn)}function Hn(t){return 255*(t180||n"number"!=typeof t||t1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new er(a,i,n,r,s):e.error(`Type ${Ge(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n=e[r-1])return i[r-1].evaluate(t);const o=zn(e,n),s=er.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Ae[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Qn.reverse(Qn.interpolate(Qn.forward(a),Qn.forward(l),s)):Jn.reverse(Jn.interpolate(Jn.forward(a),Jn.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tqe(n,t.type)));return new nr(o?Fe:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof Je&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class rr{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length=i.length)throw new ri(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ri(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sr{constructor(t,e){this.type=Re,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);return i&&n?He(i.type,[Re,ze,ke,De,Fe])?new sr(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ar{constructor(t,e,i){this.type=ke,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,Fe);if(!i||!n)return null;if(!He(i.type,[Re,ze,ke,De,Fe]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new ar(i,n,r):null}return new ar(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!We(e,["boolean","string","number","null"]))throw new ri(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(ei(e))} instead.`);if(!We(i,["string","array"]))throw new ri(`Expected second argument to be of type array or string, but found ${Ge(ei(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class lr{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(t,e){if(t.lengthNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ei(t)))return null}else i=ei(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const h=e.parse(l,s,n);if(!h)return null;n=n||h.type,o.push(h)}const s=e.parse(t[1],1,Fe);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new lr(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(ei(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class cr{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.lengthe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class hr{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Fe),n=e.parse(t[2],2,ke);if(!i||!n)return null;if(!He(i.type,[je(Fe),ze,Fe]))return e.error(`Expected first argument to be of type array or string, but found ${Ge(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ke);return r?new hr(i.type,i,n,r):null}return new hr(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!We(e,["string","array"]))throw new ri(`Expected first argument to be of type array or string, but found ${Ge(ei(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ur(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function dr(t,e,i,n){return 0===n.compare(e,i)}function pr(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Re,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,Fe);if(!o)return null;if(!ur(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ge(o.type)}'.`);let s=e.parse(t[2],2,Fe);if(!s)return null;if(!ur(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ge(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${Ge(o.type)}' and '${Ge(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new si(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new si(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,Ne),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=ei(o),i=ei(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ri(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ei(o),i=ei(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const fr=pr("==",(function(t,e,i){return e===i}),dr),mr=pr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!dr(0,e,i,n)})),_r=pr("",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),yr=pr("=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class xr{constructor(t,e,i,n,r,o){this.type=ze,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ke);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parseObjectValue(n.locale,2,"locale",ze),!r))return null;let o=null;if(n.currency&&(o=e.parseObjectValue(n.currency,2,"currency",ze),!o))return null;let s=null;if(n.unit&&(s=e.parseObjectValue(n.unit,2,"unit",ze),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",ke),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",ke),!l)?null:new xr(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class br{constructor(t){this.type=ke,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Ge(i.type)} instead.`):new br(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ri(`Expected value to be of type string or array, but found ${Ge(ei(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}function wr(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Tr={"==":fr,"!=":mr,">":gr,"=":vr,"=0&&t=0&&e=0&&i=0&&n-1}function $r(t){return"data-driven"===t["property-type"]}function Dr(t){return Pr(t.expression,"measure-light")}function kr(t){return Pr(t.expression,"zoom")}function zr(t){return!!t.expression&&t.expression.interpolated}function Rr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Or(t){return t}function Br(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(zr(e)?"exponential":"interval");if(i&&((t=Le({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Me.parse(t[1])]))),t.default=Me.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!tr[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=Vr;else if("interval"===o)s=Ur;else if("categorical"===o){s=Nr,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=jr}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>Vr({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:er.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?Fr(t.default,e.default):s(t,e,r,a,l)}}}function Fr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Nr(t,e,i,n,r){return Fr(typeof i===r?n[i]:void 0,t.default,e.default)}function Ur(t,e,i){if("number"!==ci(i))return Fr(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i=t.stops[n-1][0])return t.stops[n-1][1];const r=zn(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function Vr(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==ci(i))return Fr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i=t.stops[r-1][0])return t.stops[r-1][1];const o=zn(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Ae[e.type]||Or;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=tr[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function jr(t,e,i){return"color"===e.type?i=Me.parse(i):"formatted"===e.type?i=Ke.fromString(i.toString()):"resolvedImage"===e.type?i=Je.fromString(i.toString()):ci(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Fr(i,t.default,e.default)}fi.register(Tr,{error:[{kind:"error"},[ze],(t,[e])=>{throw new ri(e.evaluate(t))}],typeof:[ze,[Fe],(t,[e])=>Ge(ei(e.evaluate(t)))],"to-rgba":[je(ke,4),[Oe],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Oe,[ke,ke,ke],Sr],rgba:[Oe,[ke,ke,ke,ke],Sr],hsl:[Oe,[ke,ke,ke],Mr],hsla:[Oe,[ke,ke,ke,ke],Mr],has:{type:Re,overloads:[[[ze],(t,[e])=>Er(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Er(e.evaluate(t),i.evaluate(t))]]},get:{type:Fe,overloads:[[[ze],(t,[e])=>Cr(e.evaluate(t),t.properties())],[[ze,Be],(t,[e,i])=>Cr(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Fe,[ze],(t,[e])=>Cr(e.evaluate(t),t.featureState||{})],properties:[Be,[],t=>t.properties()],"geometry-type":[ze,[],t=>t.geometryType()],id:[Fe,[],t=>t.id()],zoom:[ke,[],t=>t.globals.zoom],pitch:[ke,[],t=>t.globals.pitch||0],"distance-from-center":[ke,[],t=>t.distanceFromCenter()],"measure-light":[ke,[ze],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[ke,[],t=>t.globals.heatmapDensity||0],"line-progress":[ke,[],t=>t.globals.lineProgress||0],"raster-value":[ke,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[ke,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[ke,[],t=>t.globals.skyRadialProgress||0],accumulated:[Fe,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ke,Ir(ke),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[ke,Ir(ke),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:ke,overloads:[[[ke,ke],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ke],(t,[e])=>-e.evaluate(t)]]},"/":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ke,[ke,ke],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ke,[ke],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))],log2:[ke,[ke],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ke,[ke],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ke,[ke],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ke,[ke],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ke,[ke],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ke,[ke],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ke,[ke],(t,[e])=>Math.atan(e.evaluate(t))],min:[ke,Ir(ke),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ke,Ir(ke),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ke,[ke],(t,[e])=>Math.abs(e.evaluate(t))],round:[ke,[ke],(t,[e])=>{const i=e.evaluate(t);return iMath.floor(e.evaluate(t))],ceil:[ke,[ke],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Re,[ze,Fe],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Re,[Fe],(t,[e])=>t.id()===e.value],"filter-type-==":[Re,[ze],(t,[e])=>t.geometryType()===e.value],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i=":[Re,[ze,Fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Re,[Fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Re,[Fe],(t,[e])=>e.value in t.properties()],"filter-has-id":[Re,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Re,[je(ze)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Re,[je(Fe)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Re,[ze,je(Fe)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Re,[ze,je(Fe)],(t,[e,i])=>function(t,e,i,n){for(;i>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Re,overloads:[[[Re,Re],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Ir(Re),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Re,[Re],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Re,[ze],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ze,[ze],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ze,[ze],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ze,Ir(Fe),(t,e)=>e.map((e=>ii(e.evaluate(t)))).join("")],"resolved-locale":[ze,[Ne],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[ke,[ke,ke,Fe],(t,e)=>{const[i,n,r]=e.map((e=>e.evaluate(t)));if(i>n)return i;if(i===n)return i;let o;if("string"==typeof r)o=function(t){let e=0;if(0===t.length)return e;for(let i=0;iJSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Zr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Tr}function qr(t,e,i,n){const r=new Dn(Tr,[],e?function(t){const e={color:Oe,string:ze,number:ke,enum:ze,boolean:Re,formatted:Ue,resolvedImage:Ve};return"array"===t.type?je(e[t.value]||Fe,t.length):e[t.type]}(e):void 0,void 0,void 0,i,n),o=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return o?Ar(new Gr(o,e,i,n)):Lr(r.errors)}class Hr{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!In(e.expression),this.configDependencies=An(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class Wr{constructor(t,e,i,n,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!In(e.expression),this.isLightConstant=r,this.configDependencies=An(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?er.interpolationFactor(this.interpolationType,t,e,i):0}}function Yr(t,e,i,n){if("error"===(t=qr(t,e,i,n)).result)return t;const r=t.value.expression,o=Cn(r);if(!o&&!$r(e))return Lr([new Pe("","data expressions not supported")]);const s=Ln(r,["zoom","pitch","distance-from-center"]);if(!s&&!kr(e))return Lr([new Pe("","zoom expressions not supported")]);const a=Ln(r,["measure-light"]);if(!a&&!Dr(e))return Lr([new Pe("","measure-light expression not supported")]);const l=e.expression&&e.expression.relaxZoomRestriction,c=Kr(r);return c||s||l?c instanceof Pe?Lr([c]):c instanceof er&&!zr(e)?Lr([new Pe("",'"interpolate" expressions cannot be used with this property')]):Ar(c?new Wr(o?"camera":"composite",t.value,c.labels,c instanceof er?c.interpolation:void 0,a):new Hr(o?"constant":"source",t.value,a)):Lr([new Pe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Xr{constructor(t,e){this._parameters=t,this._specification=e,Le(this,Br(this._parameters,this._specification))}static deserialize(t){return new Xr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Kr(t){let e=null;if(t instanceof rr)e=Kr(t.result);else if(t instanceof nr){for(const i of t.args)if(e=Kr(i),e)break}else(t instanceof Rn||t instanceof er)&&t.input instanceof fi&&"zoom"===t.input.name&&(e=t);return e instanceof Pe||t.eachChild((t=>{const i=Kr(t);i instanceof Pe?e=i:e&&i&&e!==i&&(e=new Pe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}var Jr,Qr,to=function(){if(Qr)return Jr;Qr=1,Jr=e;var t=3;function e(e,i,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var o=new Int32Array(this.arrayBuffer);e=o[0],this.d=(i=o[1])+2*(n=o[2]);for(var s=0;s=h[p+0]&&n>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},e.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(n),d=l;d=0||(r[i]=so(t[i],e)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function ao(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||ro(t)||oo(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(ao);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const i of Object.keys(t))"$name"!==i&&e.set(i,ao(t[i]));return e}if("Set"===e){const e=new Set;for(const i of Object.keys(t))"$name"!==i&&e.add(ao(t[i]));return e}const{klass:i}=io[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=ao(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const lo=t=>t>=128&&tt>=1536&&tt>=1872&&tt>=2208&&tt>=4352&&tt>=5120&&tt>=6016&&tt>=6320&&tt>=8192&&tt>=8448&&tt>=8528&&tt>=8960&&tt>=9216&&tt>=9280&&tt>=9312&&tt>=9632&&tt>=9728&&tt>=11008&&tt>=11904&&tt>=12032&&tt>=12272&&tt>=12288&&tt>=12352&&tt>=12448&&tt>=12544&&tt>=12592&&tt>=12688&&tt>=12704&&tt>=12736&&tt>=12784&&tt>=12800&&tt>=13056&&tt>=13312&&tt>=19904&&tt>=19968&&tt>=40960&&tt>=42128&&tt>=43360&&tt>=44032&&tt>=55216&&tt>=57344&&tt>=63744&&tt>=64336&&tt>=65040&&tt>=65072&&tt>=65104&&tt>=65136&&tt>=65280&&tt>=131072&&t=65097&&t=12296&&t=12308&&t=65306&&t=65371&&t=65512&&t=65112&&t=65123&&t=8960&&t=8972&&t=8996&&t=9085&&t=9150&&t=9169&&t=9186&&t=9754&&t=11026&&t=11088&&t=11192&&t=9984&&t=10102&&t=1424&&t=2304&&t=3840&&t-1&&(_s="error"),ms&&ms(t)};function vs(){xs.fire(new ge("pluginStateChange",{pluginStatus:_s,pluginURL:gs}))}const xs=new be,bs=function(){return _s},ws=function(){if(_s!==ds||!gs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_s=ps,vs(),gs&&ne({url:gs},(t=>{t?ys(t):(_s=fs,vs())}))},Ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_s===fs||null!=Ts.applyArabicShaping,isLoading:()=>_s===ps,setState(t){_s=t.pluginStatus,gs=t.pluginURL},isParsed:()=>null!=Ts.applyArabicShaping&&null!=Ts.processBidirectionalText&&null!=Ts.processStyledBidirectionalText,getPluginURL:()=>gs};class Ss{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!hs(i.charCodeAt(0),e))return!1;return!0}(t,Ts.isLoaded())}}class Ms{constructor(t,e,i,n){this.property=t,this.value=e,this.expression=function(t,e,i,n){if(Rr(t))return new Xr(t,e);if(Zr(t)||Array.isArray(t)&&t.length>0){const r=Yr(t,e,i,n);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Me.parse(t)),{kind:"constant",configDependencies:new Set,evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Es{constructor(t,e,i){this.property=t,this.value=new Ms(t,void 0,e,i)}transitioned(t,e){return new Is(this.property,this.value,e,et({},t.transition,this.transition),t.now)}untransitioned(){return new Is(this.property,this.value,null,{},0)}}class Cs{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=i,this.configDependencies=new Set}getValue(t){return ct(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property,this._scope,this._options)),this._values[t].value=new Ms(this._values[t].property,null===e?void 0:ct(e),this._scope,this._options),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]))}setTransitionOrValue(t,e){e&&(this._options=e);const i=this._properties.properties;if(t)for(const e in t){const n=t[e];if(st(e,"-transition")){const t=e.slice(0,-11);i[t]&&this.setTransition(t,n)}else i.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return ct(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Es(this._values[t].property)),this._values[t].transition=ct(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new As(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new As(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Is{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n":1,">=":1,"=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"!0,needGeometry:!1,needFeature:!1};Ns(t)||(t=Ws(t));const r=t;let o=!0;try{o=function(t){if(!Gs(t))return t;let e=Fs(t);return js(e),e=Vs(e),e}(r)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `)}const s=Os[`filter_${n}`],a=qr(o,s,e,i);let l=null;if("error"===a.result)throw new Error(a.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(t,e,i)=>a.value.evaluate(t,e,{},i);let c=null,h=null;if(o!==r){const t=qr(r,s,e,i);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));c=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),h=!Cn(t.value.expression)}return{filter:l,dynamicFilter:c||void 0,needGeometry:Hs(o),needFeature:!!h}}function Vs(t){if(!Array.isArray(t))return t;const e=function(t){if(Zs.has(t[0]))for(let e=1;eVs(t)))}function js(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","e?1:0}function Hs(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"="===e?Ys(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(Ws))):"all"===e?["all"].concat(t.slice(1).map(Ws)):"none"===e?["all"].concat(t.slice(1).map(Ws).map(Js)):"in"===e?Xs(t[1],t.slice(2)):"!in"===e?Js(Xs(t[1],t.slice(2))):"has"===e?Ks(t[1]):"!has"!==e||Js(Ks(t[1]));var i}function Ys(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Xs(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(qs)]]:["filter-in-small",t,["literal",e]]}}function Ks(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Js(t){return["!",t]}const Qs="";function ta(t,e){return e?`${t}${Qs}${e}`:t}const ea="-transition",ia=new Set(["fill","line","background","hillshade","raster"]);class na extends be{constructor(t,e,i,n,r){if(super(),this.id=t.id,this.fqid=ta(this.id,i),this.type=t.type,this.scope=i,this.lut=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Ls(e.layout,this.scope,r),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),e.paint)){this._transitionablePaint=new Cs(e.paint,this.scope,r);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $s(e.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return!this.is3D()&&ia.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const i=this._unevaluatedLayout;i._properties.properties[t]&&(i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),"visibility"===t&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(t){return st(t,ea)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const i=this._transitionablePaint,n=i._properties.properties;if(st(t,ea)){const r=t.slice(0,-11);return n[r]&&i.setTransition(r,e||void 0),!1}if(!n[t])return!1;const r=i._values[t],o=r.value.isDataDriven(),s=r.value;i.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...i.configDependencies]),this._handleSpecialPaintPropertyUpdate(t);const a=i._values[t].value,l=a.isDataDriven(),c=st(t,"pattern")||"line-dasharray"===t;return l||o||c||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,i){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){return lt({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Ps&&$r(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(t){this._filterCompiled||(this._featureFilter=Us(this.filter,this.scope,t),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(t){}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){}queryIntersectsMatchingFeature(t,e,i,n){}}const ra={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class oa{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class sa{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function aa(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=ra[t.type].BYTES_PER_ELEMENT,o=i=la(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:la(i,Math.max(n,e)),alignment:e}}function la(t,e){return Math.ceil(t/e)*e}class ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}ca.prototype.bytesPerElement=4,no(ca,"StructArrayLayout2i4");class ha extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}ha.prototype.bytesPerElement=6,no(ha,"StructArrayLayout3i6");class ua extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}ua.prototype.bytesPerElement=8,no(ua,"StructArrayLayout4i8");class da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,this.int16[s+3]=r,this.int16[s+4]=o,t}}da.prototype.bytesPerElement=10,no(da,"StructArrayLayout5i10");class pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,h=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,t}}pa.prototype.bytesPerElement=12,no(pa,"StructArrayLayout2i4ub1f12");class fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}fa.prototype.bytesPerElement=16,no(fa,"StructArrayLayout4f16");class ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}ma.prototype.bytesPerElement=12,no(ma,"StructArrayLayout3f12");class _a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}_a.prototype.bytesPerElement=12,no(_a,"StructArrayLayout4ui1f12");class ga extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}ga.prototype.bytesPerElement=8,no(ga,"StructArrayLayout4ui8");class ya extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}ya.prototype.bytesPerElement=12,no(ya,"StructArrayLayout6i12");class va extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,n,r,o,s,a,l,c,h,u)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}va.prototype.bytesPerElement=24,no(va,"StructArrayLayout4i4ui4i24");class xa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}xa.prototype.bytesPerElement=20,no(xa,"StructArrayLayout3i3f20");class ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ba.prototype.bytesPerElement=4,no(ba,"StructArrayLayout1ul4");class wa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}wa.prototype.bytesPerElement=4,no(wa,"StructArrayLayout2ui4");class Ta extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,h,u,d)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,t}}Ta.prototype.bytesPerElement=40,no(Ta,"StructArrayLayout5i4f1i1ul2ui40");class Sa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}Sa.prototype.bytesPerElement=16,no(Sa,"StructArrayLayout3i2i2i16");class Ma extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}Ma.prototype.bytesPerElement=16,no(Ma,"StructArrayLayout2f1f2i16");class Ea extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=20*t,l=5*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Ea.prototype.bytesPerElement=20,no(Ea,"StructArrayLayout2ub4f20");class Ca extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}Ca.prototype.bytesPerElement=6,no(Ca,"StructArrayLayout3ui6");class Ia extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b){const w=30*t,T=15*t,S=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[T+2]=r,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,t}}Ia.prototype.bytesPerElement=60,no(Ia,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Aa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P){const $=this.length;return this.resize($+1),this.emplace($,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E,C,I,A,L,P,$){const D=20*t,k=40*t,z=80*t;return this.float32[D+0]=e,this.float32[D+1]=i,this.int16[k+4]=n,this.int16[k+5]=r,this.int16[k+6]=o,this.int16[k+7]=s,this.int16[k+8]=a,this.int16[k+9]=l,this.int16[k+10]=c,this.int16[k+11]=h,this.int16[k+12]=u,this.uint16[k+13]=d,this.uint16[k+14]=p,this.uint16[k+15]=f,this.uint16[k+16]=m,this.uint16[k+17]=_,this.uint16[k+18]=g,this.uint16[k+19]=y,this.uint16[k+20]=v,this.uint16[k+21]=x,this.uint16[k+22]=b,this.uint16[k+23]=w,this.uint16[k+24]=T,this.uint16[k+25]=S,this.uint16[k+26]=M,this.uint16[k+27]=E,this.uint32[D+14]=C,this.float32[D+15]=I,this.float32[D+16]=A,this.float32[D+17]=L,this.float32[D+18]=P,this.uint8[z+76]=$,t}}Aa.prototype.bytesPerElement=80,no(Aa,"StructArrayLayout2f9i15ui1ul4f1ub80");class La extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}La.prototype.bytesPerElement=4,no(La,"StructArrayLayout1f4");class Pa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}Pa.prototype.bytesPerElement=20,no(Pa,"StructArrayLayout5f20");class $a extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=r,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}$a.prototype.bytesPerElement=28,no($a,"StructArrayLayout7f28");class Da extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}Da.prototype.bytesPerElement=12,no(Da,"StructArrayLayout1ul3ui12");class ka extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ka.prototype.bytesPerElement=2,no(ka,"StructArrayLayout1ui2");class za extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}za.prototype.bytesPerElement=8,no(za,"StructArrayLayout2f8");class Ra extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m)}emplace(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=i,this.float32[g+2]=n,this.float32[g+3]=r,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,t}}Ra.prototype.bytesPerElement=64,no(Ra,"StructArrayLayout16f64");class Oa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=10*t,c=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=r,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,t}}Oa.prototype.bytesPerElement=20,no(Oa,"StructArrayLayout4ui3f20");class Ba extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}Ba.prototype.bytesPerElement=2,no(Ba,"StructArrayLayout1i2");class Fa extends sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Fa.prototype.bytesPerElement=1,no(Fa,"StructArrayLayout1ub1");class Na extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Na.prototype.size=40;class Ua extends Ta{get(t){return new Na(this,t)}}no(Ua,"CollisionBoxArray");class Va extends oa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}Va.prototype.size=60;class ja extends Ia{get(t){return new Va(this,t)}}no(ja,"PlacedSymbolArray");class Ga extends oa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}Ga.prototype.size=80;class Za extends Aa{get(t){return new Ga(this,t)}}no(Za,"SymbolInstanceArray");class qa extends La{getoffsetX(t){return this.float32[1*t+0]}}no(qa,"GlyphOffsetArray");class Ha extends ca{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}no(Ha,"SymbolLineVertexArray");class Wa extends oa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Wa.prototype.size=12;class Ya extends Da{get(t){return new Wa(this,t)}}no(Ya,"FeatureIndexArray");class Xa extends wa{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}no(Xa,"FillExtrusionCentroidArray");class Ka extends oa{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Ka.prototype.size=6;class Ja extends ha{get(t){return new Ka(this,t)}}no(Ja,"FillExtrusionWallArray");const Qa=aa([{name:"a_pos",components:2,type:"Int16"}],4),tl=aa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class el{constructor(t=[]){this.segments=t}_prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>el.MAX_VERTEX_ARRAY_LENGTH&&ut(`Max vertices per segment is ${el.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>el.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(t,e,i,n){return this._prepareSegment(t,e.length,i.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new el([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function il(t,e){return 256*(t=K(Math.floor(t),0,255))+K(Math.floor(e),0,255)}el.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,no(el,"SegmentVector");const nl=aa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),rl=aa([{name:"a_dash",components:4,type:"Uint16"}]);class ol{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(sl(t)),this.positions.push(e,i,n)}eachPosition(t,e){const i=sl(t);let n=0,r=this.ids.length-1;for(;n>1;this.ids[t]>=i?r=t:n=t+1}for(;this.ids[n]===i;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return al(i,n,0,i.length-1),e&&(e.add(i.buffer),e.add(n.buffer)),{ids:i,positions:n}}static deserialize(t){const e=new ol;let i;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==i&&e.uniqueIds.push(t),i=t;return e.indexed=!0,e}}function sl(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;ll(t,o,s),ll(e,3*o,3*s),ll(e,3*o+1,3*s+1),ll(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i,this.context=n}setUniform(t,e,i,n,r){const o=n.constantOr(this.value);e.set(t,r,o instanceof Me?o.toRenderColor(this.context.lut):o)}getBinding(t,e){return"color"===this.type?new ml(t):new ul(t)}}class Tl{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new fl(t):new ul(t)}}class Sl{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Ss(0,{brightness:o}),e,{},r,n,s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,this.context)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=bl(i.toRenderColor(n.lut));for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.context=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate(new Ss(this.context.zoom,{brightness:o}),e,{},r,n,s),l=this.expression.evaluate(new Ss(this.context.zoom+1,{brightness:o}),e,{},r,n,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(c,t,a,l,this.context)}updatePaintArray(t,e,i,n,r,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,n,void 0,r),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,n,void 0,r);this._setPaintValue(t,e,a,l,this.context)}_setPaintValue(t,e,i,n,r){if("color"===this.type){const n=bl(i.toRenderColor(r.lut)),o=bl(i.toRenderColor(r.lut));for(let i=t;i!0){this.binders={},this._buffers=[],this.context=e;const n=[];for(const r in t.paint._values){const o=t.paint.get(r);if(!i(r))continue;if(!(o instanceof Ps&&$r(o.property.specification)))continue;const s=Ll(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===r||r.endsWith("pattern"),u="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const e=Dl(r,l,"source");this.binders[r]=h?new El(a,s,l,e,t.id):new Sl(a,s,l,e),n.push(`/a_${r}`)}else{const t=Dl(r,l,"composite");this.binders[r]=new Ml(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=h?new Tl(a.value,s):new wl(a.value,s,l,e),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Sl||e instanceof Ml?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof Sl||l instanceof Ml||l instanceof El)&&l.populatePaintArray(t,e,i,n,r,o,s)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Tl&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o,s,a){let l=!1;const c=Object.keys(t),h=0!==c.length,u=h?c:e.uniqueIds;this.context.lut=r.lut;for(const c in this.binders){const d=this.binders[c];if(d.context=this.context,(d instanceof Sl||d instanceof Ml||d instanceof El)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=r.paint.get(c);d.expression=p.value;for(const i of u){const r=t[i.toString()];e.eachPosition(i,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}if(!h)for(const e of i.uniqueIds){const r=t[e.toString()];i.eachPosition(e,((t,e,i)=>{const l=n.feature(t);d.updatePaintArray(e,i,l,r,o,s,a)}))}l=!0}}return l}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof wl||i instanceof Tl)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Sl||i instanceof Ml||i instanceof El)for(let e=0;e!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Cl(n,e,i);this.needsUpload=!1,this._featureMap=new ol,this._featureMapWithoutIds=new ol,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,i,n,r,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s,a);void 0!==e.id?this._featureMap.add(e.id,i,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,r,o||0)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Al={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Ll(t,e){return Al[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const Pl={"line-pattern":{source:_a,composite:_a},"fill-pattern":{source:_a,composite:_a},"fill-extrusion-pattern":{source:_a,composite:_a},"line-dasharray":{source:ga,composite:ga}},$l={color:{source:za,composite:fa},number:{source:La,composite:za}};function Dl(t,e,i){const n=Pl[t];return n&&n[i]||$l[e][i]}no(wl,"ConstantBinder"),no(Tl,"PatternConstantBinder"),no(Sl,"SourceExpressionBinder"),no(El,"PatternCompositeBinder"),no(Ml,"CompositeExpressionBinder"),no(Cl,"ProgramConfiguration",{omit:["_buffers"]}),no(Il,"ProgramConfigurationSet");const kl=Wi/Math.PI/2,zl=64,Rl=[zl,32,16],Ol=-kl,Bl=kl;function Fl(t,e,i,n=kl){return i=Z(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function Nl(t,e,i){return Fl(Math.cos(Z(t)),Math.sin(Z(t)),e,i)}const Ul=6371008.8,Vl=2*Math.PI*Ul;class jl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat, lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Gl{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]])}else{const e=t;this.setSouthWest(e[0]).setNorthEast(e[1])}}setNorthEast(t){return this._ne=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}setSouthWest(t){return this._sw=t instanceof jl?new jl(t.lng,t.lat):jl.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof jl)n=t,r=t;else{if(!(t instanceof Gl))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Gl.convert(t)):this.extend(jl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(jl.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new jl(n.lng,n.lat),this._ne=new jl(r.lng,r.lat)),this}getCenter(){return new jl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new jl(this.getWest(),this.getNorth())}getSouthEast(){return new jl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=jl.convert(t);let n=this._sw.lngthis._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat=l?(rc(t,e,i,c,h,o,u,a,l),rc(t,c,h,n,r,u,s,a,l)):t.push(s)}function oc(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&ut("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function uc(t,e,i){const n=t.loadGeometry(),r=t.extent,o=Wi/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1{const i=Yl((e.x+t.x/r)/o),n=Xl((e.y+t.y/r)/o),h=c.project(i,n);t.x=(h.x*s-a)*r,t.y=(h.y*s-l)*r};for(let e=0;e=r||i.y=r||(h(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)hc(e,o);return n}function dc(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?uc(t):[]}}function pc(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function fc(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class mc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ca,this.indexArray=new Ca,this.segments=new el,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}updateFootprints(t,e){}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};o.push(u)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new ya,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a,e.brightness),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,tl.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o,s){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i=Wi||n=Wi)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;fc(s,t,e),fc(s,t,e),fc(s,t,e),fc(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;pc(this.layoutVertexArray,i,n,-1,-1),pc(this.layoutVertexArray,i,n,1,-1),pc(this.layoutVertexArray,i,n,1,1),pc(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r,s)}}function _c(t,e){for(let i=0;i1){if(xc(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function Sc(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.xe.y!=s.y>e.y&&e.x=o.x&&r>=o.y)return!0;const o=[new U(e,i),new U(e,r),new U(n,r),new U(n,i)];if(t.length>2)for(const e of o)if(Mc(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=dt(t,e,i[0]);return o!==dt(t,e,i[1])||o!==dt(t,e,i[2])||o!==dt(t,e,i[3])}function Ic(t,e,i,n,r,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((i.x-t.x)*s+(i.y-t.y)*a-o0;o--)n=1this.canonical.z?new Uc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Uc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Vc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Vc(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Uc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Uc(e,this.wrap,e,i,n),new Uc(e,this.wrap,e,i+1,n),new Uc(e,this.wrap,e,i,n+1),new Uc(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,i=t.wrap;return e{let e=t.canonical.x+1,i=t.wrap;return e===1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1new Uc(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1=0;if(0===o)return 0;o!==e.length&&(i=!1)}return i?2:1}function Jc(t,e){for(const i of t.projections){const n=Xc(e,t.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function Qc(t,e){let i=0;const n=[0,0,0,0];for(let r=0;r=0&&i++;return i}class th{constructor(t,e){this.points=t||new Array(8).fill([0,0,0]),this.planes=e||new Array(6).fill([0,0,0,0]),this.bounds=eh.fromPoints(this.points),this.projections=[],this.frustumEdges=[O.vec3.sub([],this.points[2],this.points[3]),O.vec3.sub([],this.points[0],this.points[3]),O.vec3.sub([],this.points[4],this.points[0]),O.vec3.sub([],this.points[5],this.points[1]),O.vec3.sub([],this.points[6],this.points[2]),O.vec3.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],i=[t[2],0,-t[0]];this.projections.push({axis:e,projection:Xc(this.points,this.points[0],e)}),this.projections.push({axis:i,projection:Xc(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(t,e,i,n){const r=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const o=O.vec4.transformMat4([],i,t),s=1/o[3]/e*r;return O.vec4.mul(o,o,[s,s,n?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=O.vec3.sub([],o[t[0]],o[t[1]]),i=O.vec3.sub([],o[t[2]],o[t[1]]),n=O.vec3.normalize([],O.vec3.cross([],e,i)),r=-O.vec3.dot(n,o[t[1]]);return n.concat(r)})),a=[];for(let t=0;ts[1]||s[0]>o[1])return 0}return 1}containsPoint(t){for(const e of this.planes){const i=e[3];if(O.vec3.dot([e[0],e[1],e[2]],t)+it.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,K(i,0,1))+t.center[e]}function ah(t){if(t.z0){for(const t of a)O.vec3.min(h,h,t),O.vec3.max(c,c,t);return new eh(h,c)}const u=[o[12]*r,o[13]*r,o[14]*r],d=s.getCenter(),p=K(t.center.lat,-Jl,Jl),f=K(d.lat,-Jl,Jl),m=ql(t.center.lng),_=Hl(p);let g=m-ql(d.lng);const y=_-Hl(f);g>.5?g-=1:gMath.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const t=[o[4]*r,o[5]*r,o[6]*r],e=-Math.sin(Z(y>=0?s.getSouth():s.getNorth()))*kl;O.vec3.scaleAndAdd(u,u,t,e)}const x=a[v],b=a[(v+1)%4],w=new oh(x,b,u),T=[sh(w,0)||x[0],sh(w,1)||x[1],sh(w,2)||x[2]],S=bh(t.zoom);if(S>0){const n=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1.5?d=-1:pMath.PI/2*1.01}const Sh=Z(85),Mh=Math.cos(Sh),Eh=Math.sin(Sh),Ch=O.mat4.create(),Ih=t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function Ah(t,e,i,n,r,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of e)for(const e of u){const u=e.add(a),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const t=i.projection.upVector(c,u.x,u.y);p.x+=t[0]*h*d,p.y+=t[1]*h*d,p.z+=t[2]*h*d}const f=o?u:Lh(p.x,p.y,p.z,n),m=o?t.tilespaceRays.map((t=>Dh(t,d))):t.queryGeometry.screenGeometry,_=O.vec4.transformMat4([],[p.x,p.y,p.z,1],n);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const t=Xl((e.y/Wi+c.y)/(1t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,c=e.data,h=4===o&&a;for(let a=0;a{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);s&&(r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a))};if(t.clips)for(let e=0,r=0;e80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let o=i;oe&&(e=i),r>n&&(n=r)}c=Math.max(e-a,n-l),c=0!==c?32767/c:0}return Kh(o,s,i,a,l,c,0),s}function Yh(t,e,i,n,r){let o;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(let r=e;r=e;r-=n)o=_u(r/n|0,t[r],t[r+1],o);return o&&hu(o,o.next)&&(gu(o),o=o.next),o}function Xh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!hu(n,n.next)&&0!==cu(n.prev,n,n.next))n=n.next;else{if(gu(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Kh(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=ou(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n 0)for(let r=e;r=e;r-=n)o=_u(r/n|0,t[r],t[r+1],o);return o&&hu(o,o.next)&&(gu(o),o=o.next),o}function Xh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!hu(n,n.next)&&0!==cu(n.prev,n,n.next))n=n.next;else{if(gu(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Kh(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=ou(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n =e;r-=n)o=_u(r/n|0,t[r],t[r+1],o);return o&&hu(o,o.next)&&(gu(o),o=o.next),o}function Xh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!hu(n,n.next)&&0!==cu(n.prev,n,n.next))n=n.next;else{if(gu(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Kh(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=ou(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let n,r=t;t=null;let o=null;for(e=0;r;){e++;let s=r,a=0;for(let t=0;t0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n 0||l>0&&s;)0!==a&&(0===l||!s||r.z1)}(r)}(t,n,r,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,c=t.next;if(o?Qh(t,n,r,o):Jh(t))e.push(l.i,t.i,c.i),gu(t),t=c.next,a=c.next;else if((t=c)===a){s?1===s?Kh(t=tu(Xh(t),e),e,i,n,r,o,2):2===s&&eu(t,e,i,n,r,o):Kh(Xh(t),e,i,n,r,o,1);break}}}function Jh(t){const e=t.prev,i=t,n=t.next;if(cu(e,i,n)>=0)return!1;const r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,h=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=n.next;for(;f!==e;){if(f.x>=h&&f.x=u&&f.y=0)return!1;f=f.next}return!0}function Qh(t,e,i,n){const r=t.prev,o=t,s=t.next;if(cu(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,h=r.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=ou(p,f,e,i,n),y=ou(m,_,e,i,n);let v=t.prevZ,x=t.nextZ;for(;v&&v.z>=g&&x&&x.z=p&&v.x=f&&v.y=0)return!1;if(v=v.prevZ,x.x>=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=p&&v.x=f&&v.y=0)return!1;v=v.prevZ}for(;x&&x.z=p&&x.x=f&&x.y=0)return!1;x=x.nextZ}return!0}function tu(t,e){let i=t;do{const n=i.prev,r=i.next.next;!hu(n,r)&&uu(n,i,i.next,r)&&fu(n,r)&&fu(r,n)&&(e.push(n.i,i.i,r.i),gu(i),gu(i.next),i=t=r),i=i.next}while(i!==t);return Xh(i)}function eu(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&lu(s,t)){let a=mu(s,t);return s=Xh(s,s.next),a=Xh(a,a.next),Kh(s,e,i,n,r,o,0),void Kh(a,e,i,n,r,o,0)}t=t.next}s=s.next}while(s!==t)}function iu(t,e){return t.x-e.x}function nu(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(ts&&(s=t,o=i.x=i.x&&i.x>=l&&n!==i.x&&au(ro.x||i.x===o.x&&ru(o,i)))&&(o=i,h=e)}i=i.next}while(i!==a);return o}(t,e);if(!i)return e;const n=mu(i,t);return Xh(n,n.next),Xh(i,i.next)}function ru(t,e){return cu(t.prev,t,e.prev)=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function lu(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&uu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(fu(t,e)&&fu(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r0&&cu(e.prev,e,e.next)>0)}function cu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function hu(t,e){return t.x===e.x&&t.y===e.y}function uu(t,e,i,n){const r=pu(cu(t,e,i)),o=pu(cu(t,e,n)),s=pu(cu(i,n,t)),a=pu(cu(i,n,e));return r!==o&&s!==a||!(0!==r||!du(t,i,e))||!(0!==o||!du(t,n,e))||!(0!==s||!du(i,t,n))||!(0!==a||!du(i,e,n))}function du(t,e,i){return e.x=Math.min(t.x,i.x)&&e.y=Math.min(t.y,i.y)}function pu(t){return t>0?1:t=0&&cu(t,t.prev,e)>=0:cu(t,e,t.prev)1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ca,this.indexArray=new Ca,this.indexArray2=new wa,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.segments2=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=dc(s,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),h,i))continue;const u=r?r.evaluate(h,{},i,e.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:uc(s,i,n),patterns:{},sortKey:u};o.push(d)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=wu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages,e.brightness);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const i=Au(t.x-this.min.x,this.xScale,this.cellsX),n=Au(t.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Au(t.x-this.min.x,this.xScale,this.cellsX),r=Au(e.x-this.min.x,this.xScale,this.cellsX),o=Au(t.y-this.min.y,this.yScale,this.cellsY),s=Au(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[]}updateFootprints(t,e){for(const i of this.footprints)e.push({footprint:i,id:t})}populate(t,e,i,n){const r=[];for(const{feature:e,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,properties:e.properties,type:e.type,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(e,i,n),patterns:{}};r.push(c)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,i,n,r){}destroy(){}addFeature(t,e,i,n,r,o=[],s){for(const t of vu(e,2)){const e=[],i=[],n=[],r=new U(1/0,1/0),o=new U(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(i.length/2);for(let t=0;t>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(i&&l.push(i),i=[]),i.push(new t(s,a));else{if(7!==r)throw new Error("unknown command "+r);i&&i.push(i[0].clone())}}return i&&l.push(i),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},e.prototype.toGeoJSON=function(t,i,r){var o,s,a=this.extent*Math.pow(2,r),l=this.extent*t,c=this.extent*i,h=this.loadGeometry(),u=e.types[this.type];function d(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}return Nu=e,e.prototype.feature=function(e){if(e=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var i=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,i,this.extent,this._keys,this._values)},Nu}function Wu(){return Gu||(Gu=1,Zu.VectorTile=function(){if(ju)return Vu;ju=1;var t=Hu();function e(e,i,n){if(3===e){var r=new t(n,n.readVarint()+n.pos);r.length&&(i[r.name]=r)}}return Vu=function(t,i){this.layers=t.readFields(e,{},i)},Vu}(),Zu.VectorTileFeature=qu(),Zu.VectorTileLayer=Hu()),Zu}var Yu=Wu();class Xu extends U{constructor(t,e,i){super(t,e),this.z=i}}class Ku extends Xu{constructor(t,e,i,n){super(t,e,i),this.w=n}}function Ju(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new U(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new U(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.lengthe&&o(s,a,l,c,h,e):u>i?d=e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n =e&&o(s,a,l,c,h,e),d>i&&u=e&&l=s[i]&&(n=e,s=t),n[i]r&&Qu(n,s,i,r),n[i]o&&Qu(s,n,i,o)}}const ed=Number.MAX_SAFE_INTEGER;function id(t,e,i,n){return t.ordere===t))}(n,t.clipScope)}function nd(t,e){return t.x-e.x||t.y-e.y}function rd(t,e){return 0===nd(t.min,e.min)&&0===nd(t.max,e.max)}function od(t,e){return!(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew U((t.x+o.x*Wi)*a-s.x*Wi,(t.y+o.y*Wi)*a-s.y*Wi)))}return cd(i,r,t.indices,0,t.indices.length,0,0)}function ud(t,e,i,n){const r=Math.pow(2,n.z-i.z);return new U((t+i.x*Wi)*r-n.x*Wi,(e+i.y*Wi)*r-n.y*Wi)}function dd(t,e){const i=[];e.grid.queryPoint(t,i);const n=e.indices,r=e.vertices;for(let e=0;e0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const md=Yu.VectorTileFeature.types,_d=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],gd=["fill-extrusion-flood-light-ground-radius"],yd=Math.pow(2,13),vd=Math.pow(2,15)-1,xd=new U(0,1),bd=2147483648;function wd(t,e,i,n,r,o,s,a){t.emplaceBack((et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wi)&&e.x===i.x)!=((0===e.y||e.y===Wi)&&e.y===i.y)&&this.processBorderOverlap(e,i),n&&this.checkBorderIntersection(e,i)}checkBorderIntersection(t,e){e.xWi!=t.x>Wi&&this.addBorderIntersection(1,Ce(e.y,t.y,(Wi-e.x)/(t.x-e.x))),e.yWi!=t.y>Wi&&this.addBorderIntersection(3,Ce(e.x,t.x,(Wi-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n i[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){return 0===this.accCount?new U(0,0):new U(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Ad(t,e){const i=t.add(e)._unit(),n=K(t.x*i.x+t.y*i.y,-1,1);var r,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*vd*((r=t).x*(o=e).y-r.y*o.xt.xt.x>Wi,t=>t.yt.y>Wi];function Pd(t,e,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=t.sub(i),s=e.sub(i),a=[t,e,o,s];for(let t=0;tgd.includes(t))),this._segments=new el,this.hiddenByLandmarkVertexArray=new Fa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new el}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,i,n=!1){const r=t.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const e=t[0],i=t[1];a=Ad(e.sub(t[r-1])._perp()._unit(),i.sub(e)._perp()._unit())}for(let l=0;lt.region-e.region));for(let i=0;it+e),0);let o=0;for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,zu.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ca,this.footprintVertices=new ca,this.footprintSegments=[],this.layoutVertexArray=new ua,this.centroidVertexArray=new Xa,this.wallVertexArray=new Ja,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut},(t=>_d.includes(t))),this.segments=new el,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new $d(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(t,e){}populate(t,e,i,n){this.features=[],this.hasPattern=bu("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ic(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=dc(r,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:uc(r,i,n),properties:r.properties,type:r.type,patterns:{}},h=this.layoutVertexArray.length,u="Polygon"===md[c.type];if(this.hasPattern)this.features.push(wu("fill-extrusion",this.layers,c,this.zoom,e));else if(this.wallMode)for(const t of c.geometry)for(const r of fd(t,u))this.addFeature(c,[r],s,i,{},e.availableImages,n,e.brightness);else this.addFeature(c,c.geometry,s,i,{},e.availableImages,n,e.brightness);e.featureIndex.insert(r,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,i,n,r,o){for(const t of this.features){const s="Polygon"===md[t.type],{geometry:a}=t;if(this.wallMode)for(const l of a)for(const a of fd(l,s))this.addFeature(t,[a],t.index,e,i,n,r,o);else this.addFeature(t,a,t.index,e,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.groundEffect.update(t,e,s,i,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ou),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,ku.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Ru.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Du.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,r,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new U(0,0),new U(Wi,Wi)],h=s.projection,u="globe"===h.name,d=this.wallMode||"Polygon"===md[t.type],p=new Id;p.centroidDataIndex=this.centroidData.length;const f=new Cd,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)=0}(t);i||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=t.length;if(a=2&&t[a-1].equals(t[a-2]);)a--;let l,c,h,u,d,p=0;for(;p0;let g="miter";const y=2;"miter"===g&&m>y&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new U(t.x,t.y),l=new U(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(i,1),l.y-=e.y*Math.max(i,1),s.push(e),r.push(a),o.push(l)};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(m*m-1),e=_?t:0,i=_?0:t;c&&v(l,u,e,i),h&&v(l,d,e,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;tt=0;t--){const e=v[t];(0===e.length||(x=e[0]).every((t=>t.xt.x>=Wi))||x.every((t=>t.yt.y>=Wi)))&&v.splice(t,1)}var x;let b;if(u)b=Vd(v,c,n);else{b=[];for(const t of v)b.push({polygon:t,bounds:c})}const w=d?this.edgeRadius:0,T=w>0&&this.zoom{if(0===t.length)return!1;const i=t[t.length-1];return e.x===i.x&&e.y===i.y};for(const{polygon:t,bounds:e}of b){let i=0,r=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*r,this.layoutVertexArray,this.indexArray);f.footprintSegIdx4&&Fd(s[s.length-2],s[0],s[1]),c=w?zd(s[s.length-2],s[0],s[1],w):0;const _=[];let v,x,b;x=s[1].sub(s[0])._perp()._unit();let T=!0;for(let t=1,r=0;t0?1:0,A=l.dist(d);if(r+A>32768&&(r=0),w){b=M.sub(d)._perp()._unit();let t=Rd(l,d,M,kd(x,b),w);isNaN(t)&&(t=0);const e=d.sub(l)._unit();l=l.add(e.mult(c))._round(),d=d.add(e.mult(-t))._round(),c=t,x=b,m&&this.zoom>=17&&(S(_,l)||_.push(l),S(_,d)||_.push(d))}const L=o.vertexLength,P=s.length>4&&Fd(l,d,M);let $=Nd(r,a,T);if(wd(this.layoutVertexArray,l.x,l.y,C,I,0,0,$),wd(this.layoutVertexArray,l.x,l.y,C,I,0,1,$),this.wallMode){const e=y(t-1,s),i=g.joinNormals[t-1];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(r+=A,$=Nd(r,P,!T),a=P,wd(this.layoutVertexArray,d.x,d.y,C,I,0,0,$),wd(this.layoutVertexArray,d.x,d.y,C,I,0,1,$),this.wallMode){const e=y(t,s),i=g.joinNormals[t];Td(this.wallVertexArray,i,e),Td(this.wallVertexArray,i,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(L+0,L+1,L+2),this.indexArray.emplaceBack(L+1,L+3,L+2),o.primitiveLength+=2,w){const n=i+(1===t?s.length-2:t-2),r=1===t?i:n+1;if(this.indexArray.emplaceBack(L+1,n,L+3),this.indexArray.emplaceBack(n,r,L+3),o.primitiveLength+=2,void 0===v&&(v=L),!Od(M,s[t],e)){const e=t===s.length-1?v:o.vertexLength;this.indexArray.emplaceBack(L+2,L+3,e),this.indexArray.emplaceBack(L+3,e+1,e),this.indexArray.emplaceBack(L+3,r,e+1),o.primitiveLength+=3}T=!T}if(u){const t=this.layoutVertexExtArray,e=h.projectTilePoint(l.x,l.y,n),i=h.projectTilePoint(d.x,d.y,n),r=h.upVector(n,l.x,l.y),o=h.upVector(n,d.x,d.y);Md(t,e,r),Md(t,e,r),Md(t,i,o),Md(t,i,o)}}d&&(i+=s.length-1),m&&w&&this.zoom>=17&&(0!==_.length&&S(_,_[0])&&_.pop(),this.groundEffect.addData(_,e,l,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?xd:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;eWi),r=2*n+(+(i.min.x+i.max.x>Wi)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let i=0,n=0,r=0;for(const e of t){if(e.triangleSegmentIdx!==i)break;r++}const o=t.length;for(;n!==t.length;){i=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let e=a;e[t[0]*(1-i[0])+e[0]*i[0],t[1]*(1-i[1])+e[1]*i[1]],d=[],p=[];for(const t of this.triangleSubSegments){d[0]=t.min.x/Wi,d[1]=t.min.y/Wi,p[0]=t.max.x/Wi,p[1]=t.max.y/Wi;const e=u(c,h,d),s=u(c,h,p);if(0===new eh([e[0],e[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const i=t.centroid(),n=e.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new U(K(i.x,1,8191)i.max.x||i.min.x>e.max.x||e.min.y>i.max.y||i.min.y>e.max.y))for(let o=0;oe!=l>e&&to.max.x||o.min.x>t||e>o.max.y||o.min.y>e||this.footprintContainsPoint(t,e,o)&&o&&o.height>i&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&bd));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function kd(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function zd(t,e,i,n){const r=e.sub(t)._perp()._unit(),o=i.sub(e)._perp()._unit();return Rd(t,e,i,kd(r,o),n)}function Rd(t,e,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,r*o/n)}function Od(t,e,i){return t.xi[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n i[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n i[1].y&&e.y>i[1].y}function Bd(t,e){return t.xe[1].x||t.ye[1].y}function Fd(t,e,i){if(t.x=Wi||e.x=Wi||i.x=Wi)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),h=l-c,u=[];for(let t=0;t0?0:1);for(let t=0;te+1?p.push({polygons:d,bounds:t,depth:e+1}):a(d,t)}if(f.length){const t=[new U(0===i?h:n.x,1===i?h:n.y),s];u.length>e+1?p.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Xl((i.y+e/Wi)/n);return(Hl(.5*(Xl((i.y+r/Wi)/n)+t))*n-i.y)*Wi}}))}function jd(t,e,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n 1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=e/i*(n+1);if(s.isDash){const t=n-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=n-Math.sqrt(h*h+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return ut("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new pa,this.layoutVertexArray2=new fa,this.patternVertexArray=new ma,this.indexArray=new Ca,this.programConfigurations=new Il(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new el,this.maxLineLength=0,this.zOffsetVertexArray=new La,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:128}updateFootprints(t,e){}populate(t,e,i,n){this.hasPattern=bu("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=dc(e,t);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h=r?r.evaluate(c,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:uc(e,i,n),patterns:{},sortKey:h};s.push(u)}r&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:l}=e,c=this.addConstantDashes(a);for(const n of s){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,a),this.hasPattern){const t=wu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,a.positions,e.availableImages,e.brightness);l.insert(t[o].feature,r,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n,r){const o=0!==Object.keys(t).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,o?this.stateDependentLayers:this.layers,i,n,r)}addFeatures(t,e,i,n,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Qd)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,ep)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Xd.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Kd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),c=a.get("line-cap").evaluate(t,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,n,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n,s)}addLine(t,e,i,n,r,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===n;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[u-1].equals(t[u-2]);)u--;let d=0;for(;d0;if(I&&i>d){const t=m.dist(_);if(t>2*p){const e=m.sub(m.sub(_)._mult(p/t)._round());this.updateDistance(_,e),this.addCurrentVertex(e,y,0,0,f,x),_=e}}if(b&&"round"===w&&(Eo&&(w="bevel"),"bevel"===w&&(E>2&&(w="flipbevel"),E100)S=v.mult(-1);else{const t=E*y.add(v).mag()/y.sub(v).mag();S._perp()._mult(t*(A?-1:1))}this.addCurrentVertex(m,S,0,0,f,x),this.addCurrentVertex(m,S.mult(-1),0,0,f,x)}else if("bevel"===w||"fakeround"===w){const t=-Math.sqrt(E*E-1),e=A?t:0,i=A?0:t;if(_&&this.addCurrentVertex(m,y,e,i,f,x),"fakeround"===w){const t=Math.round(180*C/Math.PI/20);for(let e=1;e2*p){const e=m.add(g.sub(m)._mult(p/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,v,0,0,f,x),m=e}}}}addVerticesTo(t,e,i,n,r,o,s,a,l,c){const h=(e.w-t.w)/this.tessellationStep|0;if(h>1){this.lineSoFar=t.w;const u=(e.x-t.x)/h,d=(e.y-t.y)/h,p=(e.z-t.z)/h,f=(e.w-t.w)/h;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}function ap(t,e,i){return t.xi||t.yi}let lp,cp;function hp(t,e,i){return e*(Wi/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function up(t,e){return 1/hp(t,1,e.tileZoom)}function dp(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}no(sp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const pp=t=>{const e=[];fp(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),r=!!t.paint.get("line-pattern").constantOr(1);return n&&r&&e.push("LINE_JOIN_NONE"),e};function fp(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let mp;const _p=()=>mp||(mp={layout:lp||(lp=new Rs({"line-cap":new ks(Os.layout_line["line-cap"]),"line-join":new ks(Os.layout_line["line-join"]),"line-miter-limit":new Ds(Os.layout_line["line-miter-limit"]),"line-round-limit":new Ds(Os.layout_line["line-round-limit"]),"line-sort-key":new ks(Os.layout_line["line-sort-key"]),"line-z-offset":new ks(Os.layout_line["line-z-offset"]),visibility:new Ds(Os.layout_line.visibility)})),paint:cp||(cp=new Rs({"line-opacity":new ks(Os.paint_line["line-opacity"]),"line-color":new ks(Os.paint_line["line-color"]),"line-translate":new Ds(Os.paint_line["line-translate"]),"line-translate-anchor":new Ds(Os.paint_line["line-translate-anchor"]),"line-width":new ks(Os.paint_line["line-width"]),"line-gap-width":new ks(Os.paint_line["line-gap-width"]),"line-offset":new ks(Os.paint_line["line-offset"]),"line-blur":new ks(Os.paint_line["line-blur"]),"line-dasharray":new ks(Os.paint_line["line-dasharray"]),"line-pattern":new ks(Os.paint_line["line-pattern"]),"line-gradient":new zs(Os.paint_line["line-gradient"]),"line-trim-offset":new Ds(Os.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ds(Os.paint_line["line-trim-fade-range"]),"line-trim-color":new Ds(Os.paint_line["line-trim-color"]),"line-emissive-strength":new Ds(Os.paint_line["line-emissive-strength"]),"line-border-width":new ks(Os.paint_line["line-border-width"]),"line-border-color":new ks(Os.paint_line["line-border-color"]),"line-occlusion-opacity":new Ds(Os.paint_line["line-occlusion-opacity"])}))},mp);class gp extends ks{possiblyEvaluate(t,e){return e=new Ss(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=et({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let yp;function vp(t,e){return e>0?e+2*t:t}const xp=aa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),bp=aa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),wp=aa([{name:"a_projected_pos",components:4,type:"Float32"}],4);aa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Tp=aa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Sp=aa([{name:"a_texb",components:2,type:"Uint16"}]),Mp=aa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Ep=aa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=aa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ip=aa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);aa([{name:"triangle",components:3,type:"Uint16"}]),aa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),aa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),aa([{type:"Float32",name:"offsetX"}]),aa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ap=24;const Lp=128;function Pp(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ss(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ts.applyArabicShaping&&(t=Ts.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Rp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Op(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Bp(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Fp,Np,Up,Vp={};function jp(){if(Up)return Np;Up=1,Np=e;var t=(Fp||(Fp=1,Vp.read=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1>1,h=-7,u=i?r-1:0,d=i?-1:1,p=t[e+u];for(u+=d,o=p&(1>=-h,h+=a;h>0;o=256*o+t[e+u],u+=d,h-=8);for(s=o&(1>=-h,h+=n;h>0;s=256*s+t[e+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},Vp.write=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,h=(1>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=e=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(e*l-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[i+p]=255&a,p+=f,a/=256,r-=8);for(s=s0;t[i+p]=255&s,p+=f,s/=256,c-=8);t[i+p-f]|=128*m}),Vp);function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,n=1/i,r="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function a(t,e,i){var n=e=t;r--)i.buf[r+n]=i.buf[r]}function l(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function v(t,e){return(t[e]|t[e+1]>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*i;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*i;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i>4,r=12&&r?function(t,e,i){return r.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n 239?4:l>223?3:l>191?2:1;if(r+h>i)break;1===h?l=55296&&c=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,i){if(this.type!==e.Bytes)return t.push(this.readVarint(i));var n=o(this);for(t=t||[];this.pos127;);else if(i===e.Bytes)this.pos=this.readVarint()+this.pos;else if(i===e.Fixed32)this.pos+=4;else{if(i!==e.Fixed64)throw new Error("Unimplemented type: "+i);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t268435455||t=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t>>=7)|(t>127?128:0),t>>=7)|(t>127?128:0),t>>7&127))))},writeSVarint:function(t){this.writeVarint(t55295&&n56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n>6|192:(n>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&a(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&a(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,i,n){this.writeTag(t,e.Bytes),this.writeRawMessage(i,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,u,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,_,e)},writeBytesField:function(t,i){this.writeTag(t,e.Bytes),this.writeBytes(i)},writeFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeFixed32(i)},writeSFixed32Field:function(t,i){this.writeTag(t,e.Fixed32),this.writeSFixed32(i)},writeFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeFixed64(i)},writeSFixed64Field:function(t,i){this.writeTag(t,e.Fixed64),this.writeSFixed64(i)},writeVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeVarint(i)},writeSVarintField:function(t,i){this.writeTag(t,e.Varint),this.writeSVarint(i)},writeStringField:function(t,i){this.writeTag(t,e.Bytes),this.writeString(i)},writeFloatField:function(t,i){this.writeTag(t,e.Fixed32),this.writeFloat(i)},writeDoubleField:function(t,i){this.writeTag(t,e.Fixed64),this.writeDouble(i)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}},Np}var Gp=e(jp());function Zp(t,e,i){e.glyphs=[],1===t&&i.readMessage(qp,e)}function qp(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Hp,{});e.glyphs.push({id:t,bitmap:new Vh({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function Hp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Wp={horizontal:1,vertical:2,horizontalOnly:3};class Yp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Yp;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Yp;return e.imageName=t,e}}class Xp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Xp;for(let n=0;n=0&&i>=t&&Jp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Xp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Yp.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kp(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f){const m=Xp.fromFeature(t,r);u===Wp.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(S=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(v=o.metrics,E=8203!==m?Ap:0,_){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*g;w-i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n -i/2;){if(s--,sn;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function df(t){let e=0;for(let i=0;ic){const h=(c-l)/o,u=Ce(n.x,r.x,h),d=Ce(n.y,r.y,h),p=new hf(u,d,0,r.angleTo(n),i);return!s||uf(t,p,a,s,e)?p:void 0}l+=o}}function _f(t,e,i,n,r,o,s,a,l){const c=pf(n,o,s),h=ff(n,r),u=h*s,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&g=0&&y=0&&d+c=n&&c.x>=n||(s.x>=n?s=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new U(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new U(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function vf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();t1?s-1:s,jh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),jh.copy(n.data,l,{x:0,y:u-s},{x:a,y:c-s},{width:h,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a,y:c+u},{width:h,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c},{width:s,height:u},i),jh.copy(n.data,l,{x:h-s,y:u-s},{x:a-s,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:u-s},{x:a+h,y:c-s},{width:s,height:s},i),jh.copy(n.data,l,{x:0,y:0},{x:a+h,y:c+u},{width:s,height:s},i),jh.copy(n.data,l,{x:h-s,y:0},{x:a-s,y:c+u},{width:s,height:s},i)}this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(t,e,i,n){for(const r in t){const o=t[r],s={x:0,y:0,w:o.data.width+2*i,h:o.data.height+2*i};n.push(s),e[r]=new xf(s,o,i),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,i))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n in t.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,i),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,{position:{x:n,y:r}})}}no(xf,"ImagePosition"),no(bf,"ImageAtlas");const wf=1e20;function Tf(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=wf}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(n,t,e),o)return n.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const s=Math.floor(e/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[s])return void i(null,{stack:t,id:e,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],Ef.loadGlyphRange(t,s,r,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0}for(const i of a)i(t,e);delete n.requests[s]}))),a.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:n,glyph:r}of e)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Mf.none&&(this.localGlyphMode===Mf.all?!!this.localFontFamily:!!this.localFontFamily&&(jo(t)||Ho(t)||Po(t)||$o(t)||Lo(t)||Uo(t)||ns(t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new Ef.TinySDF({fontFamily:n,fontWeight:i,fontSize:48,buffer:6,radius:16}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new Vh({width:a,height:l},s),metrics:{width:c/2,height:h/2,left:u/2,top:d/2-27,advance:p/2,localGlyph:!0}}}}Ef.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),Qt.Glyphs);ne(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new Gp(t).readFields(Zp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},Ef.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(wf,0,u),_.fill(0,0,u);for(let t=0;t0?t*t:0,_[n]=tt+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,v=f,x=0,b=m,w=0,T=_,S=0,M=g;if(o.content&&n){const t=o.content;y=If(u,0,t[0]),x=If(d,0,t[1]),v=If(u,t[0],t[2]),b=If(d,t[1],t[3]),w=t[0]-y,S=t[1]-x,T=t[2]-t[0]-v,M=t[3]-t[1]-b}const E=(n,r,a,l)=>{const u=Lf(n.stretch-y,v,c,t.left),d=Pf(n.fixed-w,T,n.stretch,f),p=Lf(r.stretch-x,b,h,t.top),_=Pf(r.fixed-S,M,r.stretch,m),g=Lf(a.stretch-y,v,c,t.left),E=Pf(a.fixed-w,T,a.stretch,f),C=Lf(l.stretch-x,b,h,t.top),I=Pf(l.fixed-S,M,l.stretch,m),A=new U(u,p),L=new U(g,p),P=new U(g,C),$=new U(u,C),D=new U(d/s,_/s),k=new U(E/s,I/s),z=e*Math.PI/180;if(z){const t=Math.sin(z),e=Math.cos(z),i=[e,-t,t,e];A._matMult(i),L._matMult(i),$._matMult(i),P._matMult(i)}const R=n.stretch+n.fixed,O=a.stretch+a.fixed,B=r.stretch+r.fixed,F=l.stretch+l.fixed,N=t.imageSecondary;return{tl:A,tr:L,bl:$,br:P,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+B,w:O-R,h:F-B},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+B,w:O-R,h:F-B}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:k,minFontScaleX:T/s/c,minFontScaleY:M/s/h,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=Af(u,_,f),e=Af(d,g,m);for(let i=0;io)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const h=new Hi([],kf);if(0===l)return new U(n,r);for(let e=n;eu.d||!u.d)&&(u=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-u.dt.y!=a.y>t.y&&t.x18&&L>2&&(L>>=1),Math.max(Wi/(512*L),1)*_.get("symbol-spacing")),T=_.get("text-padding")*t.tilePixelRatio,S=_.get("icon-padding")*t.tilePixelRatio,M=Z(_.get("text-max-angle")),E="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),I=_.get("symbol-placement"),A=w/2;var L;const P=_.get("icon-text-fit").evaluate(e,{},u),$=_.get("icon-text-fit-padding").evaluate(e,{},u),D="none"!==P;let k;!1===t.hasAnyIconTextFit&&D&&(t.hasAnyIconTextFit=!0),n&&D&&(t.allowVerticalPlacement&&i.vertical&&(k=cf(n,i.vertical,P,$,g,x)),y&&(n=cf(n,y,P,$,g,x)));const z=(s,a,m)=>{if(a.x=Wi||a.y=Wi)return;let _=null;if(v){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new hf(t,e,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g,y,v,x,b,w,T,S,M,E){const C=t.addToLineVertexArray(e,n);let I,A,L,P,$,D,k,z=0,R=0,O=0,B=0,F=-1,N=-1;const U={};let V=_e("");const j=i?i.anchor:e,G="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let Z=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,q]=l.layout.get("text-offset").evaluate(x,{},S).map((t=>t*Ap)):(Z=l.layout.get("text-radial-offset").evaluate(x,{},S)*Ap,q=Rf),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)D=qf(t),a&&(k=qf(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},S)+90;L=Zf(c,j,e,h,u,d,t,p,i,m),a&&(P=Zf(c,j,e,h,u,d,a,g,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},S),r=Cf(o,n,w,G),s=a?Cf(a,n,w,G):void 0;A=Zf(c,j,e,h,u,d,o,g,n),z=4*r.length;const p=t.iconSizeData;let f=null;"source"===p.kind?(f=[Lp*l.layout.get("icon-size").evaluate(x,{},S)],f[0]>Vf&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Lp*b.compositeIconSizes[0].evaluate(x,{},S),Lp*b.compositeIconSizes[1].evaluate(x,{},S)],(f[0]>Vf||f[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "icon-size" is >= ${Uf}. Reduce your "icon-size".`)),t.addSymbols(t.icon,r,f,v,y,x,!1,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),F=t.icon.placedSymbolArray.length-1,s&&(R=4*s.length,t.addSymbols(t.icon,s,f,v,y,x,Wp.vertical,i,e,C.lineStartIndex,C.lineLength,-1,T,S,M,E),N=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];I||(V=_e(o.text),f?$=qf(o):I=Zf(c,j,e,h,u,d,o,p,l.layout.get("text-rotate").evaluate(x,{},S),m));const a=1===o.positionedLines.length;if(O+=jf(t,i,e,o,s,l,f,x,m,C,r.vertical?Wp.horizontal:Wp.horizontalOnly,a?Object.keys(r.horizontal):[n],U,F,b,T,S,M),a)break}r.vertical&&(B+=jf(t,i,e,r.vertical,s,l,f,x,m,C,Wp.vertical,["vertical"],U,N,b,T,S,M));let H=-1;const W=(t,e)=>t?Math.max(t,e):e;H=W($,H),H=W(D,H),H=W(k,H);const Y=H>-1?1:0;t.glyphOffsetArray.length>=65535&&ut("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.x,j.y,j.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,F,N,V,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,P||t.collisionBoxArray.length,P?P+1:t.collisionBoxArray.length,h,O,B,z,R,Y,0,Z,q,H,0,G?1:0)}(t,a,_,s,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,E,l,0,S,C,g,e,o,c,h,u,p,f)};if("line"===I)for(const r of yf(e.geometry,0,0,Wi,Wi)){const e=_f(r,w,M,i.vertical||y,n,24,b,t.overscaling,Wi);for(const i of e)y&&Hf(t,y.text,A,i)||z(r,i,u)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=mf(t,M,i.vertical||y,n,24,b);e&&z(t,e,u)}}else if("Polygon"===e.type)for(const t of vu(e.geometry,0)){const e=Df(t,16);z(t[0],new hf(e.x,e.y,0,0,void 0),u)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new hf(t[0].x,t[0].y,0,0,void 0),u);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new hf(e.x,e.y,0,0,void 0),u)}const Uf=255,Vf=Uf*Lp;function jf(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:nVf&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Lp*f.compositeTextSizes[0].evaluate(a,{},_),Lp*f.compositeTextSizes[1].evaluate(a,{},_)],(x[0]>Vf||x[1]>Vf)&&ut(`${t.layerIds[0]}: Value for "text-size" is >= ${Uf}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,h,e,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Gf(t){for(const e in t)return t[e];return null}function Zf(t,e,i,n,r,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const t=new U(d,h),e=new U(p,h),i=new U(d,u),n=new U(p,u),r=Z(l);let o=new U(0,0);c&&(o=new U(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),d=Math.min(t.x,e.x,i.x,n.x),p=Math.max(t.x,e.x,i.x,n.x),h=Math.min(t.y,e.y,i.y,n.y),u=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,d,h,p,u,a,n,r,o),t.length-1}function qf(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 Hf(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n v&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(u,d,n,o,r,o),x(d,p,r,o,r,s),x(p,f,r,s,n,s),x(f,u,n,s,n,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}function Xf(t,{x:e,y:i},n=0){return new U(((e-n)*t.scale-t.x)*Wi,(i*t.scale-t.y)*Wi)}const Kf=O.mat4.identity(new Float32Array(16));class Jf{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 jl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return Wl(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new U(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new U(e,i);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&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n 0?eam-i&&(e=am-i);const o=r/Math.pow(lm(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i1e-6&&--n>0);o=i*i;const s=K(q(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=q(i);return new jl(s,a)}}const pm=Z(Jl);class fm extends Jf{project(t,e){e=Z(e),t=Z(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,h=r*r,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(r*u)*Math.sqrt(1/m):0,y=.5*(2*g*r*d+2*i/Math.PI)-t,v=.5*(g*o+n)-e,x=.5*_*(h*f+g*r*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*r)+.5,S=b*w-T*x;s=(v*b-y*T)/S,a=(y*w-v*x)/S,i=K(i-s,-Math.PI,Math.PI),n=K(n-a,-pm,pm)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new jl(q(i),q(n))}}class mm extends Jf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Z(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:i,cosPhi:n}=this;return{x:Z(t)*n*i+.5,y:-Math.sin(Z(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=K(q((t-.5)/i)/n,-180,180),s=Math.asin(K(r*n,-1,1)),a=K(q(s),-Jl,Jl);return new jl(o,a)}}class _m extends hm{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=ph(t,e,i),r=_h(ah(i));return O.vec3.transformMat4(n,n,r),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Nl(e.lat,e.lng),n=O.vec3.normalize([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,o=Wl(1,0)*Wi*r;O.vec3.scaleAndAdd(i,i,n,o);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(i,i,s),new U(i[0],i[1])}pixelsPerMeter(t,e){return Wl(1,0)*e}pixelSpaceConversion(t,e,i){const n=Wl(1,t)*e,r=Ce(Wl(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=gh(ah(i.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=_h(ah(e));return O.mat4.rotateY(n,n,Z(i.lng)),O.mat4.rotateX(n,n,Z(i.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return rh(t,e,i,!0)||new nc(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!rh(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,h=Math.tan(t.fovAboveCenter),u=O.vec3.scale([],r.up(),h),d=O.vec3.scale([],r.right(),h*c),p=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],o,u),d)),f=[];let m;if(new Wc(s,p).closestPointOnSphere(l,a,f)){const e=O.vec3.add([],f,l),i=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(i)}else{const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const i=O.vec3.length(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(O.vec3.dot(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=bh(t.zoom);if(i>0){const n=Wf(t,Wl(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Ce(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return ph(e,i,t,1)}upVectorScale(t){return{metersToTile:ih(fh(ah(t)))}}}function gm(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Sp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,bp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Tp.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||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())}}no(Mm,"SymbolBuffers");class Em{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new el,this.collisionVertexArray=new Ea,this.collisionVertexArrayExt=new fa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Mp.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Ep.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}no(Em,"CollisionBuffers");class Cm{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Pp(this.zoom,e["text-size"]),this.iconSizeData=Pp(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Wp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Mm(new Il(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new qa,this.lineVertexArray=new Ha,this.symbolInstances=new Za}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Ss(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,y=dc(e,t);if(!r._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=uc(e,i,n)),s&&1!==e.type&&i.z{const r=ph(t.x,t.y,i,1),o=ph(n.x,n.y,i,1);return O.vec3.dot(r,o)=0;for(const i of v.sections)if(i.image)p[i.image.namePrimary]=!0;else{const n=rs(v.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n,r){const o=0!==Object.keys(t).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,i,n,r),this.icon.programConfigurations.updatePaintArrays(t,e,s,i,n,r)}updateZOffset(){const t=(t,e,n)=>{i+=e,i>t.length&&t.resize(i);for(let r=-e;r{n+=e,n>t.length&&t.resize(n);for(let r=-e;r0;if((r>0||o>0)&&(t(this.text.zOffsetVertexArray,r,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:i}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),i>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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=gm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,h,u,d,p,f,m){const _=t.indexArray,g=t.layoutVertexArray,y=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&s===Wp.vertical?Math.PI/2:0,T=o.text&&o.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),o=$p(this.textSizeData,t,r)/Ap;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=$p(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i,n){t.emplaceBack(e,-i,-i,n),t.emplaceBack(e,i,-i,n),t.emplaceBack(e,i,i,n),t.emplaceBack(e,-i,i,n)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}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 i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}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 i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Im,Am,Lm;no(Cm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Cm.addDynamicAttributes=Tm;class Pm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:De,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}}no(Pm,"FormatSectionOverride",{omit:["defaultValue"]});const $m=()=>Lm||(Lm={layout:Im||(Im=new Rs({"symbol-placement":new Ds(Os.layout_symbol["symbol-placement"]),"symbol-spacing":new Ds(Os.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ds(Os.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(Os.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ds(Os.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ds(Os.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ds(Os.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ds(Os.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ds(Os.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ds(Os.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(Os.layout_symbol["icon-size"]),"icon-text-fit":new ks(Os.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(Os.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(Os.layout_symbol["icon-image"]),"icon-rotate":new ks(Os.layout_symbol["icon-rotate"]),"icon-padding":new Ds(Os.layout_symbol["icon-padding"]),"icon-keep-upright":new Ds(Os.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(Os.layout_symbol["icon-offset"]),"icon-anchor":new ks(Os.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ds(Os.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ds(Os.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ds(Os.layout_symbol["text-rotation-alignment"]),"text-field":new ks(Os.layout_symbol["text-field"]),"text-font":new ks(Os.layout_symbol["text-font"]),"text-size":new ks(Os.layout_symbol["text-size"]),"text-max-width":new ks(Os.layout_symbol["text-max-width"]),"text-line-height":new ks(Os.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(Os.layout_symbol["text-letter-spacing"]),"text-justify":new ks(Os.layout_symbol["text-justify"]),"text-radial-offset":new ks(Os.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ds(Os.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(Os.layout_symbol["text-anchor"]),"text-max-angle":new Ds(Os.layout_symbol["text-max-angle"]),"text-writing-mode":new Ds(Os.layout_symbol["text-writing-mode"]),"text-rotate":new ks(Os.layout_symbol["text-rotate"]),"text-padding":new Ds(Os.layout_symbol["text-padding"]),"text-keep-upright":new Ds(Os.layout_symbol["text-keep-upright"]),"text-transform":new ks(Os.layout_symbol["text-transform"]),"text-offset":new ks(Os.layout_symbol["text-offset"]),"text-allow-overlap":new Ds(Os.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ds(Os.layout_symbol["text-ignore-placement"]),"text-optional":new Ds(Os.layout_symbol["text-optional"]),visibility:new Ds(Os.layout_symbol.visibility)})),paint:Am||(Am=new Rs({"icon-opacity":new ks(Os.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(Os.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(Os.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(Os.paint_symbol["text-emissive-strength"]),"icon-color":new ks(Os.paint_symbol["icon-color"]),"icon-halo-color":new ks(Os.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(Os.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(Os.paint_symbol["icon-halo-blur"]),"icon-translate":new Ds(Os.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ds(Os.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ks(Os.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(Os.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(Os.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(Os.paint_symbol["text-color"],{runtimeType:Oe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ks(Os.paint_symbol["text-halo-color"]),"text-halo-width":new ks(Os.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(Os.paint_symbol["text-halo-blur"]),"text-translate":new Ds(Os.paint_symbol["text-translate"]),"text-translate-anchor":new Ds(Os.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ds(Os.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ds(Os.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ds(Os.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ds(Os.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(Os.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Ds(Os.paint_symbol["symbol-elevation-reference"])}))},Lm);class Dm extends na{constructor(t,e,i,n){super(t,$m(),e,i,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}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 i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Cm(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of $m().paint.overridableProperties){if(!Dm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Pm(e),n=new Gr(i,e.property.specification,this.scope,this.options);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Hr("source",n):new Wr("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Ps(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Dm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=$m().paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ke)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof ni&&ei(e.value)===Ue?o(e.value.sections):e instanceof ai?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,i){return{config:new Cl(this,{zoom:e,lut:i}),overrideFog:!1}}}let km,zm,Rm,Om;var Bm=aa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Fm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Nm(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Um{constructor(t,e,i,n){this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const i=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+i,this.size?this.size[0]:0),c=Math.max(a+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const h=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,c),this.size=[l,c]}if(this.size)if(h)o.texSubImage2D(o.TEXTURE_2D,0,s,a,Fm(this.format),Nm(this.format),t);else{const e=t.data;e&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Fm(this.format),Nm(this.format),e)}this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,i=!1){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),t!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap&&!i?t===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,i,n){const{context:r}=this,{gl:o}=r;o.bindTexture(o.TEXTURE_2D,this.texture),e!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?t===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Vm{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:i}=this,{gl:n}=i;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 jm(t,e,i,n,r,o,s,a){const l=[t,e,1,i,n,1,r,o,1],c=[s,a,1],h=O.mat3.adjoint([],l),[u,d,p]=O.vec3.transformMat3(c,c,h);return O.mat3.multiply(l,l,[u,0,0,0,d,0,0,0,p])}function Gm(t,e,i,n,r,o,s,a){const l=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],l);return O.mat3.multiply(c,c,h)}(t,e,i,n,r,o,s,a);return[l[2]/l[8]/Wi,l[5]/l[8]/Wi]}function Zm(t){return[t[0],Math.min(Math.max(t[1],-Jl),Jl)]}class qm extends be{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,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 ge("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=le(this.map._requestManager.transformRequest(this.url,Qt.Image),((e,i)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ye(e)):i&&(this.image=i instanceof HTMLImageElement?kt.getImageData(i):i,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 Vm(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 ge("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Vm||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],i=t[0][1];for(const n of t)n[1]>i&&(i=n[1]),n[1]Jl?this.onNorthPole=!0:n1&&(l-=1),new Fc(s,l,Math.floor((i+r)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ge("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){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 e=Yf(new Fc(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,i=t[1].y-t[0].y,n=t[2].x-t[1].x,r=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,c=e*r-n*i,h=n*s-o*r,u=o*l-a*s,d=a*i-e*l;return c>0&&h>0&&u>0&&d>0||c{const e=n.projection.project(t[0],t[1]);return Xf(n,e)._round()}));this.perspectiveTransform=Gm(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y);const l=this._boundsArray=new ua;l.emplaceBack(r.x,r.y,0,0),l.emplaceBack(o.x,o.y,Wi,0),l.emplaceBack(a.x,a.y,0,Wi),l.emplaceBack(s.x,s.y,Wi,Wi),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,Bm.members),this.boundsSegments=el.simpleSegment(0,0,4,2);const c=[],h=[Zm((u=this.coordinates)[0]),Zm(u[1]),Zm(u[2]),Zm(u[3])];var u;const[d,p,f,m]=function(t){let e=t[0][0],i=e,n=t[0][1],r=n;for(let o=1;oi&&(i=t[o][0]),t[o][1]r&&(r=t[o][1]);return[e,n,i-e,r-n]}(h);{const n=new ua,[r,o,s,a]=function(t){let e=t[0].x,i=e,n=t[0].y,r=n;for(let o=1;oi&&(i=t[o].x),t[o].yr&&(r=t[o].y);return[e,n,i-e,r-n]}(i),l=t=>[(t.x-r)/s,(t.y-o)/a],[h,u,_,g]=i.map(l),y=function(t,e,i,n,r,o,s,a){const l=jm(0,0,1,0,1,1,0,1),c=jm(t,e,i,n,r,o,s,a),h=O.mat3.adjoint([],c);return O.mat3.multiply(l,l,h)}(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=Gm(h[0],h[1],u[0],u[1],_[0],_[1],g[0],g[1]);const v=(t,e)=>{c.push(t.lng);const i=Math.round((t.lng-d)/f*Wi),r=Math.round((t.lat-p)/m*Wi),o=l(e),s=O.vec3.transformMat3([],[o[0],o[1],1],y),a=Math.round(s[0]/s[2]*Wi),h=Math.round(s[1]/s[2]*Wi);n.emplaceBack(i,r,a,h)},x=i[3].x-i[0].x,b=i[3].y-i[0].y,w=i[2].x-i[1].x,T=i[2].y-i[1].y;for(let t=0;t{i.emplaceBack(t,n,r);const o=c[t],s=c[n],a=c[r],l=Math.min(Math.min(o,s),a),h=Math.max(Math.max(o,s),a)-l;h>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=h),e.push(l+h/2)};for(let t=0;te));i.sort(((e,i)=>t[e]-t[i]));const n=[],r=new Ca;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)0){const i=function(t,e){const i=e.worldSize,n=Wl(1,0)*i*tc(e.center.lat,e.zoom)/yh(i),r=Wl(1,e.center.lat)*i,o=O.mat4.identity([]);return O.mat4.rotateY(o,o,Z(e.center.lng)),O.mat4.rotateX(o,o,Z(e.center.lat)),O.mat4.translate(o,o,[0,0,kl]),O.mat4.scale(o,o,[n,n,n*r]),O.mat4.translate(o,o,[e.point.x-.5*i,e.point.y-.5*i,0]),O.mat4.multiply(o,o,t),O.mat4.multiply(o,e.globeMatrix,o)}(t,e);return function(t,e,i){const n=(t,e,i)=>{const n=O.vec3.length(t),r=O.vec3.length(e),o=lh(t,e,i);return O.vec3.scale(o,o,1/O.vec3.length(o)*Ce(n,r,i))},r=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],i),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],i),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],i),a=lh([t[12],t[13],t[14]],[e[12],e[13],e[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function d_(t,e,i,n){const r=eh.projectAabbCorners(n,i);let o=Number.MAX_VALUE,s=-1;for(let t=0;tnew U(r[t][0],r[t][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(_c(t,l))return o}const p_=aa([{name:"a_pos_3f",components:3,type:"Float32"}]),f_=aa([{name:"a_color_3f",components:3,type:"Float32"}]),m_=aa([{name:"a_color_4f",components:4,type:"Float32"}]),__=aa([{name:"a_uv_2f",components:2,type:"Float32"}]),g_=aa([{name:"a_normal_3f",components:3,type:"Float32"}]),y_=aa([{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"}]),v_=aa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),x_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class b_{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function w_(t,e){const i=-1===t.indexOf("://");try{return new URL(t,i&&e?"http://example.com":void 0),!0}catch(t){return!1}}class T_{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 S_{constructor(){this.instancedDataArray=new Ra,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class M_{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,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(t,e){}populate(t,e,i,n){this.tileToMeter=ic(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=dc(o,r);if(!this.layers[0]._featureFilter.filter(new Ss(this.zoom),c,i))continue;const h={id:t,sourceLayerIndex:l,index:a,geometry:r?c.geometry:uc(o,i,n),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&e.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(t,e,i,n){for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e in t)i.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(i.features[i.idToFeaturesIndex[e]],t[e],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e];for(const e of i.features){const n=this.layers[0],r=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,a)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,i,!0),t=!0)}}return t}updateReplacement(t,e,i,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(sd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e],s=r.instancedDataArray;for(const e of r.features){const r=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eWi;l=c?l-Wi:l;const h=Math.floor(l),u=s.float32[a+1];let d=!1;for(const e of this.activeReplacements)if(!id(e,i,x_.Model,n)&&!(e.min.x>h||h>e.max.x||e.min.y>u||u>e.max.y)&&(d=dd(ud(h,u,t.canonical,e.footprintTileId.canonical),e.footprint),d))break;s.float32[a]=d?l+Wi:l,o=o||d!==c}}}return o}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 i=this.instancesPerModel[e];i.instancedDataArray.length=Wi||e.y=Wi)continue;const t=(this.lookupDim-1)/Wi,i=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const n=s.length;s.resize(n+1),o.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(t,e,i,n){const r=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=r.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=r.paint.get("model-scale").evaluate(o,e,s),c=t.translation=r.paint.get("model-translation").evaluate(o,e,s),h=r.paint.get("model-color").evaluate(o,e,s);h.a=r.paint.get("model-color-mix-intensity").evaluate(o,e,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:ic(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[r]=c[2]}}}let E_,C_;no(M_,"ModelBucket",{omit:["layers"]}),no(S_,"PerModelAttributes"),no(T_,"ModelFeature");const I_=64,A_={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function L_(t,e,i,n,r,o,s,a,l,c=!1){const h=i.zoom,u=i.project(n),d=tc(n.lat,h),p=1/d;O.mat4.identity(t),O.mat4.translate(t,t,[u.x+s[0]*p,u.y+s[1]*p,s[2]]);let f=1,m=1;const _=i.worldSize;if(c){if("mercator"===i.projection.name){let t=0;i.elevation&&(t=i.elevation.getAtPointOrZero(new nc(u.x/_,u.y/_),0));const e=O.vec4.transformMat4([],[u.x,u.y,t,1],i.projMatrix)[3]/i.cameraToCenterDistance;f=e,m=e*tc(i.center.lat,h)}else if("globe"===i.projection.name){const e=u_(t,i),r=O.mat4.multiply([],i.projMatrix,e),o=[0,0,0,1];O.vec4.transformMat4(o,o,r);const s=o[3]/i.cameraToCenterDistance,a=bh(h),l=i.projection.pixelsPerMeter(n.lat,_)*tc(n.lat,h),c=i.projection.pixelsPerMeter(i.center.lat,_)*tc(i.center.lat,h);f=s/Ce(l,Ql(i.center.lat),a),m=s*d/l,f*=c,m*=c}}else f=p;O.mat4.scale(t,t,[f,f,m]);const g=[...t],y=e.orientation,v=[];if(c_(v,[y[0]+r[0],y[1]+r[1],y[2]+r[2]],o),O.mat4.multiply(t,g,v),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(t,e,i,n,r){const o=e.elevation;if(!o)return 0;const s=eh.projectAabbCorners(i,n),a=Wl(1,r.lat)*e.worldSize,l=function(t,e){const i=[0,0,1],n=[{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 r of n){const n=t[r.corners[0]],o=t[r.corners[1]],s=t[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=O.vec3.cross(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),r.dotProductWithUp=O.vec3.dot(l,i)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),c=s[l[0]],h=s[l[1]],u=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new nc(c[0]/e.worldSize,c[1]/e.worldSize),0),f=o.getAtPointOrZero(new nc(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new nc(u[0]/e.worldSize,u[1]/e.worldSize),0),_=o.getAtPointOrZero(new nc(d[0]/e.worldSize,d[1]/e.worldSize),0),g=(p+_)/2,y=(f+m)/2;return g>y?f=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function $_(t,e,i){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,p_.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,g_.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,__.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?f_:m_).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,v_.members,!0)),t.segments=el.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&P_(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&P_(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&P_(n.normalTexture,e),n.occlusionTexture&&P_(n.occlusionTexture,e,i),n.emissionTexture&&P_(n.emissionTexture,e)}function D_(t,e,i){if(t.meshes)for(const n of t.meshes)$_(n,e,i);if(t.children)for(const n of t.children)D_(n,e,i)}function k_(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)k_(e)}function z_(t){if(t.meshes)for(const i of t.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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)z_(e)}class R_{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const n=i||t.findDEMTileFor(e);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1=t)continue;const u=O_[c],d=Math.abs(u);d>a&&(s=u,a=d,l=r,h=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*h))/c;let a=e._dem.get(n,i)+s*o;const u=e._dem.get(n+l,i+h),d=e._dem.get(n-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),O_[r]=e._dem.set(n,i,a),B_[r]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=kt.now())}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)k_(e.node),z_(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint))}}getHeightAtTileCoord(t,e){const i=this.getNodesInfo(),n=[],r=[0,0,0],o=O.mat4.identity([]);for(let s=0;sc.max[0]||e>c.max[1])continue;if(!0===a.node.hidden)return{height:1/0,maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]};O.mat4.invert(o,a.node.matrix),r[0]=t,r[1]=e,O.vec3.transformMat4(r,r,o);const h=(r[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*I_|0,u=Math.min(63,(r[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*I_|0)*I_+Math.min(63,h),d=l.heightmap[u];if(!(d0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function G_(t,e){return!t.isLightConstant&&e}function Z_(t,e,i,n,r,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,c=(3840&e|(3840&e)>>4)>>4,h=240&e|(240&e)>>4;i[3]>0&&(l=Ce(l,255*i[0],i[3]),c=Ce(c,255*i[1],i[3]),h=Ce(h,255*i[2],i[3]));const u=l>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)t.polygon)).flat());const _=p?a:null,[g,y]=function(t,e,i,n,r,o,s,a,l,c,h){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,h){const u=[],d=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},g=Ud();i>0&&(i+=g),n+=g;for(const g of e){const e=[],y=[];for(const u of g){const d=u.x+r.x,g=u.y+r.y,v=t.projection.projectTilePoint(d,g,h),x=t.projection.upVector(h,u.x,u.y);let b=i,w=n;if(s){const t=Wd(d,g,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,v.x+x[0]*p*b,v.y+x[1]*p*b,v.z+x[2]*p*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*p*w,v.y+x[1]*p*w,v.z+x[2]*p*w),O.vec3.transformMat4(f,f,o),O.vec3.transformMat4(m,m,o),e.push(new Xu(f[0],f[1],f[2])),y.push(new Xu(m[0],m[1],m[2]))}u.push(e),d.push(y)}return[u,d]}(t,e,i,n,r,o,s,a,l,c,h):s?function(t,e,i,n,r,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of t){const t=[],p=[];for(const c of d){const h=c.x+n.x,d=c.y+n.y,f=Wd(h,d,e,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const m=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,O.vec4.transformMat4(u,u,r),u[3]=Math.max(u[3],1e-5);const _=new Xu(u[0]/u[3],u[1]/u[3],u[2]/u[3]);t.push(m),p.push(_)}c.push(t),h.push(p)}return[c,h]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=m+a,x=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,S=_+d,M=g+p,E=Math.max(y+f,1e-5);t.push(new Xu(v/w,x/w,b/w)),i.push(new Xu(T/E,S/E,M/E))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,u,h,c,s,_,d,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,i){let n=1/0;yc(i,e)&&(n=Hd(i,e[0]));for(let r=0;r{if(yp)return yp;const t=_p();return yp=new gp(t.paint.properties["line-width"].specification),yp.useIntegerZoom=!0,yp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new sp(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,i){const n=pp(this);return{config:new Cl(this,{zoom:e,lut:i}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,i=vp(Lc("line-width",this,e),Lc("line-gap-width",this,e)),n=Lc("line-offset",this,e);return i/2+Math.abs(n)+Pc(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,r,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=$c(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*vp(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(n=function(t,e){const i=[],n=new U(0,0);for(let r=0;r=3)for(let e=0;e{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 X_{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new Y_(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){try{t()}finally{}return null}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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 i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||mt()){const t=this.callbacks[i],n=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,e)}processTask(t,e){if(delete this.cancelCallbacks[t],""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(ao(e.error)):i(null,ao(e.data)))}else{const i=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?so(e):null,data:so(n,i)},i)}:t=>{},r=ao(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source,r.scope)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class J_{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nt();const i=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0}))}broadcast(t,e,i){tt(this.actors,((i,n)=>{i.send(t,e,n)}),i=i||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)}}J_.Actor=K_;class Q_{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const i=this.toIdx(t,e);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function tg(t,e,i,n){let r=0,o=Number.MAX_VALUE;for(let s=0;se[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function eg(t,e,i,n,r,o,s,a,l,c,h){const u=n-t,d=r-e,p=o-i,f=s-t,m=a-e,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,v=h[0]*m-h[1]*f,x=u*g+d*y+p*v;if(Math.abs(x)1)return null;const E=T*p-S*d,C=S*u-w*p,I=w*d-T*u,A=(h[0]*E+h[1]*C+h[2]*I)*b;return A1?null:(f*E+m*C+_*I)*b}function ig(t,e,i){return(t-e)/(i-e)}function ng(t,e,i,n,r,o,s,a,l){const c=1{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new Q_(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new Q_(n);for(let e=0;e0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){ng(f,m,_,t,e,i,n,h,u);const a=1=t[2])return p}continue}let g=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),e=!0);e||(c[g]=d),g++}}for(let t=0;t=this.dim+1||e=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const i=[0,0,0,0],n=hg.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Gh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function wg(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e>4|(61440&i)>>8|(240&n)>4|(15&n)>6|(192&n)>>4|(192&r)>>2|192&o,t[e+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)>2|12&n|(12&r)>1|(21845&zg)>2|(13107&Rg)>4|(3855&Rg)>8|(255&Rg)>1}var Og=function(t,e,i){for(var n=t.length,r=0,o=new Sg(e);r>l]=c;return s},Bg=new Tg(288);for(zg=0;zge&&(e=t[i]);return e},jg=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]>(7&e)&i},Gg=function(t,e){var i=e/8|0;return(t[i]|t[i+1]>(7&e)},Zg=["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"],qg=function(t,e,i){var n=new Error(e||Zg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,qg),!i)throw n;return n},Hg=new Tg(0),Wg="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wg.decode(Hg,{stream:!0})}catch(t){}const Yg={gzip_data:"gzip"};class Xg extends Error{constructor(t){super(t),this.name="MRTError"}}const Kg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Jg={uint32:1,uint16:2,uint8:4},Qg={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ty;class ey{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new Xg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),i=new DataView(t);if(13!==e[0])throw new Xg("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),i=this.getHeaderLength(t);if(e.length= ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n = ${i} but got buffer of length ${e.length}`);const n=function(t){return t.readFields(ug,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new ty(e.subarray(0,i)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Xg(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new iy(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],i=this.getLayer(t.layerName);for(let n of t.blockIndices){const r=i.dataIndex[n],o=r.first_byte-t.firstByte,s=r.last_byte-t.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map((t=>t.filter))};i._blocksInProgress.add(n),e.push(a)}return new ny(e,(()=>{e.forEach((t=>i._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>i._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class iy{constructor({version:t,name:e,units:i,tilesize:n,pixel_format:r,buffer:o,data_index:s},a){if(this.version=t,1!==this.version)throw new Xg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Kg[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Jg[this.pixelFormat]],this._decodedBlocks=new vg(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Jg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===t)return{bandIndex:e+r,blockIndex:i,blockBandIndex:r};e+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(t>=e&&tthis.cacheSize)throw new Xg(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:i,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:i}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new Xg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==r.offset?r.offset:r.deprecated_offset,scale:0!==r.scale?r.scale:r.deprecated_scale}}}ey.setPbf=function(t){ty=t};class ny{constructor(t,e,i){this.tasks=t,this._onCancel=e,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}ey.performDecoding=function(t,e){const i=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=i.subarray(n,r+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Xg(`Unhandled codec: ${c}`);return d=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||qg(6,"invalid gzip data");var e=t[3],i=10;4&e&&(i+=2+(t[10]|t[11]>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)}(r=t))+8>r.length&&qg(6,"invalid gzip data"),function(t,e,i){var n=t.length;if(!n||e.f&&!e.l)return i||new Tg(0);var r=!i,o=r||2!=e.i,s=e.i;r&&(i=new Tg(3*n));var a,l,c=function(t){var e=i.length;if(t>e){var n=new Tg(Math.max(2*e,t));n.set(i),i=n}},h=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,m=e.m,_=e.n,g=8*n;do{if(!p){h=jg(t,u,1);var y=jg(t,u+1,3);if(u+=3,!y){var v=t[(L=4+((u+7)/8|0))-4]|t[L-3]n){s&&qg(0);break}o&&c(d+v),i.set(t.subarray(L,x),d),e.b=d+=v,e.p=u=8*x,e.f=h;continue}if(1==y)p=Ng,f=Ug,m=9,_=5;else if(2==y){var b=jg(t,u,31)+257,w=jg(t,u+10,15)+4,T=b+jg(t,u+5,31)+1;u+=14;for(var S=new Tg(T),M=new Tg(19),E=0;E>4)g){s&&qg(0);break}}o&&c(d+131072);for(var R=(1>4;if((u+=15&$)>g){s&&qg(0);break}if($||qg(2),F264&&(N=jg(t,u,(1>4;if(U||qg(3),u+=15&U,z=Dg[V],V>3){var j=Cg[V];z+=Gg(t,u)&(1g){s&&qg(0);break}o&&c(d+131072);var G=d+N;if(da.length)&&(l=a.length),new Tg(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new Tg(((i=r)[(n=i.length)-4]|i[n-3]>>0))));var i,n,r,o;const s=Yg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(h,c).then((t=>(function(t,e){t.readFields(gg,e)}(new ty(t),u),new(0,Qg[o])(u.buffer)))),d.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":xg(t,s);break;case"zigzag_filter":bg(t);break;case"bitshuffle_filter":wg(t,o);break;default:throw new Xg(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},no(ny,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ry={workerUrl:"",workerClass:null,workerParams:void 0};const oy="mapboxgl_preloaded_worker_pool";class sy{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[oy]}numActive(){return Object.keys(this.active).length}}let ay;function ly(){return ay||(ay=new sy),ay}sy.workerCount=2;let cy,hy,uy,dy,py,fy=null;function my(){return mt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:hy||St.DRACO_URL}function _y(){if(mt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(dy)return dy;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 dy=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,dy}const gy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},vy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function xy(t,e,i){const n=i.json.bufferViews.length,r=i.buffers.length;e.bufferView=n,i.json.bufferViews[n]={buffer:r,byteLength:t.byteLength},i.buffers[r]=t}const by="KHR_draco_mesh_compression";function wy(t,e){const i=t.extensions&&t.extensions[by];if(!i)return;const n=new uy.Decoder,r=Ay(e,i.bufferView),o=new uy.Mesh;if(!n.DecodeArrayToMesh(r,r.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=gy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=uy._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,c):n.GetTrianglesUInt32Array(o,l,c),xy(uy.memory.buffer.slice(c,c+l),s,e),uy._free(c);for(const r of Object.keys(i.attributes)){const s=n.GetAttributeByUniqueId(o,i.attributes[r]),a=e.json.accessors[t.attributes[r]],l=yy[a.componentType],c=a.count*vy[a.type]*gy[a.componentType].BYTES_PER_ELEMENT,h=uy._malloc(c);n.GetAttributeDataArrayForAllPoints(o,s,uy[l],c,h),xy(uy.memory.buffer.slice(h,h+c),a,e),uy._free(h)}n.destroy(),o.destroy(),delete t.extensions[by]}const Ty="EXT_meshopt_compression";function Sy(t,e){if(!t.extensions||!t.extensions[Ty])return;const i=t.extensions[Ty],n=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),r=new Uint8Array(i.count*i.byteStride);py.decodeGltfBuffer(r,i.count,i.byteStride,n,i.mode,i.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=r.buffer,delete t.extensions[Ty]}const My=1179937895,Ey=new TextDecoder("utf8");function Cy(t,e){return new URL(t,e).href}function Iy(t,e,i,n){return fetch(Cy(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[i]=t}))}function Ay(t,e){const i=t.json.bufferViews[e];return new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ly(t,e,i,n){if(t.uri){const r=Cy(t.uri,n);return fetch(r).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[i]=t}))}if(void 0!==t.bufferView){const n=Ay(e,t.bufferView),r=new Blob([n],{type:t.mimeType});return createImageBitmap(r).then((t=>{e.images[i]=t}))}}function Py(t,e=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===My){const i=new Uint32Array(t,e);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(Ey.decode(i.subarray(r,r+s))),r+=s,r{const t=[],e=a&&a.includes(by),r=a&&a.includes(Ty);if(e&&t.push(function(){if(!uy)return null!=cy?cy:(cy=function(t){let e,i=null;function n(){e=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(t,i,n){return e.copyWithin(t,i,i+n)},c:function(t){const r=e.length,o=Math.max(t>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(t){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=t.instance.exports;i=g;const S=(()=>{let t=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(t),i+=n,n=t=0),t||(i+=128,t=o(i));const l=a.length+7&-8;let c=t;l>=i&&(n=l,c=s=o(l));for(let t=0;t{uy=t,cy=void 0})))}()),r&&t.push(function(){if(py)return;const t=function(t){let e;const i=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(t,i,o,s,a,l){!function(t,e,i,n,r,o,s){const a=t.exports.sbrk,l=n+3&-4,c=a(l*r),h=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,h);const d=e(c,n,r,h,o.length);if(0===d&&s&&s(c,l,r),i.set(u.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(e,e.exports[r[a]],t,i,o,s,e.exports[n[l]])}}}(fetch(_y()));return t.ready.then((()=>{py=t}))}()),o)for(let e=0;e{if(e&&s)for(const{primitives:t}of s)for(const e of t)wy(e,n);if(r&&s&&l)for(const t of l)Sy(t,n);return n}))}))}function $y(t,e){const i=t.json.bufferViews[e.bufferView],n=gy[e.componentType];return new n(t.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==vy[e.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:vy[e.type]))}function Dy(t,e,i,n){const r=gy[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:vy[e.type],l=i.float32,c=l.length/i.capacity;for(let t=0,i=0;t0){for(let r=0;r0){o.texcoordArray=new za;const t=e.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(t.count);const i=$y(e,t);Dy(e,t,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const t=e.json.accessors[r._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(e,t))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(e,e.json.accessors[r._FEATURE_RGBA4444]).buffer));const u=t.material;return o.material=function(t,e){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=t.pbrMetallicRoughness||{},f=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const t=s.extensions.KHR_texture_transform;f.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Me(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:p?e[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:n,alphaCutoff:r,normalTexture:o?e[o.index]:void 0,occlusionTexture:f,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==u?e.json.materials[u]:{defined:!1},i),o}function zy(t,e,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:l,children:c}=t,h={};if(h.matrix=n||O.mat4.fromRotationTranslationScale([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:i,max:n}=e.aabb;t[0]+=i[0]+n[0],t[1]+=i[1]+n[1]}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2)}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),i=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let t=0;t0&&n.reverse();const o=Wh(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function By(t,e){const i=[],n=[];let r=0;const o=[];for(const s of t){r=i.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:i,indices:n}}function Fy(t){const e=function(t,e){const i=[],n=WebGL2RenderingContext;if(t.json.textures)for(const r of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,t.json.samplers[r.sampler]),i.push({image:e[r.source],sampler:o,uploaded:!1})}return i}(t,t.images),i=function(t,e){const i=[];for(const n of t.json.meshes){const r=[];for(const i of n.primitives)r.push(ky(i,t,e));i.push(r)}return i}(t,e),{scenes:n,scene:r,nodes:o}=t.json,s=n?n[r||0].nodes:o,a=[];for(const e of s)a.push(zy(o[e],t,i));return function(t,e,i){const n={},r=new Set;for(let o=0;o0){const e=Array.from(r.values()).sort(((t,e)=>t-e));for(let i=e.length-1;i>=0;i--)t.splice(e[i],1)}}(a,s,t.json.nodes),a}function Ny(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,i=t.aabb.min[0]-1,n=t.aabb.min[1]-1,r=I_/(t.aabb.max[0]-i+2),o=I_/(t.aabb.max[1]-n+2);for(let s=0;st.heightmap[c*I_+l]&&(t.heightmap[c*I_+l]=a)}}function Uy(t,e){const i={};i.indexArray=new Ca,i.indexArray.reserve(4*t.length),i.vertexArray=new ma,i.vertexArray.reserve(10*t.length),i.colorArray=new fa,i.vertexArray.reserve(10*t.length);let n=0;for(const r of t){const t=Math.min(10,Math.max(4,1.3*r.height))*e,o=[-r.normal[1],r.normal[0],0],s=Math.min(.29,.1*r.width/r.depth),a=r.width-2*r.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],r.pos,o,a/2),c=O.vec3.scaleAndAdd([],r.pos,o,-a/2),h=[l[0],l[1],l[2]+r.height],u=[c[0],c[1],c[2]+r.height],d=O.vec3.scaleAndAdd([],r.normal,o,s);O.vec3.scale(d,d,t);const p=O.vec3.scaleAndAdd([],r.normal,o,-s);O.vec3.scale(p,p,t),O.vec3.add(d,l,d),O.vec3.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/t/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+n,4+n,8+n),i.indexArray.emplaceBack(7+n,9+n,5+n),i.indexArray.emplaceBack(0+n,1+n,2+n),i.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const r={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=Me.white,r.pbrMetallicRoughness=o,i.material=r,i.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class Vy{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yu.VectorTile(new Gp(this.rawTileData)).layers,this.sourceLayerCoder=new Vy(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,i,n){this.loadVTLayers();const r=t.params||{},o=Us(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>Ec(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Hy);let h=null;a.elevation&&c.length>0&&(h=R_.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=uc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,m,this.z,t.transform,t.pixelPosMatrix,h,r))))}return u}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=e,p=this.bucketLayerIDs[h];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=dc(m,!0);if(!i.filter(new Ss(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Ss(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof $s?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function Hy(t,e){return e-t}no(Zy,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Wy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Yy{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Wy[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new Yy(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Xy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u=t&&a=e&&c>1,p=o[2*d],f=o[2*d+1];p>=t&&p=e&&f=p:n>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u>1,p=r[2*d],f=r[2*d+1];tv(p,f,t,e)=p:e+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function Xy(t,e,i,n,r,o){if(r-n>1;Ky(t,e,s,n,r,o),Xy(t,e,i,n,s-1,1-o),Xy(t,e,i,s+1,r,1-o)}function Ky(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2s&&Jy(t,e,n,r);as;)l--}e[2*n+o]===s?Jy(t,e,n,l):(l++,Jy(t,e,l,r)),l{}}},t.aF=Vm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>Py(e,0,t)))},t.aH=Fy,t.aI=class{constructor(t,e,i,n){this.id=t,this.position=null!=e?new jl(e[0],e[1]):new jl(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new eh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const i=eh.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,i,n,r,o,s=!1){L_(this.matrix,this,t.transform,this.position,e,i,n,r,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)D_(e,t);for(const t of this.nodes)k_(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)z_(t)}},t.aJ=ot,t.aK=Yf,t.aL=Yl,t.aM=Xl,t.aN=ua,t.aO=Ca,t.aP=nt,t.aQ=Ua,t.aR=Cm,t.aS=function(){Ts.isLoading()||Ts.isLoaded()||"deferred"!==bs()||ws()},t.aT=Us,t.aU=dc,t.aV=Gy,t.aW=_t,t.aX=sp,t.aY=Tu,t.aZ=uc,t.a_=ca,t.aa=Ce,t.ab=Wi,t.ac=Ie,t.ad=class{constructor(t){this.specification=t}possiblyEvaluate(t,e){return function([t,e]){const i=ft([1,t,e]);return{x:i.x,y:i.y,z:i.z}}(t.expression.evaluate(e))}interpolate(t,e,i){return{x:Ce(t.x,e.x,i),y:Ce(t.y,e.y,i),z:Ce(t.z,e.z,i)}}},t.ae=function(t,e,i=0,n=!0){const r=new U(i,i),o=t.sub(r),s=e.add(r),a=[o,new U(s.x,o.y),s,new U(o.x,s.y)];return n&&a.push(o.clone()),a},t.af=function(t,e){const i=[];for(let n=0;n{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}},t.av=ta,t.aw=function(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ne(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new Yu.VectorTile(new Gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)},t.ax=function(t){Zt++,Zt>Ft&&(t.getActor().send("enforceCacheSizeLimit",Bt),Zt=0)},t.ay=Dt,t.az=function(t){return tr&&(n+=(t[i]-r)*(t[i]-r)),e[i]0&&i[0]0&&i[1]0&&n[0]0&&n[1]0?Math.acos(i/n)*G:0;let o=0!==t||0!==e?Math.atan2(-e,-t)*G+90:0;return o0){const t=180/n;O.mat3.multiply(p,p,[t/c+1,0,0,0,t/h+1,0,-.5*t/u,.5*t/d,1])}return p[2]=l,p[5]=t.x,p[8]=t.y,p},t.cC=ah,t.cD=function(t,e,i){const n=O.mat4.identity(new Float64Array(16)),r=(e/(11)return!1;const i=e.getSource().maxzoom,n=11)return e;const r=n.getSource().maxzoom,o=1{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y),a=n.upVectorScale(t.canonical,e,i).metersToTile;return O.vec3.scale(s,s,o*a),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=R_.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1({u_camera_to_center_distance:new ul(t),u_extrude_scale:new xl(t),u_device_pixel_ratio:new ul(t),u_matrix:new gl(t),u_inv_rot_matrix:new gl(t),u_merc_center:new dl(t),u_tile_id:new pl(t),u_zoom_transition:new ul(t),u_up_dir:new pl(t),u_emissive_strength:new ul(t)}),t.cO=t=>({u_matrix:new gl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_units_to_pixels:new dl(t),u_dash_image:new hl(t),u_gradient_image:new hl(t),u_image_height:new ul(t),u_texsize:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t),u_trim_fade_range:new dl(t),u_trim_color:new fl(t),u_emissive_strength:new ul(t)}),t.cP=t=>({u_matrix:new gl(t),u_texsize:new dl(t),u_pixels_to_tile_units:new xl(t),u_device_pixel_ratio:new ul(t),u_image:new hl(t),u_units_to_pixels:new dl(t),u_tile_units_to_pixels:new ul(t),u_alpha_discard_threshold:new ul(t),u_trim_offset:new dl(t)}),t.cQ=Ma,t.cR=Ip,t.cS=kp,t.cT=Ih,t.cU=(t,e,i,n,r,o)=>{const s=t.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const t=vh(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:kt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Ch,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[e.canonical.x,e.canonical.y,1{const s=t.transform;return{u_matrix:dp(t,e,i,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:up(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},t.cX=(t,e,i,n,r,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:dp(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:fp(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:up(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},t.cY=rt,t.cZ=Zh,t.c_=Ud,t.ca=ft,t.cb=function(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cc=function(t){return t({pluginStatus:_s,pluginURL:gs}),xs.on("pluginStateChange",t),t},t.cd=J_,t.ce=ly,t.cf=Ef,t.cg=Mf,t.ch=ee,t.ci=ys,t.cj=Rt,t.ck=_e,t.cl=ct,t.cm=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(0,e):t},t.cn=function(t){return t.indexOf(Qs)>=0},t.co=function(t){const e=t.indexOf(Qs);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,i,n){return"custom"===t.type?new e_(t,e):new W_[t.type](t,e,i,n)},t.cr=lt,t.cs=xs,t.ct=ie,t.cu=ml,t.cv=class extends cl{constructor(t){super(t),this.current=yl}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t0;return 0===n&&!r&&!o},t.cy=function(t){const e=t.pixelsPerMeter,i=e/Wl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[i,i,e]),Float32Array.from(n)},t.cz=uh,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Dd,t.d1=bd,t.d2=450,t.d3=7,t.d4=Hm,t.d5=aa,t.d6=Ba,t.d7=256,t.d8=gh,t.d9=ma,t.dA=wh,t.dB=function(t){const e=[0,0,0],i=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(i,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,i),new U(e[0],e[1])},t.dC=function(t,e,i=!1){if(_s===ds||_s===ps||_s===fs)throw new Error("setRTLTextPlugin cannot be called multiple times.");gs=kt.resolveURL(t),_s=ds,ms=e,vs(),i||ws()},t.dD=bs,t.dE=function(){ly().acquire(oy)},t.dF=function(){const t=ay;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(oy),ay=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.dG=sy,t.dH=function(t){const e=jt();if(!e)return;const i=e.delete(Ot);t&&i.catch(t).then((()=>t()))},t.dI=ry,t.dJ=my,t.dK=function(t){hy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setDracoUrl",hy)},t.dL=_y,t.dM=function(t){dy=kt.resolveURL(t),fy||(fy=new J_(ly(),new be)),fy.broadcast("setMeshoptUrl",dy)},t.dN=no,t.dO=Vh,t.dP=2,t.dQ=Vy,t.dR=Zy,t.dS=ip,t.dT=at,t.dU=bf,t.dV=function(t,e,i,n,r,o,s,a,l,c,h){t.createArrays(),t.tilePixelRatio=Wi/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,d=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ss(e),a),d["text-size"].possiblyEvaluate(new Ss(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ss(e),a),d["icon-size"].possiblyEvaluate(new Ss(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ss(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ss(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ss(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){_=!0;break}for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const n=v.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Ap,c=u.get("text-line-height").evaluate(o,{},a)*Ap,h=os(n)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const t=u.get("text-radial-offset").evaluate(o,{},a);b=t?Bf(p,[t*Ap,Rf]):u.get("text-offset").evaluate(o,{},a).map((t=>t*Ap))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const x="point"===u.get("symbol-placement"),w=x?u.get("text-max-width").evaluate(o,{},a)*Ap:1/0,T=o=>{t.allowVerticalPlacement&&rs(n)&&(y.vertical=Kp(v,e,i,r,l,w,c,p,o,h,b,Wp.vertical,!0,g,d))};if(!f&&m){const t="auto"===_?m.map((t=>Ff(t))):[_];let n=!1;for(let o=0;o=0||!rs(n)){const t=Kp(v,e,i,r,l,w,c,p,_,h,b,Wp.horizontal,!1,g,d);t&&(y.horizontal[_]=t)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const e=n[o.icon.namePrimary];e&&(x=lf(r[o.icon.namePrimary],o.icon.nameSecondary?r[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ut("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const T=Gf(y.horizontal)||y.vertical;t.iconsInText||(t.iconsInText=!!T&&T.iconsInText),(T||x)&&Nf(t,o,y,x,n,p,g,0,b,w,s,a,c,h,_)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)},t.dW=Yu,t.dX=hg,t.dY=N,t.dZ=Wu,t.d_=jp,t.da=Pa,t.db=$a,t.dc=function(t,e,i,n,r){return K((t-e)/(i-e)*(r-n)+n,n,r)},t.dd=wr,t.de=tc,t.df=class{constructor(t,e,i,n){this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();const[r,o,s]=this.size,{gl:a}=t;a.bindTexture(a.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Fm(this.format),Nm(this.format),e.data)}bind(t,e){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}},t.dg=u_,t.dh=[1,1,1],t.di=R_,t.dj=A_,t.dk=wa,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new U(1/0,1/0),max:new U(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const i=ad(new U(0,0),new U(Wi,Wi),t),n=[];if(e&&!od(i,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!od(i,e))continue;const r=ld(e.min,e.max,t);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope})}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const i of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(i).buckets[t.layer];n&&n.updateFootprints(i.toUnwrapped(),e)}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))))}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const i=t.getOrder(),n=t.getClipMask(),r=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=ad(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||nd(t.min,e.min)||nd(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const i=(t,e)=>t+e;return t.length-e.length||t.reduce(i,"").localeCompare(e.reduce(i,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const i=this._activeRegions[e],n=this._prevRegions[e];t=i.priority!==n.priority||!rd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!V(i.clipScope,n.clipScope),++e}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==ed&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const i=e[t].priority;for(;t1){let e=0,i=t(e);for(;e!==i;){let n=e;const r=e;for(;n!==i;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement()}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,e){const i=new ca,n=new Ca,r=[],o=t+1+2,s=e[0]+1,a=e[0]+1+(1+e.length),l=(t,e,i)=>{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;t=t.byteLength)&&ut("Invalid b3dm header information.")}return Py(t,e)},t.e1=function(t,e){const i=Fy(t);for(const t of i){for(const e of t.meshes)Ny(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Uy(t.lights,e)))}return i},t.e2=j_,t.e3=K_,t.e4=Ts,t.e5=function(t){Gt(),null!=Ut&&Ut.then((e=>{e.keys().then((i=>{for(let n=0;n"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=et,t.m=qt,t.n=function(t,e){return ie(et(t,{type:"json"}),e)},t.o=le,t.p=function(t,e){return ie(et(t,{method:"POST"}),e)},t.q=kt,t.r=jh,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}},t.t=ye,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ut,t.x=ge,t.y=2,t.z=vf})),n(0,(function(t){function e(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}function i(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const n of t)e+=`${i(n)},`;return`${e}]`}let e="{";for(const n of Object.keys(t).sort())e+=`${n}:${i(t[n])},`;return`${e}}`}function n(e){let n="";for(const r of t.bg)n+=`/${i(e[r])}`;return n}class r{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,r){this._options=r;for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.cq(i,this.scope,null,this._options)).compileFilter(r),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}const o=1*t.dP;class s{constructor(e){const i={},n=[];for(const t in e){const r=e[t],s=i[t]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i=e.metrics.localGlyph?o:1,a={x:0,y:0,w:e.bitmap.width+2*i,h:e.bitmap.height+2*i};n.push(a),s[t]=a}}const{w:r,h:s}=t.z(n),a=new t.dO({width:r||1,height:s||1});for(const n in e){const r=e[n];for(const e in r.glyphs){const s=r.glyphs[+e];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][e],c=s.metrics.localGlyph?o:1;t.dO.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}t.dN(s,"GlyphAtlas");class a{constructor(e){this.tileID=new t.aA(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=t.aK(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep}parse(e,i,n,r,o){this.status="parsing",this.data=e,this.collisionBoxArray=new t.aQ;const a=new t.dQ(Object.keys(e.layers).sort()),c=new t.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new t.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:n,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const r=e.layers[i];if(!r)continue;let o=!1,s=!1,u=!1;for(const t of p[i])"symbol"===t[0].type?o=!0:s=!0,t[0].is3D()&&"model"!==t[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(l(t,this.zoom,d.brightness,n),(h[e.id]=e.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>t.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const e=new s(m),i=new t.dU(_,g,this.lut);for(const r in h){const o=h[r];o instanceof t.aR?(l(o.layers,this.zoom,d.brightness,n),t.dV(o,m,e.positions,_,i.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof t.aX||o instanceof t.aY||o instanceof t.d0)&&(l(o.layers,this.zoom,d.brightness,n),o.addFeatures(d,this.tileID.canonical,i.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:t.bd(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const e=t.dT(d.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((t,e)=>{f||(f=t,m=e,v())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,e)=>{f||(f=t,_=e,v())}),void 0,!1,y):_={};const n=Object.keys(d.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,e)=>{f||(f=t,g=e,v())}),void 0,!1,y):g={}}v()}}function l(e,i,n,r){const o=new t.a3(i,{brightness:n});for(const t of e)t.recalculate(o,r)}class c extends t.E{constructor(e,i,n,r,o,s){super(),this.actor=e,this.layerIndex=i,this.availableImages=n,this.loadVectorData=o||t.aw,this.loading={},this.loaded={},this.deduped=new t.au(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=s}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[r]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[r];if(delete this.loading[r],h||a||!c)return l.status="done",h||(this.loaded[r]=l),n(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new t.dW.VectorTile(new t.bb(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,r)=>{if(i||!r)return n(i);const a={};if(s){const t=e(o);t.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(t)))}n(null,t.l({rawTileData:u.slice(0)},r,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[r]=l}))}reloadTile(e,i){const n=this.loaded,r=e.uid;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=t.aK(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster,o.lut=e.lut;const s=(t,e)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,n)),i(t,e)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else i(null,void 0)}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}}class h{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=e,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new t.dX(n,a,r,s{n(null,t)}),(t=>{n(t)}))}}const d=t.dW.VectorTileFeature.prototype.toGeoJSON;class p{constructor(e){this._feature=e,this.extent=t.ab,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const n=[];for(const e of i)n.push(new t.P(e[0],e[1]));e.push(n)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.ab,this.length=e.length,this._features=e}feature(t){return new p(this._features[t])}}const m=64/4096;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const i of t){const t=i.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),i.geometry?(n=y(i),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:i,uid:n}of Object.values(e)){const{z:r,x:o,y:s}=i;g(t,Math.pow(2,r),o,s)&&delete e[n]}}getTile(t,e,i){const n=Math.pow(2,t),r=[];for(const t of this.features.values())g(t,n,e,i)&&r.push(w(t,n,e,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function g({minX:t,minY:e,maxX:i,maxY:n},r,o,s){return t(o-m)/r&&n>(s-m)/r}function y(t){const{id:e,geometry:i,properties:n}=t;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)v(o,a,s);else if("MultiPoint"===r)for(const t of o)v(t,a,s);else if("LineString"===r)s.type=2,x(o,a,s);else if("MultiLineString"===r)s.type=2,b(o,a,s);else if("Polygon"===r)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)b(t,a,s,!0)}return s}function v([e,i],n,r){const o=t.am(e);let s=t.at(i);s=s1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function x(t,e,i,n=!1,r=!1){const o=[];for(const e of t)v(e,o,i);e.push(o),n&&function(t,e){let i=0;for(let e=0,n=t.length,r=n-2;e0===e)for(let e=0,i=t.length;e=a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n =a&&d>=a||(h>=a?(u+=Math.round(m*((a-h)/f)),h=a):d>=a&&(p=u+Math.round(m*((a-h)/f)),d=a),u>=a&&p>=a||(u>=a?(h+=Math.round(f*((a-u)/m)),u=a):p>=a&&(d=h+Math.round(f*((a-u)/m)),p=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],o.push(l)),l.push([d,p])))))}}var S,M,E,C={exports:{}},I=function(){if(E)return C.exports;E=1;var e=t.d_(),i=function(){if(M)return S;M=1;var e=t.dY(),i=t.dZ().VectorTileFeature;function n(t,e){this.options=e||{},this.features=t,this.length=t.length}function r(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}return S=n,n.prototype.feature=function(t){return new r(this.features[t],this.options.extent)},r.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function c(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,c=0;ct},P=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class D{constructor(t){this.options=Object.assign(Object.create(L),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(R(i),O(o),R(r),O(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+5]>1?k(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+5]>1?k(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,h={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,h),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,h),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e1;let l,c,h;if(a)l=z(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=R(n),h=O(r)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(h*r-n))]],tags:l};let d;d=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=a[i+5])}if(p>d&&p>=o){let t,o=n*d,s=h*d,f=-1;const m=(i/c1)for(const t of u){const i=t*c;if(!(a[i+2]>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function k(t,e,i){return{type:"Feature",id:t[e+3],properties:z(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function z(t,e,i){const n=t[e+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:r})}function R(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function F(t,e,i,n){let r=n;const o=e+(i-e>>1);let s,a=i-e;const l=t[e],c=t[e+1],h=t[i],u=t[i+1];for(let n=e+3;nr)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n r)s=n,r=e;else if(e===r){const t=Math.abs(n-o);tn&&(s-e>3&&F(t,e,s,n),t[s+2]=r,i-s>3&&F(t,s,i,n))}function N(t,e,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=t-i,a=e-n,s*s+a*a}function U(t,e,i,n){const r={id:t??null,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)V(r,i);else if("Polygon"===e)V(r,i[0]);else if("MultiLineString"===e)for(const t of i)V(r,t);else if("MultiPolygon"===e)for(const t of i)V(r,t[0]);return r}function V(t,e){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=e.length-3;e[2]=1,F(e,0,a,i),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function q(t,e,i,n){for(let r=0;r1?1:i}function Y(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===r?e.minX:e.minY,c=0===r?e.maxX:e.maxY;if(s>=i&&c=n)continue;let h=[];if("Point"===o||"MultiPoint"===o)X(t,h,i,n,r);else if("LineString"===o)K(t,h,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)Q(t,h,i,n,r,!1);else if("Polygon"===o)Q(t,h,i,n,r,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];Q(e,t,i,n,r,!0),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(U(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(U(e.id,o,h,e.tags))}}return l.length?l:null}function X(t,e,i,n,r){for(let o=0;o=i&&si&&(h=l(a,p,f,_,g,i),s&&(a.start=u+c*h)):y>n?v=i&&(h=l(a,p,f,_,g,i),x=!0),v>n&&y=i&&m=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&tt(a,a[0],a[1],a[2]),a.length&&e.push(a)}function J(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Q(t,e,i,n,r,o){for(const s of t)K(s,e,i,n,r,o,!1)}function tt(t,e,i,n){t.push(e,i,n)}function et(t,e,i,n,r,o){const s=(o-e)/(n-e);return tt(t,o,i+(r-i)*s,1),s}function it(t,e,i,n,r,o){const s=(o-i)/(r-i);return tt(t,e+(n-e)*s,o,1),s}function nt(t,e){const i=[];for(let n=0;n
| <STRONG> (7) | Kto i jak przetwarza Twoje dane? Odbiorcy danych: Kontakt: Okres przechowywania: Pouczenie o prawach: Prawo do skargi: Prawo do sprzeciwu:
|
HTML headings and emphasis tags are the most basic forms to indicate important content.
Tips:
1. use your keywords in the headings and make sure the first level heading (<H1>) includes the most important keywords.
2. never duplicate the title tag content in the heading tags.
3. for more effective SEO, use only one <H1> tag per page |