=0||!Co(r)){const t=Wu(v,e,i,n,l,k,c,m,b,h,_,$u.horizontal,!1,x,f,d);t&&(g.horizontal[b]=t)}E("point"===x?"left":b)}}let b=!1;if(o.icon&&o.icon.name){const e=r[o.icon.name];e&&(y=nd(n[o.icon.name],u.get("icon-offset").evaluate(o,{},s),u.get("icon-anchor").evaluate(o,{},s)),b=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&pt("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 x=jd(g.horizontal)||g.vertical;t.iconsInText||(t.iconsInText=!!x&&x.iconsInText),(x||y)&&Rd(t,o,g,y,r,h,f,0,_,b,a,s,c)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function Ld(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Rd(t,e,i,r,n,o,a,s,l,c,u,d,h){let p=o.textMaxSize.evaluate(e,{},d);void 0===p&&(p=a);const m=t.layers[0].layout,f=m.get("icon-offset").evaluate(e,{},d),g=jd(i.horizontal)||i.vertical,v=a/24,y=t.tilePixelRatio*p/24,_=t.tilePixelRatio*m.get("symbol-spacing"),b=m.get("text-padding")*t.tilePixelRatio,x=m.get("icon-padding")*t.tilePixelRatio,w=$(m.get("text-max-angle")),k="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),E="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),T=m.get("symbol-placement"),S=_/2,C=m.get("icon-text-fit");let M;r&&"none"!==C&&(t.allowVerticalPlacement&&i.vertical&&(M=od(r,i.vertical,C,m.get("icon-text-fit-padding"),f,v)),g&&(r=od(r,g,C,m.get("icon-text-fit-padding"),f,v)));const z=(a,s,p)=>{if(s.x<0||s.x>=Is||s.y<0||s.y>=Is)return;const{x:m,y:g,z:v}=h.projectTilePoint(s.x,s.y,p),y=new ad(m,g,v,0,void 0);!function(t,e,i,r,n,o,a,s,l,c,u,d,h,p,m,f,g,v,y,_,b,x,w,k,E){const T=t.addToLineVertexArray(e,r);let S,C,M,z,I,P,A,D=0,O=0,L=0,R=0,B=-1,F=-1;const j={};let N=Qa(""),V=0,U=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[V,U]=l.layout.get("text-offset").evaluate(b,{},E).map((t=>t*au)):(V=l.layout.get("text-radial-offset").evaluate(b,{},E)*au,U=Pd),t.allowVerticalPlacement&&n.vertical){const t=n.vertical;if(m)P=Vd(t),s&&(A=Vd(s));else{const r=l.layout.get("text-rotate").evaluate(b,{},E)+90;M=Nd(c,i,e,u,d,h,t,p,r,f),s&&(z=Nd(c,i,e,u,d,h,s,v,r))}}if(o){const r=l.layout.get("icon-rotate").evaluate(b,{},E),n="none"!==l.layout.get("icon-text-fit"),a=bd(o,r,w,n),p=s?bd(s,r,w,n):void 0;C=Nd(c,i,e,u,d,h,o,v,r),D=4*a.length;const m=t.iconSizeData;let f=null;"source"===m.kind?(f=[su*l.layout.get("icon-size").evaluate(b,{},E)],f[0]>Bd&&pt(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===m.kind&&(f=[su*x.compositeIconSizes[0].evaluate(b,{},E),su*x.compositeIconSizes[1].evaluate(b,{},E)],(f[0]>Bd||f[1]>Bd)&&pt(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,a,f,_,y,b,!1,i,e,T.lineStartIndex,T.lineLength,-1,k,E),B=t.icon.placedSymbolArray.length-1,p&&(O=4*p.length,t.addSymbols(t.icon,p,f,_,y,b,$u.vertical,i,e,T.lineStartIndex,T.lineLength,-1,k,E),F=t.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=n.horizontal[r];S||(N=Qa(o.text),m?I=Vd(o):S=Nd(c,i,e,u,d,h,o,p,l.layout.get("text-rotate").evaluate(b,{},E),f));const s=1===o.positionedLines.length;if(L+=Fd(t,i,e,o,a,l,m,b,f,T,n.vertical?$u.horizontal:$u.horizontalOnly,s?Object.keys(n.horizontal):[r],j,B,x,k,E),s)break}n.vertical&&(R+=Fd(t,i,e,n.vertical,a,l,m,b,f,T,$u.vertical,["vertical"],j,F,x,k,E));let Z=-1;const $=(t,e)=>t?Math.max(t,e):e;Z=$(I,Z),Z=$(P,Z),Z=$(A,Z);const G=Z>-1?1:0;t.glyphOffsetArray.length>=Yd.MAX_GLYPHS&&pt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey),t.symbolInstances.emplaceBack(i.x,i.y,i.z,e.x,e.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,B,F,N,void 0!==S?S:t.collisionBoxArray.length,void 0!==S?S+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,void 0!==C?C:t.collisionBoxArray.length,void 0!==C?C+1:t.collisionBoxArray.length,z||t.collisionBoxArray.length,z?z+1:t.collisionBoxArray.length,u,L,R,D,O,G,0,V,U,Z)}(t,s,y,a,i,r,n,M,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,b,k,l,0,x,E,f,e,o,c,u,d)};if("line"===T)for(const n of md(e.geometry,0,0,Is,Is)){const e=hd(n,_,w,i.vertical||g,r,24,y,t.overscaling,Is);for(const i of e){const e=g;e&&Ud(t,e.text,S,i)||z(n,i,d)}}else if("line-center"===T){for(const t of e.geometry)if(t.length>1){const e=dd(t,w,i.vertical||g,r,24,y);e&&z(t,e,d)}}else if("Polygon"===e.type)for(const t of pc(e.geometry,0)){const e=Md(t,16);z(t[0],new ad(e.x,e.y,0,0,void 0),d)}else if("LineString"===e.type)for(const t of e.geometry)z(t,new ad(t[0].x,t[0].y,0,0,void 0),d);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)z([e],new ad(e.x,e.y,0,0,void 0),d)}const Bd=32640;function Fd(t,e,i,r,n,a,s,l,c,u,d,h,p,m,f,g,v){const y=function(t,e,i,r,n,a,s,l){const c=[];if(0===e.positionedLines.length)return c;const u=r.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],r=e*i;return r>0?[e,-i]:r<0?[-e,i]:0===e?[i,e]:[i,-e]}(i);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,m=h/p;let f=e.top-i[1];for(let t=0;tBd&&pt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(b=[su*f.compositeTextSizes[0].evaluate(l,{},v),su*f.compositeTextSizes[1].evaluate(l,{},v)],(b[0]>Bd||b[1]>Bd)&&pt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,y,b,c,s,l,d,e,i,u.lineStartIndex,u.lineLength,m,g,v);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function jd(t){for(const e in t)return t[e];return null}function Nd(t,e,i,r,n,a,s,l,c,u){let d=s.top,h=s.bottom,p=s.left,m=s.right;const f=s.collisionPadding;if(f&&(p-=f[0],d-=f[1],m+=f[2],h+=f[3]),c){const t=new o(p,d),e=new o(m,d),i=new o(p,h),r=new o(m,h),n=$(c);let a=new o(0,0);u&&(a=new o(u[0],u[1])),t._rotateAround(n,a),e._rotateAround(n,a),i._rotateAround(n,a),r._rotateAround(n,a),p=Math.min(t.x,e.x,i.x,r.x),m=Math.max(t.x,e.x,i.x,r.x),d=Math.min(t.y,e.y,i.y,r.y),h=Math.max(t.y,e.y,i.y,r.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,p,d,m,h,l,r,n,a),t.length-1}function Vd(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 Ud(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=d([]),this.placementViewportMatrix=d([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=lu(this.zoom,e["text-size"]),this.iconSizeData=lu(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=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"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>$u[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Hd(new _s(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Hd(new _s(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Za,this.lineVertexArray=new $a,this.symbolInstances=new Ua}calculateGlyphDependencies(t,e,i,r,n){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const h=e.iconDependencies,p=e.glyphDependencies,m=e.availableImages,f=new Wo(this.zoom);for(const{feature:e,id:s,index:l,sourceLayerIndex:g}of t){const t=n._featureFilter.needGeometry,v=Ys(e,t);if(!n._featureFilter.filter(f,v,i))continue;let y,_;if(t||(v.geometry=Xs(e,i,r)),c){const t=n.getValueAndResolveTokens("text-field",v,i,m),e=Xe.factory(t);Wd(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===$o()||this.hasRTLText&&qo.isParsed())&&(y=hu(e,n,v))}if(u){const t=n.getValueAndResolveTokens("icon-image",v,i,m);_=t instanceof Ye?t:Ye.fromString(t)}if(!y&&!_)continue;const b=this.sortFeaturesByKey?d.evaluate(v,{},i):void 0;if(this.features.push({id:s,text:y,icon:_,index:l,sourceLayerIndex:g,geometry:v.geometry,properties:e.properties,type:Zd[e.type],sortKey:b}),_&&(h[_.name]=!0),y){const t=a.evaluate(v,{},i).join(","),e="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf($u.vertical)>=0;for(const i of y.sections)if(i.image)h[i.image.name]=!0;else{const r=Co(y.toString()),n=i.fontStack||t,o=p[n]=p[n]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function o(e){r.push(t[e]),n++}function a(t,e,n){const o=i[t];return delete i[t],i[e]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function s(t,i,n){const o=e[i];return delete e[i],e[t]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i,r))}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.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const n={};for(let r=t.segment+1;r=0;i--)n[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),o=cu(this.textSizeData,t,n)/au;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),n=cu(this.iconSizeData,t,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,n,o){for(let a=r;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;er[t]-r[e]||n[e]-n[t])),o}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),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Wn("SymbolBucket",Yd,{omit:["layers","collisionBoxArray","features","compareText"]}),Yd.MAX_GLYPHS=65535,Yd.addDynamicAttributes=qd;const Kd=new sa({"symbol-placement":new ia(be.layout_symbol["symbol-placement"]),"symbol-spacing":new ia(be.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ia(be.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ra(be.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ia(be.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ia(be.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new ia(be.layout_symbol["icon-ignore-placement"]),"icon-optional":new ia(be.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ia(be.layout_symbol["icon-rotation-alignment"]),"icon-size":new ra(be.layout_symbol["icon-size"]),"icon-text-fit":new ia(be.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ia(be.layout_symbol["icon-text-fit-padding"]),"icon-image":new ra(be.layout_symbol["icon-image"]),"icon-rotate":new ra(be.layout_symbol["icon-rotate"]),"icon-padding":new ia(be.layout_symbol["icon-padding"]),"icon-keep-upright":new ia(be.layout_symbol["icon-keep-upright"]),"icon-offset":new ra(be.layout_symbol["icon-offset"]),"icon-anchor":new ra(be.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ia(be.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ia(be.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ia(be.layout_symbol["text-rotation-alignment"]),"text-field":new ra(be.layout_symbol["text-field"]),"text-font":new ra(be.layout_symbol["text-font"]),"text-size":new ra(be.layout_symbol["text-size"]),"text-max-width":new ra(be.layout_symbol["text-max-width"]),"text-line-height":new ra(be.layout_symbol["text-line-height"]),"text-letter-spacing":new ra(be.layout_symbol["text-letter-spacing"]),"text-justify":new ra(be.layout_symbol["text-justify"]),"text-radial-offset":new ra(be.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ia(be.layout_symbol["text-variable-anchor"]),"text-anchor":new ra(be.layout_symbol["text-anchor"]),"text-max-angle":new ia(be.layout_symbol["text-max-angle"]),"text-writing-mode":new ia(be.layout_symbol["text-writing-mode"]),"text-rotate":new ra(be.layout_symbol["text-rotate"]),"text-padding":new ia(be.layout_symbol["text-padding"]),"text-keep-upright":new ia(be.layout_symbol["text-keep-upright"]),"text-transform":new ra(be.layout_symbol["text-transform"]),"text-offset":new ra(be.layout_symbol["text-offset"]),"text-allow-overlap":new ia(be.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new ia(be.layout_symbol["text-ignore-placement"]),"text-optional":new ia(be.layout_symbol["text-optional"])});var Jd={paint:new sa({"icon-opacity":new ra(be.paint_symbol["icon-opacity"]),"icon-color":new ra(be.paint_symbol["icon-color"]),"icon-halo-color":new ra(be.paint_symbol["icon-halo-color"]),"icon-halo-width":new ra(be.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ra(be.paint_symbol["icon-halo-blur"]),"icon-translate":new ia(be.paint_symbol["icon-translate"]),"icon-translate-anchor":new ia(be.paint_symbol["icon-translate-anchor"]),"text-opacity":new ra(be.paint_symbol["text-opacity"]),"text-color":new ra(be.paint_symbol["text-color"],{runtimeType:Ae,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ra(be.paint_symbol["text-halo-color"]),"text-halo-width":new ra(be.paint_symbol["text-halo-width"]),"text-halo-blur":new ra(be.paint_symbol["text-halo-blur"]),"text-translate":new ia(be.paint_symbol["text-translate"]),"text-translate-anchor":new ia(be.paint_symbol["text-translate-anchor"])}),layout:Kd};class Qd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Me,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}}Wn("FormatSectionOverride",Qd,{omit:["defaultValue"]});class th extends Ss{constructor(t){super(t,Jd)}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)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||$r(o.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Yd(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Jd.paint.overridableProperties){if(!th.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Qd(e),r=new Zr(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new qr("source",r):new Wr("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new ta(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&th.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Jd.paint.properties[e];let n=!1;const o=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Xe)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof ei&&Qe(e.value)===Re?o(e.value.sections):e instanceof oi?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}getProgramConfiguration(t){return new ys(this,t)}}var eh={paint:new sa({"background-color":new ia(be.paint_background["background-color"]),"background-pattern":new oa(be.paint_background["background-pattern"]),"background-opacity":new ia(be.paint_background["background-opacity"])})},ih={paint:new sa({"raster-opacity":new ia(be.paint_raster["raster-opacity"]),"raster-hue-rotate":new ia(be.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ia(be.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ia(be.paint_raster["raster-brightness-max"]),"raster-saturation":new ia(be.paint_raster["raster-saturation"]),"raster-contrast":new ia(be.paint_raster["raster-contrast"]),"raster-resampling":new ia(be.paint_raster["raster-resampling"]),"raster-fade-duration":new ia(be.paint_raster["raster-fade-duration"])})};class rh extends Ss{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var nh={paint:new sa({"sky-type":new ia(be.paint_sky["sky-type"]),"sky-atmosphere-sun":new ia(be.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new ia(be.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new ia(be.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new ia(be.paint_sky["sky-gradient-radius"]),"sky-gradient":new aa(be.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new ia(be.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new ia(be.paint_sky["sky-atmosphere-color"]),"sky-opacity":new ia(be.paint_sky["sky-opacity"])})};function oh(t,e,i){const r=x(0,0,1),n=j(F());return function(t,e,i){i*=.5;var r=e[0],n=e[1],o=e[2],a=e[3],s=Math.sin(i),l=Math.cos(i);t[0]=r*l-o*s,t[1]=n*l+a*s,t[2]=o*l+r*s,t[3]=a*l-n*s}(n,n,i?-$(t)+Math.PI:$(t)),N(n,n,-$(e)),A(r,r,n),M(r,r)}const ah={circle:class extends Ss{constructor(t){super(t,gl)}createBucket(t){return new Js(t)}queryRadius(t){const e=t;return dl("circle-radius",this,e)+dl("circle-stroke-width",this,e)+hl(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,o,a,s){const l=ml(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return _l(t,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new ys(this,t)}},heatmap:class extends Ss{createBucket(t){return new El(t)}constructor(t){super(t,Il),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Pl({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return dl("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,n,a,s,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return _l(t,r,a,s,l,!0,!0,new o(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new ys(this,t)}},hillshade:class extends Ss{constructor(t){super(t,Al)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(t){return new ys(this,t)}},fill:class extends Ss{constructor(t){super(t,_c)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new ys(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new vc(t)}queryRadius(){return hl(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,o){return!t.queryGeometry.isAboveHorizon&&el(pl(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Ss{constructor(t){super(t,Fc)}createBucket(t){return new Rc(t)}queryRadius(){return hl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new ys(this,t)}queryIntersectsFeature(t,e,i,r,n,a,s,l,c){const u=ml(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,t.pixelToTileUnitsFactor),d=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),p=[0,0],m=l&&a.elevation,f=a.elevation?a.elevation.exaggeration():1;if(m){const e=t.tile.getBucket(this).centroidVertexArray,i=c+1;if(i=3)for(let e=0;e1&&(a=t[++o]);const l=Math.abs(s-a.left),c=Math.abs(s-a.right),u=Math.min(l,c);let d;const h=e/i*(r+1);if(a.isDash){const t=r-Math.abs(h);d=Math.sqrt(u*u+t*t)}else d=r-Math.sqrt(u*u+h*h);this.image.data[n+s]=Math.max(0,Math.min(255,d+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,a=t[o];for(let i=0;i1&&(a=t[++o]);const r=Math.abs(i-a.left),s=Math.abs(i-a.right),l=Math.min(r,s);this.image.data[n+i]=Math.max(0,Math.min(255,(a.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return pt("LineAtlas out of space"),null;0===t.length&&t.push(1);let a=0;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(){delete this._channel,this._callback=()=>{}}}const fh=s.performance;function gh(t){const e=t?t.url.toString():void 0;return fh.getEntriesByName(e)}class vh{constructor(){this.tasks={},this.taskQueue=[],st(["process"],this),this.invoker=new mh(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=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===r){gt();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){gt();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;i0;o--)r=1<this.canonical.z?new xh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new xh(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 wh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return wh(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 xh(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,r=2*this.canonical.y;return[new xh(e,this.wrap,e,i,r),new xh(e,this.wrap,e,i+1,r),new xh(e,this.wrap,e,i,r+1),new xh(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ye[a])return null}else{const s=1/r[a];let l=(t[a]-i[a])*s,c=(e[a]-i[a])*s;if(l>c){const t=l;l=c,c=t}if(l>n&&(n=l),co)return null}return n}function Lh(t,e,i,r,n,o,a,s,l,c,u){const d=r-t,h=n-e,p=o-i,m=a-t,f=s-e,g=l-i,v=u[1]*g-u[2]*f,y=u[2]*m-u[0]*g,_=u[0]*f-u[1]*m,b=d*v+h*y+p*_;if(Math.abs(b)<1e-15)return null;const x=1/b,w=c[0]-t,k=c[1]-e,E=c[2]-i,T=(w*v+k*y+E*_)*x;if(T<0||T>1)return null;const S=k*p-E*h,C=E*d-w*p,M=w*h-k*d,z=(u[0]*S+u[1]*C+u[2]*M)*x;return z<0||T+z>1?null:(m*S+f*C+g*M)*x}function Rh(t,e,i){return(t-e)/(i-e)}function Bh(t,e,i,r,n,o,a,s,l){const c=1<{const o=r?1:0,a=(t+1)*i-o,s=e*i,l=(e+1)*i-o;n[0]=t*i,n[1]=s,n[2]=a,n[3]=l};let a=new Dh(r);const s=[];for(let e=0;e=1;r/=2){const t=i[i.length-1];a=new Dh(r);for(let e=0;e0;){const{idx:s,t:p,nodex:m,nodey:f,depth:g}=h.pop();if(this.leaves[s]){Bh(m,f,g,t,e,i,r,u,d);const s=1<=t[2])return p}continue}let v=0;for(let h=0;h=l[c[i]]&&(c.splice(i,0,h),e=!0);e||(c[v]=h),v++}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=Uh.getUnpackVector(e);let n=Math.floor((t+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new zl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,o=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=a-1;break;case 1:a=o+1}const s=-e*this.dim,l=-i*this.dim;for(let e=o;e{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class $h extends _e{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Zh(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ah}onAdd(t){this.map=t,this._minTileCacheSize=t?t._minTileCacheSize:null,this._maxTileCacheSize=t?t._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return tt(this._tiles).map((t=>t.tileID)).sort(Gh).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,n=new o(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),a=new o(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||a.y-n.y||a.x-n.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Gh).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new ye(r,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=Et.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new ve("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(a=t)}let s=a;for(;s.overscaledZ>e;)if(s=s.scaledTo(s.overscaledZ-1),t[s.key]){r[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new xh(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=this._updateRetainedTiles(r);if(qh(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(n);for(const r of i){const i=n[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=Et.now())continue;const a=this.findLoadedParent(i,Math.max(i.overscaledZ-$h.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),e[r]=i}const o=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(n[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&e[r.key]){n[t]=i.tileID;break}}}for(const e in t)n[e]||(this._coveredTiles[e]=!0,n[e]=t[e])}for(const t in n)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,n);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),n=t[0].overscaledZ,o=Math.max(n-$h.maxOverzooming,this._source.minzoom),a=Math.max(n+$h.maxUnderzooming,this._source.minzoom),s={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let n=t.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&n&&(t=this._addTile(o)),t&&(e[o.key]=o,n=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null,r="raster"===this._source.type||"raster-dem"===this._source.type;e=new sp(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,r),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new ve("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(t,e,i){const r=[],n=this.transform;if(!n)return r;for(const o in this._tiles){const a=this._tiles[o];if(i&&a.clearQueryDebugViz(),a.holdingForFade())continue;const s=t.containsTile(a,n,e);s&&r.push(s)}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(qh(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=Et.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){const i=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const t of r){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}const a=Array.from(i.values()),s="raster"===this._source.type||"raster-dem"===this._source.type;Q(a,((t,e)=>{const i=new sp(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,s);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Gh(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function qh(t){return"raster"===t||"image"===t||"video"===t}$h.maxOverzooming=10,$h.maxUnderzooming=3;class Wh{constructor(t,e,i){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=i}static create(t,e,i){const r=i||t.findDEMTileFor(e);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,a=1<=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Pc.VectorTile(new yu(this.rawTileData)).layers,this.sourceLayerCoder=new Ih(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,r){this.loadVTLayers();const n=t.params||{},o=an(n.filter),a=t.tileResult,s=t.transform,l=a.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>cl(a.bufferedTilespaceGeometry,t,e,i,r)));c.sort(Yh);let u=null;s.elevation&&c.length>0&&(u=Wh.create(s.elevation,this.tileID));const d={};let h;for(let s=0;s(m||(m=Xs(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(a,e,r,m,this.z,t.transform,t.pixelPosMatrix,u,n))))}return d}loadMatchingFeature(t,e,i,r,n,o,a,s,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:d,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[u];if(r&&!function(t,e){for(let i=0;i=0)return!0;return!1}(r,p))return;const m=this.sourceLayerCoder.decode(d),f=this.vtLayers[m].feature(c);if(i.needGeometry){const t=Ys(f,!0);if(!i.filter(new Wo(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Wo(this.tileID.overscaledZ),f))return;const g=this.getId(f,m);for(let e=0;e{const a=e instanceof ea?e.get(o):null;return a&&a.evaluate?a.evaluate(i,r,n):a}))}function Yh(t,e){return e-t}Wn("FeatureIndex",Hh,{omit:["rawTileData","sourceLayerCoder"]});var Kh=ha([{name:"a_pos",type:"Int16",components:2}]);const Jh=32,Qh=33,tp=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,i=0,r=0,n=0,o=0,a=0,s=0;for(1&e?n=o=a=Jh:i=r=s=Jh;(e>>=1)>1;){const t=i+n>>1,l=r+o>>1;1&e?(n=i,o=r,i=a,r=s):(i=n,r=o,n=a,o=s),a=t,s=l}const l=4*t;tp[l+0]=i,tp[l+1]=r,tp[l+2]=n,tp[l+3]=o}const ep=new Uint16Array(2178),ip=new Uint8Array(1089),rp=new Uint16Array(1089);function np(t){return 0===t?-.03125:32===t?.03125:0}var op=ha([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const ap={type:2,extent:Is,loadGeometry:()=>[[new o(0,0),new o(8193,0),new o(8193,8193),new o(0,8193),new o(0,0)]]};class sp{constructor(t,e,i,r,n){this.tileID=t,this.uid=rt(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Yd){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Yd&&e.hasRTLText){this.hasRTLText=!0,qo.isLoading()||qo.isLoaded()||"deferred"!==$o()||Go();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new Fa}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new hh(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new hh(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new hh(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:n,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=e?e.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const a=an(e&&e.filter),{z:s,x:l,y:c}=this.tileID.canonical,u={z:s,x:l,y:c};for(let e=0;et)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=tp[e+0],r=tp[e+1],n=tp[e+2],o=tp[e+3],a=i+n>>1,s=r+o>>1,l=a+s-r,c=s+i-a,u=r*Qh+i,d=o*Qh+n,h=s*Qh+a,p=Math.hypot((ep[2*u+0]+ep[2*d+0])/2-ep[2*h+0],(ep[2*u+1]+ep[2*d+1])/2-ep[2*h+1])>=16;if(ip[h]=ip[h]||(p?1:0),t<1022){const t=(r+c>>1)*Qh+(i+l>>1),e=(o+c>>1)*Qh+(n+l>>1);ip[h]=ip[h]||ip[t]||ip[e]}}const n=new fa,o=new Sa;let a=0;function s(t,e){const i=e*Qh+t;return 0===rp[i]&&(n.emplaceBack(ep[2*i+0],ep[2*i+1],t*Is/Jh,e*Is/Jh),rp[i]=++a),rp[i]-1}function l(t,e,i,r,n,a){const c=t+i>>1,u=e+r>>1;if(Math.abs(t-n)+Math.abs(e-a)>1&&ip[u*Qh+c])l(n,a,t,e,c,u),l(i,r,n,a,c,u);else{const l=s(t,e),c=s(i,r),u=s(n,a);o.emplaceBack(l,c,u)}}return l(0,0,Jh,Jh,Jh,0),l(Jh,Jh,0,0,0,Jh),{vertices:n,indices:o}}(this.tileID.canonical,e);r=t.vertices,n=t.indices}else{r=new fa,n=new Sa;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=Ll(r.int16,void 0,4);for(let e=0;et*(1-i)+e*i,[r,n]=vp(t),o=new Pa,a=function(t){const e=d(new Float64Array(16)),i=bp(t);var r,n;return m(e,e,[i,i,i]),p(e,e,((r=[])[0]=-(n=t.min)[0],r[1]=-n[1],r[2]=-n[2],r)),e}(gp(t));o.reserve(4096);for(let s=0;s<65;s++){const l=i(r[0],n[0],s/64),c=Bs(l),u=c*e-t.y,d=Math.sin($(l)),h=Math.cos($(l));for(let t=0;t<65;t++){const e=t/64,s=i(r[1],n[1],e),l=yp(h,d,s);P(l,l,a);const p=Rs(s);o.emplaceBack(l[0],l[1],l[2],p,c,e,u)}}return o}_createGridIndices(){const t=new Sa,e=(e,i)=>{const r=65*i+e;t.emplaceBack(r+1,r,r+65),t.emplaceBack(r+65,r+65+1,r+1)};for(let t=0;t<64;t++)for(let i=0;i<64;i++)e(i,t);return t}getWirefameBuffer(t){if(!this.wireframeSegments){const e=this._createWireframeGrid();this.wireframeIndexBuffer=t.createIndexBuffer(e),this.wireframeSegments=zs.simpleSegment(0,0,4096,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const t=new Da,e=(e,i)=>{const r=65*i+e;t.emplaceBack(r,r+1),t.emplaceBack(r,r+65),t.emplaceBack(r,r+65+1)};for(let t=0;t<64;t++)for(let i=0;i<64;i++)e(i,t);return t}}function Ep(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<_&&(b(t,c,r,n,s,l),b(c,i,s,l,o,a))}b(d,h,r,o,n,o),b(h,p,n,o,n,a),b(p,m,n,a,r,a),b(m,d,r,a,r,o),f-=_,g-=_,v+=_,y+=_;const x=1/Math.max(v-f,y-g);return{scale:x,x:f*x,y:g*x,x2:v*x,y2:y*x,projection:e}}class Tp{constructor(t){const e={},i=[];for(const r in t){const n=t[r],o=e[r]={};for(const t in n.glyphs){const e=n.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,a={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(a),o[t]=a}}const{w:r,h:n}=Vu(i),o=new Ml({width:r||1,height:n||1});for(const i in t){const r=t[i];for(const t in r.glyphs){const n=r.glyphs[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=e[i][t],s=n.metrics.localGlyph?2:1;Ml.copy(n.bitmap,o,{x:0,y:0},{x:a.x+s,y:a.y+s},n.bitmap)}}this.image=o,this.positions=e}}Wn("GlyphAtlas",Tp);class Sp{constructor(t){this.tileID=new xh(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=Ep(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,e,i,r,n){this.status="parsing",this.data=t,this.collisionBoxArray=new Fa;const o=new Ih(Object.keys(t.layers).sort()),a=new Hh(this.tileID,this.promoteId);a.bucketLayerIDs=[];const s={},l=new ph(256,256),c={featureIndex:a,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=e.familiesBySource[this.source];for(const e in u){const r=t.layers[e];if(!r)continue;let n=!1,l=!1;for(const t of u[e])"symbol"===t[0].type?n=!0:l=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&pt(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=o.encode(e),h=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(Cp(t,this.zoom,i),(s[e.id]=e.createBucket({index:a.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:i})).populate(h,c,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(t.map((t=>t.id))))}}let d,h,p,m;l.trim();const f={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=ct(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(g).length?r.send("getGlyphs",{uid:this.uid,stacks:g},((t,e)=>{d||(d=t,h=e,_.call(this))}),void 0,!1,f):h={};const v=Object.keys(c.iconDependencies);v.length?r.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{d||(d=t,p=e,_.call(this))}),void 0,!1,f):p={};const y=Object.keys(c.patternDependencies);function _(){if(d)return n(d);if(h&&p&&m){const t=new Tp(h),e=new Zu(p,m);for(const r in s){const n=s[r];n instanceof Yd?(Cp(n.layers,this.zoom,i),Od(n,h,t.positions,p,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection),n.projection=this.projection.name):n.hasPattern&&(n instanceof Xc||n instanceof vc||n instanceof Rc)&&(Cp(n.layers,this.zoom,i),n.addFeatures(c,this.tileID.canonical,e.patternPositions,i))}this.status="done",n(null,{buckets:tt(s).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?h:null,iconMap:this.returnDependencies?p:null,glyphPositions:this.returnDependencies?t.positions:null})}}y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{d||(d=t,m=e,_.call(this))}),void 0,!1,f):m={},_.call(this)}}function Cp(t,e,i){const r=new Wo(e);for(const e of t)e.recalculate(r,i)}class Mp{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const n=this.entries[t]=this.entries[t]||{callbacks:[]};if(n.result){const[t,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const t of n.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((t=>t!==r)),n.callbacks.length||(n.cancel(),delete this.entries[t]))}}}function zp(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const r=se(t.request,((t,r,n,o)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new Pc.VectorTile(new yu(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),e()}}),e)}const Ip=d(new Float64Array(16));class Pp{constructor(t,e){this._tr=t,this._worldSize=e}createInversionMatrix(){return Ip}createTileMatrix(t){let e,i,r;const n=t.canonical,o=d(new Float64Array(16)),a=this._tr.projection;if(a.isReprojectedInTileSpace){const s=Ep(n,a);e=1,i=s.x+t.wrap*s.scale,r=s.y,m(o,o,[e/s.scale,e/s.scale,this._tr.pixelsPerMeter/this._worldSize])}else e=this._worldSize/this._tr.zoomScale(n.z),i=(n.x+Math.pow(2,n.z)*t.wrap)*e,r=n.y*e;return p(o,o,[i,r,0]),m(o,o,[e/Is,e/Is,1]),o}pointCoordinate(t,e,i){const r=this._tr.horizonLineFromTop(!1),n=new o(t,Math.max(r,e));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(n,i))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var Ap={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const t=Math.sin($(this.parallels[0])),e=(t+Math.sin($(this.parallels[1])))/2,i=1+t*(2*e-t),r=Math.sqrt(i)/e;this.constants={n:e,c:i,r0:r,parallels:this.parallels}},project(t,e){this.initializeConstants();const i=$(t-this.center[0]),r=$(e),{n,c:o,r0:a}=this.constants,s=Math.sqrt(o-2*n*Math.sin(r))/n;return{x:s*Math.sin(i*n),y:s*Math.cos(i*n)-a,z:0}},unproject(t,e){this.initializeConstants();const{n:i,c:r,r0:n}=this.constants,o=n+e;let a=Math.atan2(t,Math.abs(o))*Math.sign(o);o*i<0&&(a-=Math.PI*Math.sign(t)*Math.sign(o));const s=$(this.center[0])*i;a=J(a,-Math.PI-s,Math.PI-s);const l=G(a/i)+this.center[0],c=Math.asin(Y((r-(t*t+o*o)*i*i)/(2*i),-1,1)),u=Y(G(c),-85.051129,Us);return new Ds(l,u)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)};const Dp=1.340264,Op=-.081106,Lp=893e-6,Rp=.003796,Bp=Math.sqrt(3)/2;var Fp={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const i=Math.asin(Bp*Math.sin(e)),r=i*i,n=r*r*r;return{x:.5*(t*Math.cos(i)/(Bp*(Dp+3*Op*r+n*(7*Lp+9*Rp*r)))/Math.PI+.5),y:1-.5*(i*(Dp+Op*r+n*(Lp+Rp*r))/Math.PI+1),z:0}},unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=i*i,n=r*r*r;for(let t,o,a,s=0;s<12&&(o=i*(Dp+Op*r+n*(Lp+Rp*r))-e,a=Dp+3*Op*r+n*(7*Lp+9*Rp*r),t=o/a,i=Y(i-t,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(t)<1e-12));++s);const o=Bp*t*(Dp+3*Op*r+n*(7*Lp+9*Rp*r))/Math.cos(i),a=Math.asin(Math.sin(i)/Bp),s=Y(180*o/Math.PI,-180,180),l=Y(180*a/Math.PI,-85.051129,Us);return new Ds(s,l)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)},jp={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(t,e)=>({x:.5+t/360,y:.5-e/360,z:0}),unproject(t,e){const i=360*(t-.5),r=Y(360*(.5-e),-85.051129,Us);return new Ds(i,r)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)};const Np=Math.PI/2;function Vp(t){return Math.tan((Np+t)/2)}var Up={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const t=$(this.parallels[0]),e=$(this.parallels[1]),i=Math.cos(t),r=t===e?Math.sin(t):Math.log(i/Math.cos(e))/Math.log(Vp(e)/Vp(t)),n=i*Math.pow(Vp(t),r)/r;this.constants={n:r,f:n,parallels:this.parallels}},project(t,e){this.initializeConstants(),e=$(e),t=$(t-this.center[0]);const i=1e-6,{n:r,f:n}=this.constants;n>0?e<-Np+i&&(e=-Np+i):e>Np-i&&(e=Np-i);const o=n/Math.pow(Vp(e),r),a=o*Math.sin(r*t),s=n-o*Math.cos(r*t);return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+.5),z:0}},unproject(t,e){this.initializeConstants(),t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:r}=this.constants,n=r-e,o=Math.sign(n),a=Math.sign(i)*Math.sqrt(t*t+n*n);let s=Math.atan2(t,Math.abs(n))*o;n*i<0&&(s-=Math.PI*Math.sign(t)*o);const l=Y(G(s/i)+this.center[0],-180,180),c=Y(G(2*Math.atan(Math.pow(r/a,1/i))-Np),-85.051129,Us);return new Ds(l,c)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)},Zp={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(t,e)=>({x:Rs(t),y:Bs(e),z:0}),unproject(t,e){const i=js(t),r=Ns(e);return new Ds(i,r)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)};const $p=$(Us);var Gp={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(t,e){const i=(e=$(e))*e,r=i*i;return{x:.5*((t=$(t))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}},unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const t=o*o;n=(i*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-e)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),i=Y(i-n,-$p,$p)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const a=Y(G(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=G(i);return new Ds(a,s)},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)};const qp=$(Us),Wp={albers:Ap,equalEarth:Fp,equirectangular:jp,lambertConformalConic:Up,mercator:Zp,naturalEarth:Gp,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(t,e){e=$(e),t=$(t);const i=Math.cos(e),r=2/Math.PI,n=Math.acos(i*Math.cos(t/2)),o=Math.sin(n)/n,a=.5*(t*r+2*i*Math.sin(t/2)/o)||0,s=.5*(e+Math.sin(e)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}},unproject(t,e){let i=t=(2*t-.5)*Math.PI,r=e=(2*(1-e)-1)*Math.PI,n=25;const o=1e-6;let a=0,s=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,d=Math.cos(i/2),h=Math.sin(i/2),p=2*d*h,m=h*h,f=1-u*d*d,g=f?1/f:0,v=f?Math.acos(n*d)*Math.sqrt(1/f):0,y=.5*(2*v*n*h+2*i/Math.PI)-t,_=.5*(v*o+r)-e,b=.5*g*(u*m+v*n*d*c)+1/Math.PI,x=g*(p*l/4-v*o*h),w=.125*g*(l*h-v*o*u*p),k=.5*g*(c*d+v*m*n)+.5,E=x*w-k*b;a=(_*x-y*k)/E,s=(y*w-_*b)/E,i=Y(i-a,-Math.PI,Math.PI),r=Y(r-s,-qp,qp)}while((Math.abs(a)>o||Math.abs(s)>o)&&--n>0);return new Ds(G(i),G(r))},projectTilePoint:(t,e)=>({x:t,y:e,z:0}),locationPoint:(t,e)=>t._coordinatePoint(t.locationCoordinate(e),!1),pixelsPerMeter:(t,e)=>Fs(1,t)*e,farthestPixelDistance(t){return dp(t,this.pixelsPerMeter(t.center.lat,t.worldSize))},createTileTransform:(t,e)=>new Pp(t,e)}};t.ARRAY_TYPE=c,t.AUTH_ERR_MSG=Ot,t.Aabb=yl,t.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},st(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=gt()?t:s,this.scheduler=new vh}send(t,e,i,r,n=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[a]=i);const s=wt(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Yn(e,s)},s),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,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||gt()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Kn(e.error)):i(null,Kn(e.data)))}else{const i=wt(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Yn(e):null,data:Yn(r,i)},i)}:t=>{},n=Kn(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,n,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],n.source)[t[1]](n,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=_h,t.Color=qe,t.ColorMode=Sh,t.CullFaceMode=zh,t.DEMData=Uh,t.DataConstantProperty=ia,t.DedupedRequest=Mp,t.DepthMode=kh,t.EXTENT=Is,t.Elevation=class{getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){null==e&&(e=null);const r=this._source();if(!r)return e;if(t.y<0||t.y>1)return e;const n=r.getSource().maxzoom,o=1<{const r=this.getAtTileOffset(t,i.x,i.y),n=e.upVector(t.canonical,i.x,i.y);return S(n,n,r*e.upVectorScale(t.canonical)),n}}getForTilePoints(t,e,i,r){const n=Wh.create(this,t,r);return!!n&&(e.forEach((t=>{t[2]=this.exaggeration()*n.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,n=1<this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!Lt(t))return t;const i=Ft(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!Lt(t))return t;const i=Ft(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e){if(!Lt(t))return t;const i=Ft(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const n=Ft(t);return Lt(t)?(n.path=`/styles/v1${n.path}/sprite${e}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${e}${i}`,jt(n))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!Lt(t))return t;const r=Ft(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${Ct.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${St.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${St.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||St.ACCESS_TOKEN;return St.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,e){const i=Ft(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${St.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${St.TILE_URL_VERSION}/`,"")}`;let n=i.params;return e&&(n=n.filter((t=>!t.match(/^access_token=/)))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&Lt(e),r=[];for(const e of t.tiles||[])Rt(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=Ft(St.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!St.REQUIRE_ACCESS_TOKEN)return jt(t);if(e=e||St.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),jt(t)}},t.ResourceType=re,t.SegmentVector=zs,t.SourceCache=$h,t.StencilMode=Th,t.StructArrayLayout1ui2=Oa,t.StructArrayLayout2f1f2i16=Ea,t.StructArrayLayout2i4=ma,t.StructArrayLayout2ui4=Da,t.StructArrayLayout3f12=va,t.StructArrayLayout3ui6=Sa,t.StructArrayLayout4i8=fa,t.Texture=hh,t.Tile=sp,t.Transitionable=Yo,t.Uniform1f=as,t.Uniform1i=class extends os{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends os{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends os{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=ss,t.UniformColor=ls,t.UniformMatrix2f=class extends os{constructor(t,e){super(t,e),this.current=ds}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}},t.UniformMatrix3f=class extends os{constructor(t,e){super(t,e),this.current=us}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},t.UniformMatrix4f=class extends os{constructor(t,e){super(t,e),this.current=cs}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=bh,t.ValidationError=xe,t.VectorTileWorkerSource=class extends _e{constructor(t,e,i,r,n){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=n||zp,this.loading={},this.loaded={},this.deduped=new Mp(t.scheduler),this.isSpriteLoaded=r,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,r=t&&t.request,n=r&&r.collectResourceTiming,o=this.loading[i]=new Sp(t);o.abort=this.loadVectorData(t,((a,s)=>{const l=!this.loading[i];if(delete this.loading[i],l||a||!s)return o.status="done",l||(this.loaded[i]=o),e(a);const c=s.rawData,u={};s.expires&&(u.expires=s.expires),s.cacheControl&&(u.cacheControl=s.cacheControl),o.vectorTile=s.vectorTile||new Pc.VectorTile(new yu(c));const d=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const o={};if(n){const t=gh(r);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,et({rawTileData:c.slice(0)},i,u,o))}))};this.isSpriteLoaded?d():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(d,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):d()})),this.loaded=this.loaded||{},this.loaded[i]=o}))}reloadTile(t,e){const i=this.loaded,r=t.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=t.showCollisionBoxes,o.enableTerrain=!!t.enableTerrain,o.projection=t.projection;const a=(t,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),e(t,i)};"parsing"===o.status?o.reloadCallback=a:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(t,e){const i=t.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}},t.WritingMode=$u,t.ZoomHistory=Jn,t.add=w,t.addDynamicAttributes=qd,t.adjoint=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8];return t[0]=a*u-s*c,t[1]=n*c-r*u,t[2]=r*s-n*a,t[3]=s*l-o*u,t[4]=i*u-n*l,t[5]=n*o-i*s,t[6]=o*c-a*l,t[7]=r*l-i*c,t[8]=i*a-r*o,t},t.asyncAll=Q,t.bezier=H,t.bindAll=st,t.boundsAttributes=op,t.bufferConvexPolygon=function(t,e){const i=[];for(let r=0;rQt&&(t.getActor().send("enforceCacheSizeLimit",Jt),ie=0)},t.calculateGlobeMatrix=wp,t.calculateGlobeMercatorMatrix=function(t){const e=t.worldSize,i=Y(t.center.lat,-85.051129,Us),r=new o(Rs(t.center.lng)*e,Bs(i)*e),n=Fs(1,t.center.lat)*e,a=t.pixelsPerMeter,s=e/(n/t.pixelsPerMeter),l=d(new Float64Array(16));return p(l,l,[r.x,r.y,0]),m(l,l,[s,s,a]),l},t.clamp=Y,t.clearTileCache=function(t){const e=s.caches.delete(Xt);t&&e.catch(t).then((()=>t()))},t.clipLine=md,t.clone=function(t){var e=new c(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=dt,t.collisionCircleLayout=ou,t.config=St,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new c(16);return c!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=u,t.createExpression=Gr,t.createLayout=ha,t.createStyleLayer=function(t){return"custom"===t.type?new rh(t):new ah[t.type](t)},t.cross=I,t.degToRad=$,t.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},t.dot=z,t.ease=X,t.easeCubicInOut=W,t.emitValidationErrors=Vn,t.endsWith=lt,t.enforceCacheSizeLimit=function(t){te(),Yt&&Yt.then((e=>{e.keys().then((i=>{for(let r=0;ro&&(r+=(t[n]-o)*(t[n]-o)),e[n]{}}},t.globeBuffersForTileMesh=function(t,e,i,r){const n=t.context,o=t.transform;let a=e.globeGridBuffer,s=e.globePoleBuffer;if(!a){const t=kp.createGridVertices(i.canonical);a=e.globeGridBuffer=n.createVertexBuffer(t,up,!1)}if(!s){const t=kp.createPoleTriangleVertices(r,o.tileSize*r,0===i.canonical.y);s=e.globePoleBuffer=n.createVertexBuffer(t,up,!1)}return[a,s]},t.globeDenormalizeECEF=xp,t.globeMatrixForTile=function(t,e){const i=xp(gp(t)),r=((n=new Float64Array(16))[0]=(o=e)[0],n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=o[6],n[7]=o[7],n[8]=o[8],n[9]=o[9],n[10]=o[10],n[11]=o[11],n[12]=o[12],n[13]=o[13],n[14]=o[14],n[15]=o[15],n);var n,o;return v(r,r,i),r},t.globePoleMatrixForTile=function(t,e,i){const r=d(new Float64Array(16)),n=Math.pow(2,t.z),o=(t.x-n/2)/n*Math.PI*2,a=i.point,s=i.worldSize/(i.tileSize*n);return p(r,r,[a.x,a.y,-i.worldSize/Math.PI/2]),m(r,r,[s,s,s]),f(r,r,$(-i._center.lat)),g(r,r,$(-i._center.lng)),g(r,r,o),e&&m(r,r,[1,-1,1]),r},t.globeTileBounds=gp,t.globeToMercatorTransition=function(t){return K(5,6,t)},t.identity=d,t.identity$1=j,t.invert=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],d=e[9],h=e[10],p=e[11],m=e[12],f=e[13],g=e[14],v=e[15],y=i*s-r*a,_=i*l-n*a,b=i*c-o*a,x=r*l-n*s,w=r*c-o*s,k=n*c-o*l,E=u*f-d*m,T=u*g-h*m,S=u*v-p*m,C=d*g-h*f,M=d*v-p*f,z=h*v-p*g,I=y*z-_*M+b*C+x*S-w*T+k*E;return I?(t[0]=(s*z-l*M+c*C)*(I=1/I),t[1]=(n*M-r*z-o*C)*I,t[2]=(f*k-g*w+v*x)*I,t[3]=(h*w-d*k-p*x)*I,t[4]=(l*S-a*z-c*T)*I,t[5]=(i*z-n*S+o*T)*I,t[6]=(g*b-m*k-v*_)*I,t[7]=(u*k-h*b+p*_)*I,t[8]=(a*M-s*S+c*E)*I,t[9]=(r*S-i*M-o*E)*I,t[10]=(m*w-f*b+v*y)*I,t[11]=(d*b-u*w-p*y)*I,t[12]=(s*T-a*C-l*E)*I,t[13]=(i*C-r*T+n*E)*I,t[14]=(f*_-m*x-g*y)*I,t[15]=(u*x-d*_+h*y)*I,t):null},t.isMapAuthenticated=function(t){return Ht.has(t)},t.isMapboxURL=Lt,t.latFromMercatorY=Ns,t.len=R,t.length=b,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=zp,t.makeRequest=ae,t.mercatorXfromLng=Rs,t.mercatorYfromLat=Bs,t.mercatorZfromAltitude=Fs,t.mul=v,t.mul$1=L,t.multiply=function(t,e,i){var r=e[0],n=e[1],o=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8],h=i[0],p=i[1],m=i[2],f=i[3],g=i[4],v=i[5],y=i[6],_=i[7],b=i[8];return t[0]=h*r+p*a+m*c,t[1]=h*n+p*s+m*u,t[2]=h*o+p*l+m*d,t[3]=f*r+g*a+v*c,t[4]=f*n+g*s+v*u,t[5]=f*o+g*l+v*d,t[6]=y*r+_*a+b*c,t[7]=y*n+_*s+b*u,t[8]=y*o+_*l+b*d,t},t.multiply$1=h,t.multiply$2=E,t.nextPowerOfTwo=ot,t.normalize=M,t.normalize$1=function(t,e){var i=e[0],r=e[1],n=e[2],o=e[3],a=i*i+r*r+n*n+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=i*a,t[1]=r*a,t[2]=n*a,t[3]=o*a,t},t.number=Fi,t.ortho=function(t,e,i,r,n,o,a){var s=1/(e-i),l=1/(r-n),c=1/(o-a);return t[0]=-2*s,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]=2*c,t[11]=0,t[12]=(e+i)*s,t[13]=(n+r)*l,t[14]=(a+o)*c,t[15]=1,t},t.pbf=yu,t.perspective=function(t,e,i,r,n){var o,a=1/Math.tan(e/2);return t[0]=a/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,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!=n&&n!==1/0?(t[10]=(n+r)*(o=1/(r-n)),t[14]=2*n*r*o):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){const i={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let a=n[o];a||(a=n[o]=[]),a.push(e)}}}const{ImageBitmap:n}=t.window;class o{loadTile(e,i){const{uid:r,encoding:o,rawImageData:a,padding:s,buildQuadTree:l}=e,c=n&&a instanceof n?this.getImageData(a,s):a;i(null,new t.DEMData(r,c,o,s<1,l))}getImageData(e,i){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-i,-i,e.width+2*i,e.height+2*i);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:r.width,height:r.height},r.data)}}var a=function t(e,i){var r,n=e&&e.type;if("FeatureCollection"===n)for(r=0;r=Math.abs(s)?i-l+s:s-l+i,i=l}i+r>=0!=!!e&&t.reverse()}const c=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(e){this._feature=e,this.extent=t.EXTENT,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.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return c.call(this,t,e,i)}}class d{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new u(this._features[t])}}var h=t.vectorTile.VectorTileFeature,p=m;function m(t,e){this.options=e||{},this.features=t,this.length=t.length}function f(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}m.prototype.feature=function(t){return new f(this.features[t],this.options.extent)},f.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function E(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,o=0,a=i.length,s=0;s>1;C(t,e,a,r,n,o%2),S(t,e,i,r,a-1,o+1),S(t,e,i,a+1,n,o+1)}function C(t,e,i,r,n,o){for(;n>r;){if(n-r>600){const a=n-r+1,s=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);C(t,e,i,Math.max(r,Math.floor(i-s*c/a+u)),Math.min(n,Math.floor(i+(a-s)*c/a+u)),o)}const a=e[2*i+o];let s=r,l=n;for(M(t,e,r,i),e[2*n+o]>a&&M(t,e,r,n);sa;)l--}e[2*r+o]===a?M(t,e,r,l):(l++,M(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function M(t,e,i,r){z(t,i,r),z(e,2*i,2*r),z(e,2*i+1,2*r+1)}function z(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function I(t,e,i,r){const n=t-i,o=e-r;return n*n+o*o}g.fromVectorTileJs=y,g.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new p(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return y({layers:i})},g.GeoJSONWrapper=v;const P=t=>t[0],A=t=>t[1];class D{constructor(t,e=P,i=A,r=64,n=Float64Array){this.nodeSize=r,this.points=t;const o=t.length<65536?Uint16Array:Uint32Array,a=this.ids=new o(t.length),s=this.coords=new n(2*t.length);for(let r=0;r=i&&c<=n&&u>=r&&u<=o&&l.push(t[a]);continue}const m=Math.floor((p+h)/2);c=e[2*m],u=e[2*m+1],c>=i&&c<=n&&u>=r&&u<=o&&l.push(t[m]);const f=(d+1)%2;(0===d?i<=c:r<=u)&&(s.push(p),s.push(m-1),s.push(f)),(0===d?n>=c:o>=u)&&(s.push(m+1),s.push(h),s.push(f))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,n,o){const a=[0,t.length-1,0],s=[],l=n*n;for(;a.length;){const c=a.pop(),u=a.pop(),d=a.pop();if(u-d<=o){for(let n=d;n<=u;n++)I(e[2*n],e[2*n+1],i,r)<=l&&s.push(t[n]);continue}const h=Math.floor((d+u)/2),p=e[2*h],m=e[2*h+1];I(p,m,i,r)<=l&&s.push(t[h]);const f=(c+1)%2;(0===c?i-n<=p:r-n<=m)&&(a.push(d),a.push(h-1),a.push(f)),(0===c?i+n>=p:r+n>=m)&&(a.push(h+1),a.push(u),a.push(f))}return s}(this.ids,this.coords,t,e,i,this.nodeSize)}}const O={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},L=Math.fround||(R=new Float32Array(1),t=>(R[0]=+t,R[0]));var R;class B{constructor(t){this.options=G(Object.create(O),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:n}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;let a=[];for(let e=0;e=i;t--){const i=+Date.now();a=this._cluster(a,t),this.trees[t]=new D(a,q,W,n,Float32Array),e&&console.log("z%d: %d clusters in %dms",t,a.length,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=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,n=180;else if(i>n){const t=this.getClusters([i,r,180,o],e),a=this.getClusters([-180,r,n,o],e);return t.concat(a)}const a=this.trees[this._limitZoom(e)],s=a.range(U(i),Z(o),U(n),Z(r)),l=[];for(const t of s){const e=a.points[t];l.push(e.numPoints?N(e):this.points[e.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.points[e];if(!o)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=n.within(o.x,o.y,a),l=[];for(const e of s){const i=n.points[e];i.parentId===t&&l.push(i.numPoints?N(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:o,radius:a}=this.options,s=a/o,l=(i-s)/n,c=(i+1+s)/n,u={features:[]};return this._addTileFeatures(r.range((e-s)/n,l,(e+1+s)/n,c),r.points,e,i,n,u),0===e&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.points,n,i,n,u),e===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.points,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(t,o.cluster_id,i,r,n):ne&&(d+=i.numPoints||1)}if(d>u&&d>=a){let t=n.x*u,a=n.y*u,s=o&&u>1?this._map(n,!0):null;const h=(r<<5)+(e+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=e)continue;r.zoom=e;const c=r.numPoints||1;t+=r.x*c,a+=r.y*c,r.parentId=h,o&&(s||(s=this._map(n,!0)),o(s,this._map(r)))}n.parentId=h,i.push(F(t/d,a/d,h,d,s))}else if(i.push(n),d>1)for(const t of c){const r=l.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?G({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?G({},r):r}}function F(t,e,i,r,n){return{x:L(t),y:L(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function j(t,e){const[i,r]=t.geometry.coordinates;return{x:L(U(i)),y:L(Z(r)),zoom:1/0,index:e,parentId:-1}}function N(t){return{type:"Feature",id:t.id,properties:V(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),$(t.y)]}};var e}function V(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return G(G({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function U(t){return t/360+.5}function Z(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function $(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function G(t,e){for(const i in e)t[i]=e[i];return t}function q(t){return t.x}function W(t){return t.y}function H(t,e,i,r){for(var n,o=r,a=i-e>>1,s=i-e,l=t[e],c=t[e+1],u=t[i],d=t[i+1],h=e+3;ho)n=h,o=p;else if(p===o){var m=Math.abs(h-a);mr&&(n-e>3&&H(t,e,n,r),t[n+2]=o,i-n>3&&H(t,n,i,r))}function X(t,e,i,r,n,o){var a=n-i,s=o-r;if(0!==a||0!==s){var l=((t-i)*a+(e-r)*s)/(a*a+s*s);l>1?(i=n,r=o):l>0&&(i+=a*l,r+=s*l)}return(a=t-i)*a+(s=e-r)*s}function Y(t,e,i,r){var n={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)K(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r0&&(a+=r?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var u=e.length-3;e[2]=1,H(e,0,u,i),e[u+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function et(t,e,i,r){for(var n=0;n1?1:i}function nt(t,e,i,r,n,o,a,s){if(r/=e,o>=(i/=e)&&a=r)return null;for(var l=[],c=0;c=i&&m=r)){var f=[];if("Point"===h||"MultiPoint"===h)ot(d,f,i,r,n);else if("LineString"===h)at(d,f,i,r,n,!1,s.lineMetrics);else if("MultiLineString"===h)lt(d,f,i,r,n,!1);else if("Polygon"===h)lt(d,f,i,r,n,!0);else if("MultiPolygon"===h)for(var g=0;g=i&&a<=r&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function at(t,e,i,r,n,o,a){for(var s,l,c=st(t),u=0===n?ut:dt,d=t.start,h=0;h