=0||!Ur(n)){const t=Du(_,e,i,r,l,w,d,g,v,p,y,Su.horizontal,!1,M,h,u);t&&(f.horizontal[v]=t)}A("point"===M?"left":v)}}let b=!1;if(o.icon&&o.icon.name){const e=n[o.icon.name];e&&(g=Fu(r[o.icon.name],c.get("icon-offset").evaluate(o,{},s),c.get("icon-anchor").evaluate(o,{},s)),b=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&C("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==c.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const v=Ad(f.horizontal)||f.vertical;t.iconsInText||(t.iconsInText=!!v&&v.iconsInText),(v||g)&&Md(t,o,f,g,n,d,h,0,y,b,a,s)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function vd(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 Md(t,e,i,n,r,o,a,s,l,c,u,m){let p=o.textMaxSize.evaluate(e,{},m);void 0===p&&(p=a);const h=t.layers[0].layout,f=h.get("icon-offset").evaluate(e,{},m),_=Ad(i.horizontal)||i.vertical,g=a/24,y=t.tilePixelRatio*p/24,b=t.tilePixelRatio*h.get("symbol-spacing"),v=h.get("text-padding")*t.tilePixelRatio,M=h.get("icon-padding")*t.tilePixelRatio,x=d(h.get("text-max-angle")),w="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),A="map"===h.get("icon-rotation-alignment")&&"point"!==h.get("symbol-placement"),L=h.get("symbol-placement"),z=b/2,T=h.get("icon-text-fit");let k;n&&"none"!==T&&(t.allowVerticalPlacement&&i.vertical&&(k=Xu(n,i.vertical,T,h.get("icon-text-fit-padding"),f,g)),_&&(n=Xu(n,_,T,h.get("icon-text-fit-padding"),f,g)));const S=(a,s)=>{s.x<0||s.x>=Za||s.y<0||s.y>=Za||function(t,e,i,n,r,o,a,s,l,c,u,d,m,p,h,f,_,g,y,b,v,M,x,w,A){const L=t.addToLineVertexArray(e,n);let z,T,k,S,E,O,D,P=0,N=0,I=0,B=0,Y=-1,R=-1;const j={};let q=ya(""),W=0,F=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[W,F]=l.layout.get("text-offset").evaluate(v,{},A).map((t=>t*Hc)):(W=l.layout.get("text-radial-offset").evaluate(v,{},A)*Hc,F=_d),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(h)O=zd(t),s&&(D=zd(s));else{const n=l.layout.get("text-rotate").evaluate(v,{},A)+90;k=Ld(c,i,e,u,d,m,t,p,n,f),s&&(S=Ld(c,i,e,u,d,m,s,g,n))}}if(o){const n=l.layout.get("icon-rotate").evaluate(v,{},A),r="none"!==l.layout.get("icon-text-fit"),a=od(o,n,x,r),p=s?od(s,n,x,r):void 0;T=Ld(c,i,e,u,d,m,o,g,n),P=4*a.length;const h=t.iconSizeData;let f=null;"source"===h.kind?(f=[Uc*l.layout.get("icon-size").evaluate(v,{},A)],f[0]>xd&&C(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===h.kind&&(f=[Uc*M.compositeIconSizes[0].evaluate(v,{},A),Uc*M.compositeIconSizes[1].evaluate(v,{},A)],(f[0]>xd||f[1]>xd)&&C(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,a,f,b,y,v,!1,i,e,L.lineStartIndex,L.lineLength,-1,w,A),Y=t.icon.placedSymbolArray.length-1,p&&(N=4*p.length,t.addSymbols(t.icon,p,f,b,y,v,Su.vertical,i,e,L.lineStartIndex,L.lineLength,-1,w,A),R=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];z||(q=ya(o.text),h?E=zd(o):z=Ld(c,i,e,u,d,m,o,p,l.layout.get("text-rotate").evaluate(v,{},A),f));const s=1===o.positionedLines.length;if(I+=wd(t,i,e,o,a,l,h,v,f,L,r.vertical?Su.horizontal:Su.horizontalOnly,s?Object.keys(r.horizontal):[n],j,Y,M,w,A),s)break}r.vertical&&(B+=wd(t,i,e,r.vertical,a,l,h,v,f,L,Su.vertical,["vertical"],j,R,M,w,A));let X=-1;const H=(t,e)=>t?Math.max(t,e):e;X=H(E,X),X=H(O,X),X=H(D,X);const U=X>-1?1:0;t.glyphOffsetArray.length>=Nd.MAX_GLYPHS&&C("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(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,Y,R,q,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==k?k:t.collisionBoxArray.length,void 0!==k?k+1:t.collisionBoxArray.length,void 0!==T?T:t.collisionBoxArray.length,void 0!==T?T+1:t.collisionBoxArray.length,S||t.collisionBoxArray.length,S?S+1:t.collisionBoxArray.length,u,I,B,P,N,U,0,W,F,X)}(t,s,s,a,i,n,r,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,v,w,l,0,M,A,f,e,o,c,u,m)};if("line"===L)for(const r of Qu(e.geometry,0,0,Za,Za)){const e=Ku(r,b,x,i.vertical||_,n,24,y,t.overscaling,Za);for(const i of e){const e=_;e&&Td(t,e.text,z,i)||S(r,i)}}else if("line-center"===L){for(const t of e.geometry)if(t.length>1){const e=$u(t,x,i.vertical||_,n,24,y);e&&S(t,e)}}else if("Polygon"===e.type)for(const t of Jl(e.geometry,0)){const e=pd(t,16);S(t[0],new Hu(e.x,e.y,0,0,void 0))}else if("LineString"===e.type)for(const t of e.geometry)S(t,new Hu(t[0].x,t[0].y,0,0,void 0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)S([e],new Hu(e.x,e.y,0,0,void 0))}const xd=32640;function wd(t,e,i,n,r,a,s,l,c,u,d,m,p,h,f,_,g){const y=function(t,e,i,n,r,a,s,l){const c=[];if(0===e.positionedLines.length)return c;const u=n.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,d=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:n<0?[-e,i]:0===e?[i,e]:[i,-e]}(i);let m=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)m-=t.lineOffset;const p=e.positionedLines.length,h=m/p;let f=e.top-i[1];for(let t=0;txd&&C(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===b.kind&&(v=[Uc*f.compositeTextSizes[0].evaluate(l,{},g),Uc*f.compositeTextSizes[1].evaluate(l,{},g)],(v[0]>xd||v[1]>xd)&&C(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,y,v,c,s,l,d,e,i,u.lineStartIndex,u.lineLength,h,_,g);for(const e of m)p[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Ad(t){for(const e in t)return t[e];return null}function Ld(t,e,i,n,r,a,s,l,c,u){let m=s.top,p=s.bottom,h=s.left,f=s.right;const _=s.collisionPadding;if(_&&(h-=_[0],m-=_[1],f+=_[2],p+=_[3]),c){const t=new o(h,m),e=new o(f,m),i=new o(h,p),n=new o(f,p),r=d(c);let a=new o(0,0);u&&(a=new o(u[0],u[1])),t._rotateAround(r,a),e._rotateAround(r,a),i._rotateAround(r,a),n._rotateAround(r,a),h=Math.min(t.x,e.x,i.x,n.x),f=Math.max(t.x,e.x,i.x,n.x),m=Math.min(t.y,e.y,i.y,n.y),p=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,h,m,f,p,l,n,r,a),t.length-1}function zd(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 Td(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])t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ys([]),this.placementViewportMatrix=Ys([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Vc(this.zoom,e["text-size"]),this.iconSizeData=Vc(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=>Su[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Cd(new Ya(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Cd(new Ya(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new la,this.lineVertexArray=new ca,this.symbolInstances=new sa}calculateGlyphDependencies(t,e,i,n,r){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 m=e.iconDependencies,p=e.glyphDependencies,h=e.availableImages,f=new po(this.zoom);for(const{feature:e,id:s,index:l,sourceLayerIndex:_}of t){const t=r._featureFilter.needGeometry,g=fs(e,t);if(!r._featureFilter.filter(f,g,i))continue;let y,b;if(t||(g.geometry=hs(e,i,n)),c){const t=r.getValueAndResolveTokens("text-field",g,i,h),e=fe.factory(t);Dd(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===co()||this.hasRTLText&&mo.isParsed())&&(y=Kc(e,r,g))}if(u){const t=r.getValueAndResolveTokens("icon-image",g,i,h);b=t instanceof _e?t:_e.fromString(t)}if(!y&&!b)continue;const v=this.sortFeaturesByKey?d.evaluate(g,{},i):void 0;if(this.features.push({id:s,text:y,icon:b,index:l,sourceLayerIndex:_,geometry:g.geometry,properties:e.properties,type:kd[e.type],sortKey:v}),b&&(m[b.name]=!0),y){const t=a.evaluate(g,{},i).join(","),e="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Su.vertical)>=0;for(const i of y.sections)if(i.image)m[i.image.name]=!0;else{const n=Ur(y.toString()),r=i.fontStack||t,o=p[r]=p[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 a(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 s(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){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,n),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i,n))}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]),n=t.dist(e[t.segment]);const r={};for(let n=t.segment+1;n=0;i--)r[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=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:n),o=Gc(this.textSizeData,t,r)/Hc;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Gc(this.iconSizeData,t,n);return this.tilePixelRatio*r}_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,n,r,o){for(let a=n;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}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}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)}}}pr("SymbolBucket",Nd,{omit:["layers","collisionBoxArray","features","compareText"]}),Nd.MAX_GLYPHS=65535,Nd.addDynamicAttributes=Od;const Id=new To({"symbol-placement":new xo(jt.layout_symbol["symbol-placement"]),"symbol-spacing":new xo(jt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new xo(jt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new wo(jt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new xo(jt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new xo(jt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new xo(jt.layout_symbol["icon-ignore-placement"]),"icon-optional":new xo(jt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new xo(jt.layout_symbol["icon-rotation-alignment"]),"icon-size":new wo(jt.layout_symbol["icon-size"]),"icon-text-fit":new xo(jt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new xo(jt.layout_symbol["icon-text-fit-padding"]),"icon-image":new wo(jt.layout_symbol["icon-image"]),"icon-rotate":new wo(jt.layout_symbol["icon-rotate"]),"icon-padding":new xo(jt.layout_symbol["icon-padding"]),"icon-keep-upright":new xo(jt.layout_symbol["icon-keep-upright"]),"icon-offset":new wo(jt.layout_symbol["icon-offset"]),"icon-anchor":new wo(jt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new xo(jt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new xo(jt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new xo(jt.layout_symbol["text-rotation-alignment"]),"text-field":new wo(jt.layout_symbol["text-field"]),"text-font":new wo(jt.layout_symbol["text-font"]),"text-size":new wo(jt.layout_symbol["text-size"]),"text-max-width":new wo(jt.layout_symbol["text-max-width"]),"text-line-height":new wo(jt.layout_symbol["text-line-height"]),"text-letter-spacing":new wo(jt.layout_symbol["text-letter-spacing"]),"text-justify":new wo(jt.layout_symbol["text-justify"]),"text-radial-offset":new wo(jt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new xo(jt.layout_symbol["text-variable-anchor"]),"text-anchor":new wo(jt.layout_symbol["text-anchor"]),"text-max-angle":new xo(jt.layout_symbol["text-max-angle"]),"text-writing-mode":new xo(jt.layout_symbol["text-writing-mode"]),"text-rotate":new wo(jt.layout_symbol["text-rotate"]),"text-padding":new xo(jt.layout_symbol["text-padding"]),"text-keep-upright":new xo(jt.layout_symbol["text-keep-upright"]),"text-transform":new wo(jt.layout_symbol["text-transform"]),"text-offset":new wo(jt.layout_symbol["text-offset"]),"text-allow-overlap":new xo(jt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new xo(jt.layout_symbol["text-ignore-placement"]),"text-optional":new xo(jt.layout_symbol["text-optional"])});var Bd={paint:new To({"icon-opacity":new wo(jt.paint_symbol["icon-opacity"]),"icon-color":new wo(jt.paint_symbol["icon-color"]),"icon-halo-color":new wo(jt.paint_symbol["icon-halo-color"]),"icon-halo-width":new wo(jt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new wo(jt.paint_symbol["icon-halo-blur"]),"icon-translate":new xo(jt.paint_symbol["icon-translate"]),"icon-translate-anchor":new xo(jt.paint_symbol["icon-translate-anchor"]),"text-opacity":new wo(jt.paint_symbol["text-opacity"]),"text-color":new wo(jt.paint_symbol["text-color"],{runtimeType:Jt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new wo(jt.paint_symbol["text-halo-color"]),"text-halo-width":new wo(jt.paint_symbol["text-halo-width"]),"text-halo-blur":new wo(jt.paint_symbol["text-halo-blur"]),"text-translate":new xo(jt.paint_symbol["text-translate"]),"text-translate-anchor":new xo(jt.paint_symbol["text-translate-anchor"])}),layout:Id};class Yd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Gt,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}}pr("FormatSectionOverride",Yd,{omit:["defaultValue"]});class Rd extends Ha{constructor(t){super(t,Bd)}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,n){const r=this.layout.get(t).evaluate(e,{},i,n),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||dn(o.value)||!r?r:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new Nd(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Bd.paint.overridableProperties){if(!Rd.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Yd(e),n=new un(i,e.property.specification);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new pn("source",n):new hn("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new vo(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Rd.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=Bd.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 fe)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof Me&&be(e.value)===ie?o(e.value.sections):e instanceof Le?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramConfiguration(t){return new Ba(this,t)}}var jd={paint:new To({"background-color":new xo(jt.paint_background["background-color"]),"background-pattern":new Lo(jt.paint_background["background-pattern"]),"background-opacity":new xo(jt.paint_background["background-opacity"])})},qd={paint:new To({"raster-opacity":new xo(jt.paint_raster["raster-opacity"]),"raster-hue-rotate":new xo(jt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new xo(jt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new xo(jt.paint_raster["raster-brightness-max"]),"raster-saturation":new xo(jt.paint_raster["raster-saturation"]),"raster-contrast":new xo(jt.paint_raster["raster-contrast"]),"raster-resampling":new xo(jt.paint_raster["raster-resampling"]),"raster-fade-duration":new xo(jt.paint_raster["raster-fade-duration"])})};class Wd extends Ha{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 Fd={paint:new To({"sky-type":new xo(jt.paint_sky["sky-type"]),"sky-atmosphere-sun":new xo(jt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new xo(jt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new xo(jt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new xo(jt.paint_sky["sky-gradient-radius"]),"sky-gradient":new zo(jt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new xo(jt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new xo(jt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new xo(jt.paint_sky["sky-opacity"])})};function Xd(t,e,i){const n=Fs(0,0,1),r=el(tl());return function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],a=e[3],s=Math.sin(i),l=Math.cos(i);t[0]=n*l-o*s,t[1]=r*l+a*s,t[2]=o*l+n*s,t[3]=a*l-r*s}(r,r,i?-d(t)+Math.PI:d(t)),il(r,r,-d(e)),Gs(n,n,r),Vs(n,n)}const Hd={circle:class extends Ha{constructor(t){super(t,Ns)}createBucket(t){return new gs(t)}queryRadius(t){const e=t;return Es("circle-radius",this,e)+Es("circle-stroke-width",this,e)+Os(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,n,r,o,a,s){const l=Cs(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 rl(t,n,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 Ba(this,t)}},heatmap:class extends Ha{createBucket(t){return new cl(t)}constructor(t){super(t,fl),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=_l({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 Es("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,n,r,a,s,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return rl(t,n,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 Ba(this,t)}},hillshade:class extends Ha{constructor(t){super(t,gl)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(t){return new Ba(this,t)}},fill:class extends Ha{constructor(t){super(t,rc)}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 Ba(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 ic(t)}queryRadius(){return Os(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,n,r,o){return!t.queryGeometry.isAboveHorizon&&vs(Ds(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends Ha{constructor(t){super(t,wc)}createBucket(t){return new Mc(t)}queryRadius(){return Os(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 Ba(this,t)}queryIntersectsFeature(t,e,i,n,r,a,s,l,c){const u=Cs(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),m=this.paint.get("fill-extrusion-base").evaluate(e,i),p=[0,0],h=l&&a.elevation,f=a.elevation?a.elevation.exaggeration():1;if(h){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 m=e/i*(n+1);if(a.isDash){const t=n-Math.abs(m);d=Math.sqrt(u*u+t*t)}else d=n-Math.sqrt(u*u+m*m);this.image.data[r+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],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,a=t[o];for(let i=0;i1&&(a=t[++o]);const n=Math.abs(i-a.left),s=Math.abs(i-a.right),l=Math.min(n,s);this.image.data[r+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 n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return C("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 tm=s.performance;function em(t){const e=t?t.url.toString():void 0;return tm.getEntriesByName(e)}class im{constructor(){this.tasks={},this.taskQueue=[],T(["process"],this),this.invoker=new Qd(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){I();try{t()}finally{}return{cancel:()=>{}}}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(){I();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;ib&&(v(t,c,n,r,s,l),v(c,i,s,l,o,a))}v(d,m,n,o,r,o),v(m,p,r,o,r,a),v(p,h,r,a,n,a),v(h,d,n,a,n,o),f-=b,_-=b,g+=b,y+=b;const M=1/Math.max(g-f,y-_);return{scale:M,x:f*M,y:_*M,x2:g*M,y2:y*M,projection:e}}function rm(t,e,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class om{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=lm(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=(r=this.y,o=this.z,a=rm(256*(n=this.x),256*(r=Math.pow(2,o)-r-1),o),s=rm(256*(n+1),256*(r+1),o),a[0]+","+a[1]+","+s[0]+","+s[1]);var n,r,o,a,s;const l=function(t,e,i){let n,r="";for(let o=t;o>0;o--)n=1<this.canonical.z?new sm(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new sm(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 lm(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return lm(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 sm(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 sm(e,this.wrap,e,i,n),new sm(e,this.wrap,e,i+1,n),new sm(e,this.wrap,e,i,n+1),new sm(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>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=a,n=s):(i=r,n=o,r=a,o=s),a=t,s=l}const l=4*t;hm[l+0]=i,hm[l+1]=n,hm[l+2]=r,hm[l+3]=o}const fm=new Uint16Array(2178),_m=new Uint8Array(1089),gm=new Uint16Array(1089);function ym(t){return 0===t?-.03125:32===t?.03125:0}var bm=Do([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const vm={type:2,extent:Za,loadGeometry:()=>[[new o(0,0),new o(8193,0),new o(8193,8193),new o(0,8193),new o(0,0)]]};class Mm{constructor(t,e,i,n,r){this.tileID=t,this.uid=w(),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=r,this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Nd){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 Nd&&e.hasRTLText){this.hasRTLText=!0,mo.isLoading()||mo.isLoaded()||"deferred"!==co()||uo();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 na}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.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 Kd(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Kd(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Kd(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,n,r,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:a,transform:o,params:r,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),r=e?e.sourceLayer:"",o=n._geojsonTileLayer||n[r];if(!o)return;const a=zn(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=hm[e+0],n=hm[e+1],r=hm[e+2],o=hm[e+3],a=i+r>>1,s=n+o>>1,l=a+s-n,c=s+i-a,u=n*pm+i,d=o*pm+r,m=s*pm+a,p=Math.hypot((fm[2*u+0]+fm[2*d+0])/2-fm[2*m+0],(fm[2*u+1]+fm[2*d+1])/2-fm[2*m+1])>=16;if(_m[m]=_m[m]||(p?1:0),t<1022){const t=(n+c>>1)*pm+(i+l>>1),e=(o+c>>1)*pm+(r+l>>1);_m[m]=_m[m]||_m[t]||_m[e]}}const r=new No,o=new Uo;let a=0;function s(t,e){const i=e*pm+t;return 0===gm[i]&&(r.emplaceBack(fm[2*i+0],fm[2*i+1],t*Za/mm,e*Za/mm),gm[i]=++a),gm[i]-1}function l(t,e,i,n,r,a){const c=t+i>>1,u=e+n>>1;if(Math.abs(t-r)+Math.abs(e-a)>1&&_m[u*pm+c])l(r,a,t,e,c,u),l(i,n,r,a,c,u);else{const l=s(t,e),c=s(i,n),u=s(r,a);o.emplaceBack(l,c,u)}}return l(0,0,mm,mm,mm,0),l(mm,mm,0,0,0,mm),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new No,r=new Uo;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=vl(n.int16,void 0,4);for(let e=0;ee[a])return null}else{const s=1/n[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>r&&(r=l),co)return null}return r}function Lm(t,e,i,n,r,o,a,s,l,c,u){const d=n-t,m=r-e,p=o-i,h=a-t,f=s-e,_=l-i,g=u[1]*_-u[2]*f,y=u[2]*h-u[0]*_,b=u[0]*f-u[1]*h,v=d*g+m*y+p*b;if(Math.abs(v)<1e-15)return null;const M=1/v,x=c[0]-t,w=c[1]-e,A=c[2]-i,L=(x*g+w*y+A*b)*M;if(L<0||L>1)return null;const z=w*p-A*m,T=A*d-x*p,k=x*m-w*d,S=(u[0]*z+u[1]*T+u[2]*k)*M;return S<0||L+S>1?null:(h*z+f*T+_*k)*M}function zm(t,e,i){return(t-e)/(i-e)}function Tm(t,e,i,n,r,o,a,s,l){const c=1<{const o=n?1:0,a=(t+1)*i-o,s=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=s,r[2]=a,r[3]=l};let a=new wm(n);const s=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];a=new wm(n);for(let e=0;e0;){const{idx:s,t:p,nodex:h,nodey:f,depth:_}=m.pop();if(this.leaves[s]){Tm(h,f,_,t,e,i,n,u,d);const s=1<<_,l=(h+0)/s,c=(h+1)/s,m=(f+0)/s,g=(f+1)/s,y=Em(l,m,this.dem)*a,b=Em(c,m,this.dem)*a,v=Em(c,g,this.dem)*a,M=Em(l,g,this.dem)*a,x=Lm(u[0],u[1],y,d[0],u[1],b,d[0],d[1],v,r,o),w=Lm(d[0],d[1],v,u[0],d[1],M,u[0],u[1],y,r,o),A=Math.min(null!==x?x:Number.MAX_VALUE,null!==w?w:Number.MAX_VALUE);if(A!==Number.MAX_VALUE)return A;{const t=Us([],r,o,p);if(Sm(y,b,M,v,zm(t[0],u[0],d[0]),zm(t[1],u[1],d[1]))>=t[2])return p}continue}let g=0;for(let m=0;m=l[c[i]]&&(c.splice(i,0,m),e=!0);e||(c[g]=m),g++}}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],n=Dm.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 hl({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 n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+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,r)}),i)),this.data[n].push(r),this.order.push(n),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,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Pm{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Pm.ReadOnly=!1,Pm.ReadWrite=!0,Pm.disabled=new Pm(519,Pm.ReadOnly,[0,1]);const Nm=7680;class Im{constructor(t,e,i,n,r,o){this.test=t,this.ref=e,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Im.disabled=new Im({func:519,mask:0},0,0,Nm,Nm,Nm);class Bm{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}Bm.Replace=[1,0],Bm.disabled=new Bm(Bm.Replace,me.transparent,[!1,!1,!1,!1]),Bm.unblended=new Bm(Bm.Replace,me.transparent,[!0,!0,!0,!0]),Bm.alphaBlended=new Bm([1,771],me.transparent,[!0,!0,!0,!0]);const Ym=1029,Rm=2305;class jm{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}jm.disabled=new jm(!1,Ym,Rm),jm.backCCW=new jm(!0,Ym,Rm),jm.backCW=new jm(!0,Ym,2304),jm.frontCW=new jm(!0,1028,2304),jm.frontCCW=new jm(!0,1028,Rm);class qm extends Rt{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 Cm(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new xm}onAdd(t){this.map=t,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 v(this._tiles).map((t=>t.tileID)).sort(Wm).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,n=e.tileID,r=new o(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),a=new o(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||a.y-r.y||a.x-r.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Wm).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,n){if(n)return t.state="errored",void(404!==n.status?this._source.fire(new Yt(n,{tile:t})):this.update(this.transform));t.timeAdded=X.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Bt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),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,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!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]){n[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),n=this._getLoadedTile(e);if(n)return n}}_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,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(o)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}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 n;this.updateCacheSize(t,e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new sm(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=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&&(n=n.filter((t=>this._source.hasTile(t))))):n=[];const r=this._updateRetainedTiles(n);if(Fm(this._source.type)&&0!==n.length){const t={},e={},i=Object.keys(r);for(const n of i){const i=r[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=X.now())continue;const a=this.findLoadedParent(i,Math.max(i.overscaledZ-qm.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),e[n]=i}const o=n[n.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(r[t]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>o;){n=n.scaledTo(n.overscaledZ-1);const o=this._tiles[n.key];if(o&&o.hasData()&&e[n.key]){r[t]=i.tileID;break}}}for(const e in t)r[e]||(this._coveredTiles[e]=!0,r[e]=t[e])}for(const t in r)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,r);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={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-qm.maxOverzooming,this._source.minzoom),a=Math.max(r+qm.maxUnderzooming,this._source.minzoom),s={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let a=n.overscaledZ-1;a>=o;--a){const o=n.scaledTo(a);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=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;e=new Mm(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,"raster"===this._source.type||"raster-dem"===this._source.type),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 Bt("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 n=[],r=this.transform;if(!r)return n;for(const o in this._tiles){const a=this._tiles[o];if(i&&a.clearQueryDebugViz(),a.holdingForFade())continue;const s=t.containsTile(a,r,e);s&&n.push(s)}return n}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(Fm(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=X.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 n=this._tiles[t];n&&n.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)))}}function Wm(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Fm(t){return"raster"===t||"image"===t||"video"===t}qm.maxOverzooming=10,qm.maxUnderzooming=3;class Xm{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,a=1<=0&&n[3]>=0&&s.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new _c.VectorTile(new nu(this.rawTileData)).layers,this.sourceLayerCoder=new cm(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=zn(r.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,n)=>ks(a.bufferedTilespaceGeometry,t,e,i,n)));c.sort(Vm);let u=null;s.elevation&&c.length>0&&(u=Xm.create(s.elevation,this.tileID));const d={};let m;for(let s=0;s(h||(h=hs(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(a,e,n,h,this.z,t.transform,t.pixelPosMatrix,u,r))))}return d}loadMatchingFeature(t,e,i,n,r,o,a,s,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:d,layoutVertexArrayOffset:m}=e,p=this.bucketLayerIDs[u];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,p))return;const h=this.sourceLayerCoder.decode(d),f=this.vtLayers[h].feature(c);if(i.needGeometry){const t=fs(f,!0);if(!i.filter(new po(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new po(this.tileID.overscaledZ),f))return;const _=this.getId(f,h);for(let e=0;e{const a=e instanceof Mo?e.get(o):null;return a&&a.evaluate?a.evaluate(i,n,r):a}))}function Vm(t,e){return e-t}pr("FeatureIndex",Hm,{omit:["rawTileData","sourceLayerCoder"]});class Gm{constructor(t){const e={},i=[];for(const n in t){const r=t[n],o=e[n]={};for(const t in r.glyphs){const e=r.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const n=e.metrics.localGlyph?2:1,a={x:0,y:0,w:e.bitmap.width+2*n,h:e.bitmap.height+2*n};i.push(a),o[t]=a}}const{w:n,h:r}=zu(i),o=new pl({width:n||1,height:r||1});for(const i in t){const n=t[i];for(const t in n.glyphs){const r=n.glyphs[+t];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const a=e[i][t],s=r.metrics.localGlyph?2:1;pl.copy(r.bitmap,o,{x:0,y:0},{x:a.x+s,y:a.y+s},r.bitmap)}}this.image=o,this.positions=e}}pr("GlyphAtlas",Gm);class Zm{constructor(t){this.tileID=new sm(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,t.projection&&(this.tileTransform=nm(t.tileID.canonical,t.projection))}parse(t,e,i,n,r){this.status="parsing",this.data=t,this.collisionBoxArray=new na;const o=new cm(Object.keys(t.layers).sort()),a=new Hm(this.tileID,this.promoteId);a.bucketLayerIDs=[];const s={},l=new Jd(256,256),c={featureIndex:a,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=e.familiesBySource[this.source];for(const e in u){const n=t.layers[e];if(!n)continue;let r=!1,l=!1;for(const t of u[e])"symbol"===t[0].type?r=!0:l=!0;if(!0===this.isSymbolTile&&!r)continue;if(!1===this.isSymbolTile&&!l)continue;1===n.version&&C(`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),m=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&($m(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(m,c,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(t.map((t=>t.id))))}}let d,m,p,h;l.trim();const f={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=S(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?n.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{d||(d=t,m=e,b.call(this))}),void 0,!1,f):m={};const g=Object.keys(c.iconDependencies);g.length?n.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{d||(d=t,p=e,b.call(this))}),void 0,!1,f):p={};const y=Object.keys(c.patternDependencies);function b(){if(d)return r(d);if(m&&p&&h){const t=new Gm(m),e=new ku(p,h);for(const n in s){const r=s[n];r instanceof Nd?($m(r.layers,this.zoom,i),bd(r,m,t.positions,p,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom)):r.hasPattern&&(r instanceof Pc||r instanceof ic||r instanceof Mc)&&($m(r.layers,this.zoom,i),r.addFeatures(c,this.tileID.canonical,e.patternPositions,i))}this.status="done",r(null,{buckets:v(s).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?m:null,iconMap:this.returnDependencies?p:null,glyphPositions:this.returnDependencies?t.positions:null})}}y.length?n.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{d||(d=t,h=e,b.call(this))}),void 0,!1,f):h={},b.call(this)}}function $m(t,e,i){const n=new po(e);for(const e of t)e.recalculate(n,i)}class Km{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{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]))}}}function Jm(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=Tt(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new _c.VectorTile(new nu(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)}var Qm={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],conic:!0,initializeConstants(){if(this.constants&&nl(this.parallels,this.constants.parallels))return;const t=Math.sin(d(this.parallels[0])),e=(t+Math.sin(d(this.parallels[1])))/2,i=1+t*(2*e-t),n=Math.sqrt(i)/e;this.constants={n:e,c:i,r0:n,parallels:this.parallels}},project(t,e){this.initializeConstants();const i=d(t-this.center[0]),n=d(e),{n:r,c:o,r0:a}=this.constants,s=Math.sqrt(o-2*r*Math.sin(n))/r;return{x:s*Math.sin(i*r),y:s*Math.cos(i*r)-a}},unproject(t,e){this.initializeConstants();const{n:i,c:n,r0:r}=this.constants,o=r+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=d(this.center[0])*i;a=y(a,-Math.PI-s,Math.PI-s);const l=m(a/i)+this.center[0],c=Math.asin(g((n-(t*t+o*o)*i*i)/(2*i),-1,1)),u=g(m(c),-85.051129,ss);return new Ja(l,u)}};const tp=1.340264,ep=-.081106,ip=893e-6,np=.003796,rp=Math.sqrt(3)/2;var op={name:"equalEarth",center:[0,0],range:[3.5,7],project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const i=Math.asin(rp*Math.sin(e)),n=i*i,r=n*n*n;return{x:.5*(t*Math.cos(i)/(rp*(tp+3*ep*n+r*(7*ip+9*np*n)))/Math.PI+.5),y:1-.5*(i*(tp+ep*n+r*(ip+np*n))/Math.PI+1)}},unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,n=i*i,r=n*n*n;for(let t,o,a,s=0;s<12&&(o=i*(tp+ep*n+r*(ip+np*n))-e,a=tp+3*ep*n+r*(7*ip+9*np*n),t=o/a,i=g(i-t,-Math.PI/3,Math.PI/3),n=i*i,r=n*n*n,!(Math.abs(t)<1e-12));++s);const o=rp*t*(tp+3*ep*n+r*(7*ip+9*np*n))/Math.cos(i),a=Math.asin(Math.sin(i)/rp),s=g(180*o/Math.PI,-180,180),l=g(180*a/Math.PI,-85.051129,ss);return new Ja(s,l)}},ap={name:"equirectangular",wrap:!0,center:[0,0],range:[3.5,7],project:(t,e)=>({x:.5+t/360,y:.5-e/360}),unproject(t,e){const i=360*(t-.5),n=g(360*(.5-e),-85.051129,ss);return new Ja(i,n)}};const sp=Math.PI/2;function lp(t){return Math.tan((sp+t)/2)}var cp={name:"lambertConformalConic",range:[3.5,7],center:[0,30],parallels:[30,30],conic:!0,initializeConstants(){if(this.constants&&nl(this.parallels,this.constants.parallels))return;const t=d(this.parallels[0]),e=d(this.parallels[1]),i=Math.cos(t),n=t===e?Math.sin(t):Math.log(i/Math.cos(e))/Math.log(lp(e)/lp(t)),r=i*Math.pow(lp(t),n)/n;this.constants={n,f:r,parallels:this.parallels}},project(t,e){this.initializeConstants(),e=d(e),t=d(t-this.center[0]);const i=1e-6,{n,f:r}=this.constants;r>0?e<-sp+i&&(e=-sp+i):e>sp-i&&(e=sp-i);const o=r/Math.pow(lp(e),n),a=o*Math.sin(n*t),s=r-o*Math.cos(n*t);return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+.5)}},unproject(t,e){this.initializeConstants(),t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this.constants,r=n-e,o=Math.sign(r),a=Math.sign(i)*Math.sqrt(t*t+r*r);let s=Math.atan2(t,Math.abs(r))*o;r*i<0&&(s-=Math.PI*Math.sign(t)*o);const l=g(m(s/i)+this.center[0],-180,180),c=g(m(2*Math.atan(Math.pow(n/a,1/i))-sp),-85.051129,ss);return new Ja(l,c)}},up={name:"mercator",wrap:!0,center:[0,0],project:(t,e)=>({x:es(t),y:is(e)}),unproject(t,e){const i=rs(t),n=os(e);return new Ja(i,n)}};const dp=d(ss);var mp={name:"naturalEarth",center:[0,0],range:[3.5,7],project(t,e){const i=(e=d(e))*e,n=i*i;return{x:.5*((t=d(t))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1)}},unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const t=o*o;r=(i*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-e)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),i=g(i-r,-dp,dp)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const a=g(m(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=m(i);return new Ja(a,s)}};const pp=d(ss),hp={albers:Qm,equalEarth:op,equirectangular:ap,lambertConformalConic:cp,mercator:up,naturalEarth:mp,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],project(t,e){e=d(e),t=d(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,a=.5*(t*n+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)}},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 a=0,s=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,d=Math.cos(i/2),m=Math.sin(i/2),p=2*d*m,h=m*m,f=1-u*d*d,_=f?1/f:0,y=f?Math.acos(r*d)*Math.sqrt(1/f):0,b=.5*(2*y*r*m+2*i/Math.PI)-t,v=.5*(y*o+n)-e,M=.5*_*(u*h+y*r*d*c)+1/Math.PI,x=_*(p*l/4-y*o*m),w=.125*_*(l*m-y*o*u*p),A=.5*_*(c*d+y*h*r)+.5,L=x*w-A*M;a=(v*x-b*A)/L,s=(b*w-v*M)/L,i=g(i-a,-Math.PI,Math.PI),n=g(n-s,-pp,pp)}while((Math.abs(a)>o||Math.abs(s)>o)&&--r>0);return new Ja(m(i),m(n))}}};t.ARRAY_TYPE=Is,t.AUTH_ERR_MSG=tt,t.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},T(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=I()?t:s,this.scheduler=new im}send(t,e,i,n,r=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[a]=i);const s=W(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!i,targetMapId:n,mustQueue:r,sourceMapId:this.mapId,data:_r(e,s)},s),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,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||I()){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(gr(e.error)):i(null,gr(e.data)))}else{const i=W(this.globalScope)?void 0:[],n=e.hasCallback?(e,n)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?_r(e):null,data:_r(n,i)},i)}:t=>{},r=gr(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)[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)}},t.CanonicalTileID=om,t.Color=me,t.ColorMode=Bm,t.CullFaceMode=jm,t.DEMData=Dm,t.DataConstantProperty=xo,t.DedupedRequest=Km,t.DepthMode=Pm,t.EXTENT=Za,t.Elevation=class{getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){null==e&&(e=null);const n=this._source();if(!n)return e;if(t.y<0||t.y>1)return e;const r=n.getSource().maxzoom,o=1<{t[2]=this.exaggeration()*r.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,n=e.tileID,r=1<this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!et(t))return t;const i=rt(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!et(t))return t;const i=rt(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e){if(!et(t))return t;const i=rt(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=rt(t);return et(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,ot(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!et(t))return t;const n=rt(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==n.authority&&512===i?"@2x":""}${V.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${U.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${U.TILE_URL_VERSION}${n.path}`);const r=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(n.params)||U.ACCESS_TOKEN;return U.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,r)}canonicalizeTileURL(t,e){const i=rt(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${U.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${U.TILE_URL_VERSION}/`,"")}`;let r=i.params;return e&&(r=r.filter((t=>!t.match(/^access_token=/)))),r.length&&(n+=`?${r.join("&")}`),n}canonicalizeTileset(t,e){const i=!!e&&et(e),n=[];for(const e of t.tiles||[])it(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",n=rt(U.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!U.REQUIRE_ACCESS_TOKEN)return ot(t);if(e=e||U.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||""}`),ot(t)}},t.ResourceType=wt,t.SegmentVector=Ga,t.SourceCache=qm,t.StencilMode=Im,t.StructArrayLayout1ui2=Qo,t.StructArrayLayout2f1f2i16=Xo,t.StructArrayLayout2i4=Po,t.StructArrayLayout2ui4=Jo,t.StructArrayLayout3f12=Bo,t.StructArrayLayout3ui6=Uo,t.StructArrayLayout4i8=No,t.Texture=Kd,t.Tile=Mm,t.Transitionable=_o,t.Uniform1f=La,t.Uniform1i=class extends Aa{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 Aa{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 Aa{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=za,t.UniformColor=Ta,t.UniformMatrix2f=class extends Aa{constructor(t,e){super(t,e),this.current=Ea}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 Aa{constructor(t,e){super(t,e),this.current=Sa}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 Aa{constructor(t,e){super(t,e),this.current=ka}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=am,t.ValidationError=qt,t.VectorTileWorkerSource=class extends Rt{constructor(t,e,i,n,r){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=r||Jm,this.loading={},this.loaded={},this.deduped=new Km(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,n=t&&t.request,r=n&&n.collectResourceTiming,o=this.loading[i]=new Zm(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 _c.VectorTile(new nu(c));const d=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const o={};if(r){const t=em(n);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,M({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,n=t.uid,r=this;if(i&&i[n]){const o=i[n];o.showCollisionBoxes=t.showCollisionBoxes,o.enableTerrain=!!t.enableTerrain;const a=(t,i)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,r.layerIndex,this.availableImages,r.actor,n)),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,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()}},t.WritingMode=Su,t.ZoomHistory=yr,t.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},t.addDynamicAttributes=Od,t.altitudeFromMercatorZ=as,t.asyncAll=b,t.bezier=f,t.bindAll=T,t.boundsAttributes=bm,t.bufferConvexPolygon=function(t,e){const i=[];for(let n=0;nbt&&(t.getActor().send("enforceCacheSizeLimit",yt),xt=0)},t.clamp=g,t.clearTileCache=function(t){const e=s.caches.delete(ft);t&&e.catch(t).then((()=>t()))},t.clipLine=Qu,t.clone=function(t){var e=new Is(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.clone$1=function(t){var e=new Is(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$2=O,t.collisionCircleLayout=Xc,t.config=U,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},t.create=qs,t.create$1=function(){var t=new Is(16);return Is!=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$2=Bs,t.createExpression=mn,t.createLayout=Do,t.createStyleLayer=function(t){return"custom"===t.type?new Wd(t):new Hd[t.type](t)},t.cross=function(t,e,i){var n=e[0],r=e[1],o=e[2],a=i[0],s=i[1],l=i[2];return t[0]=r*l-o*s,t[1]=o*a-n*l,t[2]=n*s-r*a,t},t.degToRad=d,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=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.dot$1=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},t.ease=_,t.easeCubicInOut=h,t.emitValidationErrors=sr,t.endsWith=k,t.enforceCacheSizeLimit=function(t){vt(),_t&&_t.then((e=>{e.keys().then((i=>{for(let n=0;no&&(n+=(t[r]-o)*(t[r]-o)),e[r]{}}},t.identity=Ys,t.identity$1=el,t.invert=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],d=e[9],m=e[10],p=e[11],h=e[12],f=e[13],_=e[14],g=e[15],y=i*s-n*a,b=i*l-r*a,v=i*c-o*a,M=n*l-r*s,x=n*c-o*s,w=r*c-o*l,A=u*f-d*h,L=u*_-m*h,z=u*g-p*h,T=d*_-m*f,k=d*g-p*f,S=m*g-p*_,E=y*S-b*k+v*T+M*z-x*L+w*A;return E?(t[0]=(s*S-l*k+c*T)*(E=1/E),t[1]=(r*k-n*S-o*T)*E,t[2]=(f*w-_*x+g*M)*E,t[3]=(m*x-d*w-p*M)*E,t[4]=(l*z-a*S-c*L)*E,t[5]=(i*S-r*z+o*L)*E,t[6]=(_*v-h*w-g*b)*E,t[7]=(u*w-m*v+p*b)*E,t[8]=(a*k-s*z+c*A)*E,t[9]=(n*z-i*k-o*A)*E,t[10]=(h*x-f*v+g*y)*E,t[11]=(d*v-u*x-p*y)*E,t[12]=(s*L-a*T-l*A)*E,t[13]=(i*T-n*L+r*A)*E,t[14]=(f*b-h*M-_*y)*E,t[15]=(u*M-d*b+m*y)*E,t):null},t.isMapAuthenticated=function(t){return ht.has(t)},t.isMapboxURL=et,t.latFromMercatorY=os,t.len=Js,t.length=Ws,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=Jm,t.makeRequest=zt,t.mercatorXfromLng=es,t.mercatorYfromLat=is,t.mercatorZfromAltitude=ns,t.mul=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},t.mul$1=js,t.mul$2=Ks,t.multiply=Rs,t.multiply$1=Hs,t.nextPowerOfTwo=L,t.normalize=Vs,t.normalize$1=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],a=i*i+n*n+r*r+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=i*a,t[1]=n*a,t[2]=r*a,t[3]=o*a,t},t.number=ri,t.ortho=function(t,e,i,n,r,o,a){var s=1/(e-i),l=1/(n-r),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]=(r+n)*l,t[14]=(a+o)*c,t[15]=1,t},t.pbf=nu,t.perspective=function(t,e,i,n,r){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!=r&&r!==1/0?(t[10]=(r+n)*(o=1/(n-r)),t[14]=2*r*n*o):(t[10]=-1,t[14]=-2*n),t},t.pick=function(t,e){const i={};for(let n=0;nthis._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 a=r[o];a||(a=r[o]=[]),a.push(e)}}}const{ImageBitmap:r}=t.window;class o{loadTile(e,i){const{uid:n,encoding:o,rawImageData:a,padding:s,buildQuadTree:l}=e,c=r&&a instanceof r?this.getImageData(a,s):a;i(null,new t.DEMData(n,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 n=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:n.width,height:n.height},n.data)}}var a=function t(e,i){var n,r=e&&e.type;if("FeatureCollection"===r)for(n=0;n=Math.abs(s)?i-l+s:s-l+i,i=l}i+n>=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 n=[];for(const e of i)n.push(new t.pointGeometry(e[0],e[1]));e.push(n)}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 m=t.vectorTile.VectorTileFeature,p=h;function h(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}h.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 A(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,a=i.length,s=0;s>1;T(t,e,a,n,r,o%2),z(t,e,i,n,a-1,o+1),z(t,e,i,a+1,r,o+1)}function T(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const a=r-n+1,s=i-n+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);T(t,e,i,Math.max(n,Math.floor(i-s*c/a+u)),Math.min(r,Math.floor(i+(a-s)*c/a+u)),o)}const a=e[2*i+o];let s=n,l=r;for(k(t,e,n,i),e[2*r+o]>a&&k(t,e,n,r);sa;)l--}e[2*n+o]===a?k(t,e,n,l):(l++,k(t,e,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function k(t,e,i,n){S(t,i,n),S(e,2*i,2*n),S(e,2*i+1,2*n+1)}function S(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function E(t,e,i,n){const r=t-i,o=e-n;return r*r+o*o}_.fromVectorTileJs=y,_.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var n in t)i[n]=new p(t[n].features,e),i[n].name=n,i[n].version=e.version,i[n].extent=e.extent;return y({layers:i})},_.GeoJSONWrapper=g;const O=t=>t[0],D=t=>t[1];class C{constructor(t,e=O,i=D,n=64,r=Float64Array){this.nodeSize=n,this.points=t;const o=t.length<65536?Uint16Array:Uint32Array,a=this.ids=new o(t.length),s=this.coords=new r(2*t.length);for(let n=0;n=i&&c<=r&&u>=n&&u<=o&&l.push(t[a]);continue}const h=Math.floor((p+m)/2);c=e[2*h],u=e[2*h+1],c>=i&&c<=r&&u>=n&&u<=o&&l.push(t[h]);const f=(d+1)%2;(0===d?i<=c:n<=u)&&(s.push(p),s.push(h-1),s.push(f)),(0===d?r>=c:o>=u)&&(s.push(h+1),s.push(m),s.push(f))}return l}(this.ids,this.coords,t,e,i,n,this.nodeSize)}within(t,e,i){return function(t,e,i,n,r,o){const a=[0,t.length-1,0],s=[],l=r*r;for(;a.length;){const c=a.pop(),u=a.pop(),d=a.pop();if(u-d<=o){for(let r=d;r<=u;r++)E(e[2*r],e[2*r+1],i,n)<=l&&s.push(t[r]);continue}const m=Math.floor((d+u)/2),p=e[2*m],h=e[2*m+1];E(p,h,i,n)<=l&&s.push(t[m]);const f=(c+1)%2;(0===c?i-r<=p:n-r<=h)&&(a.push(d),a.push(m-1),a.push(f)),(0===c?i+r>=p:n+r>=h)&&(a.push(m+1),a.push(u),a.push(f))}return s}(this.ids,this.coords,t,e,i,this.nodeSize)}}const P={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},N=Math.fround||(I=new Float32Array(1),t=>(I[0]=+t,I[0]));var I;class B{constructor(t){this.options=H(Object.create(P),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:n,nodeSize:r}=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 C(a,U,V,r,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 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),a=this.getClusters([-180,n,r,o],e);return t.concat(a)}const a=this.trees[this._limitZoom(e)],s=a.range(W(i),F(o),W(r),F(n)),l=[];for(const t of s){const e=a.points[t];l.push(e.numPoints?j(e):this.points[e.index])}return l}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.points[e];if(!o)throw new Error(n);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=r.within(o.x,o.y,a),l=[];for(const e of s){const i=r.points[e];i.parentId===t&&l.push(i.numPoints?j(i):this.points[i.index])}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:a}=this.options,s=a/o,l=(i-s)/r,c=(i+1+s)/r,u={features:[]};return this._addTileFeatures(n.range((e-s)/r,l,(e+1+s)/r,c),n.points,e,i,r,u),0===e&&this._addTileFeatures(n.range(1-s/r,l,1,c),n.points,r,i,r,u),e===r-1&&this._addTileFeatures(n.range(0,l,s/r,c),n.points,-1,i,r,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,n,r){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(t,o.cluster_id,i,n,r):re&&(d+=i.numPoints||1)}if(d>u&&d>=a){let t=r.x*u,a=r.y*u,s=o&&u>1?this._map(r,!0):null;const m=(n<<5)+(e+1)+this.points.length;for(const i of c){const n=l.points[i];if(n.zoom<=e)continue;n.zoom=e;const c=n.numPoints||1;t+=n.x*c,a+=n.y*c,n.parentId=m,o&&(s||(s=this._map(r,!0)),o(s,this._map(n)))}r.parentId=m,i.push(Y(t/d,a/d,m,d,s))}else if(i.push(r),d>1)for(const t of c){const n=l.points[t];n.zoom<=e||(n.zoom=e,i.push(n))}}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?H({},t.properties):t.properties;const i=this.points[t.index].properties,n=this.options.map(i);return e&&n===i?H({},n):n}}function Y(t,e,i,n,r){return{x:N(t),y:N(e),zoom:1/0,id:i,parentId:-1,numPoints:n,properties:r}}function R(t,e){const[i,n]=t.geometry.coordinates;return{x:N(W(i)),y:N(F(n)),zoom:1/0,index:e,parentId:-1}}function j(t){return{type:"Feature",id:t.id,properties:q(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),X(t.y)]}};var e}function q(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return H(H({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function W(t){return t/360+.5}function F(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 X(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function H(t,e){for(const i in e)t[i]=e[i];return t}function U(t){return t.x}function V(t){return t.y}function G(t,e,i,n){for(var r,o=n,a=i-e>>1,s=i-e,l=t[e],c=t[e+1],u=t[i],d=t[i+1],m=e+3;mo)r=m,o=p;else if(p===o){var h=Math.abs(m-a);hn&&(r-e>3&&G(t,e,r,n),t[r+2]=o,i-r>3&&G(t,r,i,n))}function Z(t,e,i,n,r,o){var a=r-i,s=o-n;if(0!==a||0!==s){var l=((t-i)*a+(e-n)*s)/(a*a+s*s);l>1?(i=r,n=o):l>0&&(i+=a*l,n+=s*l)}return(a=t-i)*a+(s=e-n)*s}function $(t,e,i,n){var r={id:void 0===t?null:t,type:e,geometry:i,tags:n,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 n=0;n0&&(a+=n?(r*c-l*o)/2:Math.sqrt(Math.pow(l-r,2)+Math.pow(c-o,2))),r=l,o=c}var u=e.length-3;e[2]=1,G(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,n){for(var r=0;r1?1:i}function rt(t,e,i,n,r,o,a,s){if(n/=e,o>=(i/=e)&&a=n)return null;for(var l=[],c=0;c=i&&h=n)){var f=[];if("Point"===m||"MultiPoint"===m)ot(d,f,i,n,r);else if("LineString"===m)at(d,f,i,n,r,!1,s.lineMetrics);else if("MultiLineString"===m)lt(d,f,i,n,r,!1);else if("Polygon"===m)lt(d,f,i,n,r,!0);else if("MultiPolygon"===m)for(var _=0;_=i&&a<=n&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function at(t,e,i,n,r,o,a){for(var s,l,c=st(t),u=0===r?ut:dt,d=t.start,m=0;mi&&(l=u(c,p,h,_,g,i),a&&(c.start=d+s*l)):y>n?b=i&&(l=u(c,p,h,_,g,i),v=!0),b>n&&y<=n&&(l=u(c,p,h,_,g,n),v=!0),!o&&v&&(a&&(c.end=d+s*l),e.push(c),c=st(t)),a&&(d+=s)}var M=t.length-3;p=t[M],h=t[M+1],f=t[M+2],(y=0===r?p:h)>=i&&y<=n&&ct(c,p,h,f),M=c.length-3,o&&M>=3&&(c[M]!==c[0]||c[M+1]!==c[1])&&ct(c,c[0],c[1],c[2]),c.length&&e.push(c)}function st(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function lt(t,e,i,n,r,o){for(var a=0;aa.maxX&&(a.maxX=u),d>a.maxY&&(a.maxY=d)}return a}function gt(t,e,i,n){var r=e.geometry,o=e.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&e.size<(r?a:n))i.numPoints+=e.length/3;else{for(var s=[],l=0;la)&&(i.numSimplified++,s.push(e[l]),s.push(e[l+1])),i.numPoints++;r&&function(t,e){for(var i=0,n=0,r=t.length,o=r-2;n0===e)for(n=0,r=t.length;n24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var n=0;n1&&console.time("creation"),m=this.tiles[d]=_t(t,e,i,n,l),this.tileCoords.push({z:e,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,n,m.numFeatures,m.numPoints,m.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(m.source=t,r){if(e===l.maxZoom||e===r)continue;var h=1<1&&console.time("clipping");var f,_,g,y,b,v,M=.5*l.buffer/l.extent,x=.5-M,w=.5+M,A=1+M;f=_=g=y=null,b=rt(t,u,i-M,i+w,0,m.minX,m.maxX,l),v=rt(t,u,i+x,i+A,0,m.minX,m.maxX,l),t=null,b&&(f=rt(b,u,n-M,n+w,1,m.minY,m.maxY,l),_=rt(b,u,n+x,n+A,1,m.minY,m.maxY,l),b=null),v&&(g=rt(v,u,n-M,n+w,1,m.minY,m.maxY,l),y=rt(v,u,n+x,n+A,1,m.minY,m.maxY,l),v=null),c>1&&console.timeEnd("clipping"),s.push(f||[],e+1,2*i,2*n),s.push(_||[],e+1,2*i,2*n+1),s.push(g||[],e+1,2*i+1,2*n),s.push(y||[],e+1,2*i+1,2*n+1)}}},bt.prototype.getTile=function(t,e,i){var n=this.options,r=n.extent,o=n.debug;if(t<0||t>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,u=e,d=i;!l&&c>0;)c--,u=Math.floor(u/2),d=Math.floor(d/2),l=this.tiles[vt(c,u,d)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,d),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,d,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[s]?ht(this.tiles[s],r):null):null};class xt extends t.VectorTileWorkerSource{constructor(t,e,i,n,r){super(t,e,i,n,Mt),r&&(this.loadGeoJSON=r)}loadData(e,i){const n=e&&e.request,r=n&&n.collectResourceTiming;this.loadGeoJSON(e,((o,s)=>{if(o||!s)return i(o);if("object"!=typeof s)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{a(s,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const n=s.features.filter((t=>i.value.evaluate({zoom:0},t)));s={type:"FeatureCollection",features:n}}this._geoJSONIndex=e.cluster?new B(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const n={},r={},o={accumulated:null,zoom:0},a={properties:null},s=Object.keys(i);for(const e of s){const[o,a]=i[e],s=t.createExpression(a),l=t.createExpression("string"==typeof o?[o,["accumulated"],["get",e]]:o);n[e]=s.value,r[e]=l.value}return e.map=t=>{a.properties=t;const e={};for(const t of s)e[t]=n[t].evaluate(o,a);return e},e.reduce=(t,e)=>{a.properties=e;for(const e of s)o.accumulated=t[e],t[e]=r[e].evaluate(o,a)},e}(e)).load(s.features):function(t,e){return new bt(t,e)}(s,e.geojsonVtOptions)}catch(o){return i(o)}this.loaded={};const l={};if(r){const i=t.getPerformanceMeasurement(n);i&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)t.getJSON(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class wt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:xt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}clearCaches(t,e,i){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],i()}checkIfReady(t,e,i){i()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,i){this.isSpriteLoaded[e]=i;for(const n in this.workerSources[e]){const r=this.workerSources[e][n];for(const e in r)r[e]instanceof t.VectorTileWorkerSource&&(r[e].isSpriteLoaded=i,r[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const n=this.workerSources[t][i];for(const t in n)n[t].availableImages=e}i()}enableTerrain(t,e,i){this.terrain=e,i()}setProjection(e,i){this.projections[e]=t.getProjection(i)}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(e,i,n){const r=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).loadTile(r,n)}loadDEMTile(e,i,n){const r=this.enableTerrain?t.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(e,i.source).loadTile(r,n)}reloadTile(e,i,n){const r=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).reloadTile(r,n)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const n=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==n.removeSource?n.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,n){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();n(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){n(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new n),e}getWorkerSource(t,e,i){return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][i]||(this.workerSources[t][e][i]=new this.workerSourceTypes[e]({send:(e,i,n,r,o,a)=>{this.actor.send(e,i,n,t,o,a)},scheduler:this.actor.scheduler},this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded[t])),this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new o),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(t,e,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new wt(self)),wt})),r(["./shared"],(function(t){var e=i;function i(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(i);try{e=new Worker(n),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(n),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===n[e=t&&t.failIfMajorPerformanceCaveat]&&(n[e]=function(t){var e,n=function(t){var e=document.createElement("canvas"),n=Object.create(i.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,e.getContext("webgl",n)||e.getContext("experimental-webgl",n)}(t);if(!n)return!1;try{e=n.createShader(n.VERTEX_SHADER)}catch(t){return!1}return!(!e||n.isContextLost())&&(n.shaderSource(e,"void main() {}"),n.compileShader(e),!0===n.getShaderParameter(e,n.COMPILE_STATUS))}(e)),n[e]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var e}(t)}var n={};function r(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i{t.window.removeEventListener("click",u,!0)}),0)},o.mousePos=function(t,e){const i=t.getBoundingClientRect();return d(t,i,e)},o.touchPos=function(t,e){const i=t.getBoundingClientRect(),n=[];for(let r=0;r=0?0:e.button},o.remove=function(t){t.parentNode&&t.parentNode.removeChild(t)};class p{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(e,i,n){const r=t.dot(i,this.dir);if(Math.abs(r)<1e-6)return!1;const o=t.dot(t.sub(t.create(),e,this.pos),i)/r,a=t.scaleAndAdd(t.create(),this.pos,this.dir,o);return t.copy(n,a),!0}}class h{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(e,i,n){const r=Math.pow(2,n),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((n=>{const o=t.transformMat4([],n,e),a=1/o[3]/i*r;return t.mul(o,o,[a,a,1/o[3],a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.sub([],o[e[0]],o[e[1]]),n=t.sub([],o[e[2]],o[e[1]]),r=t.normalize([],t.cross([],i,n)),a=-t.dot(r,o[e[1]]);return r.concat(a)}));return new h(o,a)}}class f{constructor(e,i){this.min=e,this.max=i,this.center=t.scale([],t.add([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],n=t.clone(this.min),r=t.clone(this.max);for(let t=0;t=0;if(0===a)return 0;a!==i.length&&(n=!1)}if(n)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;rthis.max[t]-this.min[t])return 0}return 1}}function _(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class g extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(t,e){if(!t)return!0;let i=0;for(const n of t){if(n[0]{this.ready=!0}))}broadcast(e,i,n){t.asyncAll(this.actors,((t,n)=>{t.send(e,i,n)}),n=n||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)}}function E(e,i,n){return i*(t.EXTENT/(e.tileSize*Math.pow(2,n-e.tileID.overscaledZ)))}S.Actor=t.Actor;class O{constructor(t,e,i,n){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map((t=>n.pointCoordinate3D(t))),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(e,i){let n,r;if(e instanceof t.pointGeometry||"number"==typeof e[0]){const o=t.pointGeometry.convert(e);n=[t.pointGeometry.convert(e)],r=i.isPointAboveHorizon(o)}else{const o=t.pointGeometry.convert(e[0]),a=t.pointGeometry.convert(e[1]);n=[o,a],r=t.polygonizeBounds(o,a).every((t=>i.isPointAboveHorizon(t)))}return new O(n,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],r=t.polygonizeBounds(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),t.bufferConvexPolygon(r,e)}containsTile(e,i,n){const r=e.queryPadding+1,o=e.tileID.wrap,a=n?this._bufferedCameraMercator(r,i).map((i=>t.getTilePoint(e.tileTransform,i,o))):this._bufferedScreenMercator(r,i).map((i=>t.getTilePoint(e.tileTransform,i,o))),s=this.screenGeometryMercator.map((i=>t.getTileVec3(e.tileTransform,i,o))),l=s.map((e=>new t.pointGeometry(e[0],e[1]))),c=i.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),u=t.getTileVec3(e.tileTransform,c,o),d=s.map((e=>{const i=t.sub(e,e,u);return t.normalize(i,i),new p(u,i)})),m=E(e,1,i.zoom);if(t.polygonIntersectsBox(a,0,0,t.EXTENT,t.EXTENT))return{queryGeometry:this,tilespaceGeometry:l,tilespaceRays:d,bufferedTilespaceGeometry:a,bufferedTilespaceBounds:(h=t.getBounds(a),h.min.x=t.clamp(h.min.x,0,t.EXTENT),h.min.y=t.clamp(h.min.y,0,t.EXTENT),h.max.x=t.clamp(h.max.x,0,t.EXTENT),h.max.y=t.clamp(h.max.y,0,t.EXTENT),h),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:m};var h}_bufferedScreenMercator(t,e){const i=D(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{const n=this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(t,e){const i=D(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{const n=this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t)));return this._cameraRaycastCache[i]=n,n}}}function D(t){return 100*t|0}function C(e,i,n){const r=function(r,o){if(r)return n(r);if(o){const r=t.pick(t.extend(o,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);o.vector_layers&&(r.vectorLayers=o.vector_layers,r.vectorLayerIds=r.vectorLayers.map((t=>t.id))),r.tiles=i.canonicalizeTileset(r,e.url),n(null,r)}};return e.url?t.getJSON(i.transformRequest(i.normalizeSourceURL(e.url),t.ResourceType.Source),r):t.exported.frame((()=>r(null,e)))}class P{constructor(e,i,n){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=n||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),n=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),r=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),a=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y