/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.13.0/LICENSE.txt */ var maplibregl=function(){"use strict";function e(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}function t(e,t){this.x=e,this.y=t}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,i;"function"==typeof SuppressedError&&SuppressedError,t.prototype={clone(){return new t(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=n,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-n*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:t},t.convert=function(e){if(e instanceof t)return e;if(Array.isArray(e))return new t(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new t(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(i)return n;function e(e,t,r,n){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=n}return i=1,n=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,n=0;n<8;n++){var i=this.sampleCurveX(r)-e;if(Math.abs(i)i?o=r:a=r,r=.5*(a-o)+o;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},n}(),o=r(s);let a,l;var u,c="undefined"!=typeof Float32Array?Float32Array:Array;function h(e,t,r){var n=t[0],i=t[1],s=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*o,e}u=new c(4),c!=Float32Array&&(u[0]=0,u[1]=0,u[2]=0,u[3]=0);const p=8192;function f(e,t,r){return Math.min(r,Math.max(t,e))}function d(e,...t){for(const r of t)for(const t in r)e[t]=r[t];return e}function y(e,t,r){const n={};for(const r in e)n[r]=t.call(this,e[r],r,e);return n}function m(e){return Array.isArray(e)?e.map(m):"object"==typeof e&&e?y(e,m):e}new o(.25,.1,.25,1);const g={};function x(e){g[e]||("undefined"!=typeof console&&console.warn(e),g[e]=!0)}function v(e,t,r){return(r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function b(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}function w(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}let _,S;function A(e,t,r,n){return e.addEventListener(t,r,n),{unsubscribe:()=>{e.removeEventListener(t,r,n)}}}function T(e){return e*Math.PI/180}class I{constructor(e,t,r){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(r=i[2]);for(let e=0;e=u[l+0]&&n>=u[l+1])?(o[h]=!0,s.push(i[h])):o[h]=!1}}}}_forEachCell(e,t,r,n,i,s,o,a){const l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n);for(let p=l;p<=c;p++)for(let l=u;l<=h;l++){const u=this.d*l+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(l),this._convertFromCellCoord(p+1),this._convertFromCellCoord(l+1)))&&i.call(this,e,t,r,n,u,s,o,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let r=0;for(let e=0;e":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const E=["type","source","source-layer","minzoom","maxzoom","filter","layout"];class M{constructor(e,t,r,n){this.message=(e?`${e}: `:"")+r,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}function D(e,...t){for(const r of t)for(const t in r)e[t]=r[t];return e}class P extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class F{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,r]of t)this.bindings[e]=r}concat(e){return new F(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const z={kind:"null"},B={kind:"number"},C={kind:"string"},V={kind:"boolean"},L={kind:"color"},O={kind:"projectionDefinition"},N={kind:"object"},R={kind:"value"},$={kind:"collator"},q={kind:"formatted"},U={kind:"padding"},G={kind:"colorArray"},j={kind:"numberArray"},X={kind:"resolvedImage"},Y={kind:"variableAnchorOffsetCollection"};function Z(e,t){return{kind:"array",itemType:e,N:t}}function H(e){if("array"===e.kind){const t=H(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const W=[z,B,C,V,L,O,q,N,Z(R),U,j,G,X,Y];function J(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!J(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of W)if(!J(e,t))return null}return`Expected ${H(e)} but found ${H(t)} instead.`}function K(e,t){return t.some((t=>t.kind===e.kind))}function Q(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function ee(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const te=.96422,re=.82521,ne=4/29,ie=6/29,se=3*ie*ie,oe=ie*ie*ie,ae=Math.PI/180,le=180/Math.PI;function ue(e){return(e%=360)<0&&(e+=360),e}function ce([e,t,r,n]){let i,s;const o=pe((.2225045*(e=he(e))+.7168786*(t=he(t))+.0606169*(r=he(r)))/1);e===t&&t===r?i=s=o:(i=pe((.4360747*e+.3850649*t+.1430804*r)/te),s=pe((.0139322*e+.0971045*t+.7141733*r)/re));const a=116*o-16;return[a<0?0:a,500*(i-o),200*(o-s),n]}function he(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pe(e){return e>oe?Math.pow(e,1/3):e/se+ne}function fe([e,t,r,n]){let i=(e+16)/116,s=isNaN(t)?i:i+t/500,o=isNaN(r)?i:i-r/200;return i=1*ye(i),s=te*ye(s),o=re*ye(o),[de(3.1338561*s-1.6168667*i-.4906146*o),de(-.9787684*s+1.9161415*i+.033454*o),de(.0719453*s-.2289914*i+1.4052427*o),n]}function de(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function ye(e){return e>ie?e*e*e:se*(e-ne)}const me=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function ge(e,t){return me(e,t)?e[t]:void 0}function xe(e){return parseInt(e.padEnd(2,e),16)/255}function ve(e,t){return be(t?e/100:e,0,1)}function be(e,t,r){return Math.min(Math.max(t,e),r)}function we(e){return!e.some(Number.isNaN)}const _e={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Se(e,t,r){return e+r*(t-e)}function Ae(e,t,r){return e.map(((e,n)=>Se(e,t[n],r)))}class Te{constructor(e,t,r,n=1,i=!0){this.r=e,this.g=t,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,r,n]))}static parse(e){if(e instanceof Te)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=ge(_e,e);if(t){const[e,r,n]=t;return[e/255,r/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let r=1;return[xe(e.slice(r,r+=t)),xe(e.slice(r,r+=t)),xe(e.slice(r,r+=t)),xe(e.slice(r,r+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,r,n,i,s,o,a,l,u,c,h,p]=t,f=[i||" ",a||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const e=[n,o,u].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[be(+r/t,0,1),be(+s/t,0,1),be(+l/t,0,1),h?ve(+h,p):1];if(we(e))return e}}return}}const r=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[e,t,n,i,s,o,a,l,u]=r,c=[n||" ",s||" ",a].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const e=[+t,be(+i,0,100),be(+o,0,100),l?ve(+l,u):1];if(we(e))return function([e,t,r,n]){function i(n){const i=(n+e/30)%12,s=t*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return e=ue(e),t/=100,r/=100,[i(0),i(8),i(4),n]}(e)}}}(e);return t?new Te(...t,!1):void 0}get rgb(){const{r:e,g:t,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[e/i,t/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,r,n,i]=ce(e),s=Math.sqrt(r*r+n*n);return[Math.round(1e4*s)?ue(Math.atan2(n,r)*le):NaN,s,t,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ce(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,r,n]=this.rgb;return`rgba(${[e,t,r].map((e=>Math.round(255*e))).join(",")},${n})`}static interpolate(e,t,r,n="rgb"){switch(n){case"rgb":{const[n,i,s,o]=Ae(e.rgb,t.rgb,r);return new Te(n,i,s,o,!1)}case"hcl":{const[n,i,s,o]=e.hcl,[a,l,u,c]=t.hcl;let h,p;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==s&&0!==s||(p=l)):(h=n,1!==u&&0!==u||(p=i));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+r*e}const[f,d,y,m]=function([e,t,r,n]){return e=isNaN(e)?0:e*ae,fe([r,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=p?p:Se(i,l,r),Se(s,u,r),Se(o,c,r)]);return new Te(f,d,y,m,!1)}case"lab":{const[n,i,s,o]=fe(Ae(e.lab,t.lab,r));return new Te(n,i,s,o,!1)}}}}Te.black=new Te(0,0,0,1),Te.white=new Te(1,1,1,1),Te.transparent=new Te(0,0,0,0),Te.red=new Te(1,0,0,1);class Ie{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const ke=["bottom","center","top"];class Ee{constructor(e,t,r,n,i,s){this.text=e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=i,this.verticalAlign=s}}class Me{constructor(e){this.sections=e}static fromString(e){return new Me([new Ee(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof Me?e:Me.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class De{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof De)return e;if("number"==typeof e)return new De([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new De(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,r){return new De(Ae(e.values,t.values,r))}}class Pe{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pe)return e;if("number"==typeof e)return new Pe([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Pe(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,r){return new Pe(Ae(e.values,t.values,r))}}class Fe{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Fe)return e;if("string"==typeof e){const t=Te.parse(e);if(!t)return;return new Fe([t])}if(!Array.isArray(e))return;const t=[];for(const r of e){if("string"!=typeof r)return;const e=Te.parse(r);if(!e)return;t.push(e)}return new Fe(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,r,n="rgb"){const i=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let s=0;s=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ne(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Le||e instanceof Te||e instanceof Ie||e instanceof Me||e instanceof De||e instanceof Pe||e instanceof Fe||e instanceof Ce||e instanceof Ve)return!0;if(Array.isArray(e)){for(const t of e)if(!Ne(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ne(e[t]))return!1;return!0}return!1}function Re(e){if(null===e)return z;if("string"==typeof e)return C;if("boolean"==typeof e)return V;if("number"==typeof e)return B;if(e instanceof Te)return L;if(e instanceof Le)return O;if(e instanceof Ie)return $;if(e instanceof Me)return q;if(e instanceof De)return U;if(e instanceof Pe)return j;if(e instanceof Fe)return G;if(e instanceof Ce)return Y;if(e instanceof Ve)return X;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=Re(t);if(r){if(r===e)continue;r=R;break}r=e}return Z(r||R,t)}return N}function $e(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Te||e instanceof Le||e instanceof Me||e instanceof De||e instanceof Pe||e instanceof Fe||e instanceof Ce||e instanceof Ve?e.toString():JSON.stringify(e)}class qe{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ne(e[1]))return t.error("invalid value");const r=e[1];let n=Re(r);const i=t.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new qe(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ue={string:C,number:B,boolean:V,object:N};class Ge{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const i=e[0];if("array"===i){let i,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in Ue)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=Ue[r],n++}else i=R;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++}r=Z(i,s)}else{if(!Ue[i])throw new Error(`Types doesn't contain name = ${i}`);r=Ue[i]}const s=[];for(;ne.outputDefined()))}}const je={"to-boolean":V,"to-color":L,"to-number":B,"to-string":C};class Xe{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0];if(!je[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return t.error("Expected one argument.");const n=je[r],i=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Oe(t[0],t[1],t[2],t[3]),!r))return new Te(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new ze(r||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const r of this.args){t=r.evaluate(e);const n=De.parse(t);if(n)return n}throw new ze(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const r of this.args){t=r.evaluate(e);const n=Pe.parse(t);if(n)return n}throw new ze(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const r of this.args){t=r.evaluate(e);const n=Fe.parse(t);if(n)return n}throw new ze(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const r of this.args){t=r.evaluate(e);const n=Ce.parse(t);if(n)return n}throw new ze(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new ze(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Me.fromString($e(this.args[0].evaluate(e)));case"resolvedImage":return Ve.fromString($e(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return $e(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const Ye=["Unknown","Point","LineString","Polygon"];class Ze{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ye[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Te.parse(e),this._parseColorCache.set(e,t)),t}}class He{constructor(e,t,r=[],n,i=new F,s=[]){this.registry=e,this.path=r,this.key=r.map((e=>`[${e}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=t}parse(e,t,r,n,i={}){return t?this.concat(t,r,n)._parse(e,i):this._parse(e,i)}_parse(e,t){function r(e,t,r){return"assert"===r?new Ge(t,[e]):"coerce"===r?new Xe(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[n];if(i){let n=i.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,i=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(i.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(i.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(i.kind)||"colorArray"===e.kind&&["value","string","array"].includes(i.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(i.kind))n=r(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,i))return null}else n=r(n,e,t.typeAnnotation||"assert")}if(!(n instanceof qe)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const e=new Ze;try{n=new qe(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,r){const n="number"==typeof e?this.path.concat(e):this.path,i=r?this.scope.concat(r):this.scope;return new He(this.registry,this._isConstant,n,t||null,i,this.errors)}error(e,...t){const r=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new P(r,e))}checkSubtype(e,t){const r=J(e,t);return r&&this.error(r),r}}class We{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new ze(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t!==Math.floor(t))throw new ze(`Array index must be an integer, but found ${t} instead.`);return r[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class Qe{constructor(e,t){this.type=V,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,R),n=t.parse(e[2],2,R);return r&&n?K(r.type,[V,C,B,z,R])?new Qe(r,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${H(r.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!r)return!1;if(!Q(t,["boolean","string","number","null"]))throw new ze(`Expected first argument to be of type boolean, string, number or null, but found ${H(Re(t))} instead.`);if(!Q(r,["string","array"]))throw new ze(`Expected second argument to be of type array or string, but found ${H(Re(r))} instead.`);return r.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class et{constructor(e,t,r){this.type=B,this.needle=e,this.haystack=t,this.fromIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,R),n=t.parse(e[2],2,R);if(!r||!n)return null;if(!K(r.type,[V,C,B,z,R]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${H(r.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,B);return i?new et(r,n,i):null}return new et(r,n)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Q(t,["boolean","string","number","null"]))throw new ze(`Expected first argument to be of type boolean, string, number or null, but found ${H(Re(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),Q(r,["string"])){const e=r.indexOf(t,n);return-1===e?-1:[...r.slice(0,e)].length}if(Q(r,["array"]))return r.indexOf(t,n);throw new ze(`Expected second argument to be of type array or string, but found ${H(Re(r))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class tt{constructor(e,t,r,n,i,s){this.inputType=e,this.type=t,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const i={},s=[];for(let o=2;oNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Re(e)))return null}else r=Re(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=s.length}const c=t.parse(l,o,n);if(!c)return null;n=n||c.type,s.push(c)}const o=t.parse(e[1],1,R);if(!o)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==o.type.kind&&t.concat(1).checkSubtype(r,o.type)?null:new tt(r,n,o,i,s,a):null}evaluate(e){const t=this.input.evaluate(e);return(Re(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class rt{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n=[];for(let i=1;it.outputDefined()))&&this.otherwise.outputDefined()}}class nt{constructor(e,t,r,n){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,R),n=t.parse(e[2],2,B);if(!r||!n)return null;if(!K(r.type,[Z(R),C,R]))return t.error(`Expected first argument to be of type array or string, but found ${H(r.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,B);return i?new nt(r.type,r,n,i):null}return new nt(r.type,r,n)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),Q(t,["string"]))return[...t].slice(r,n).join("");if(Q(t,["array"]))return t.slice(r,n);throw new ze(`Expected first argument to be of type array or string, but found ${H(Re(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function it(e,t){const r=e.length-1;let n,i,s=0,o=r,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),n=e[a],i=e[a+1],n<=t){if(a===r||tt))throw new ze("Input is not a number.");o=a-1}return 0}class st{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,B);if(!r)return null;const n=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let r=1;r=s)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const u=t.parse(o,l,i);if(!u)return null;i=i||u.type,n.push([s,u])}return new st(i,r,n)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;return n>=t[i-1]?r[i-1].evaluate(e):r[it(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var at,lt,ut=function(){if(lt)return at;function e(e,t,r,n){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=n}return lt=1,at=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,n=0;n<8;n++){var i=this.sampleCurveX(r)-e;if(Math.abs(i)i?o=r:a=r,r=.5*(a-o)+o;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},at}(),ct=ot(ut);class ht{constructor(e,t,r,n,i){this.type=e,this.operator=t,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,r,n){let i=0;if("exponential"===e.name)i=pt(t,e.base,r,n);else if("linear"===e.name)i=pt(t,1,r,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;i=new ct(s[0],s[1],s[2],s[3]).solve(pt(t,1,r,n))}return i}static parse(e,t){let[r,n,i,...s]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,B),!i)return null;const o=[];let a=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||t.expectedType==G?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=L;for(let e=0;e=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(n,l,a);if(!u)return null;a=a||u.type,o.push([r,u])}return ee(a,B)||ee(a,O)||ee(a,L)||ee(a,U)||ee(a,j)||ee(a,G)||ee(a,Y)||ee(a,Z(B))?new ht(a,r,n,i,o):t.error(`Type ${H(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;if(n>=t[i-1])return r[i-1].evaluate(e);const s=it(t,n),o=ht.interpolationFactor(this.interpolation,n,t[s],t[s+1]),a=r[s].evaluate(e),l=r[s+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Se(a,l,o);case"color":return Te.interpolate(a,l,o);case"padding":return De.interpolate(a,l,o);case"colorArray":return Fe.interpolate(a,l,o);case"numberArray":return Pe.interpolate(a,l,o);case"variableAnchorOffsetCollection":return Ce.interpolate(a,l,o);case"array":return Ae(a,l,o);case"projectionDefinition":return Le.interpolate(a,l,o)}case"interpolate-hcl":switch(this.type.kind){case"color":return Te.interpolate(a,l,o,"hcl");case"colorArray":return Fe.interpolate(a,l,o,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Te.interpolate(a,l,o,"lab");case"colorArray":return Fe.interpolate(a,l,o,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function pt(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}const ft={color:Te.interpolate,number:Se,padding:De.interpolate,numberArray:Pe.interpolate,colorArray:Fe.interpolate,variableAnchorOffsetCollection:Ce.interpolate,array:Ae};class dt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r=null;const n=t.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of e.slice(1)){const e=t.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,i.push(e)}if(!r)throw new Error("No output type");const s=n&&i.some((e=>J(n,e.type)));return new dt(s?R:r,i)}evaluate(e){let t,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(e),r&&r instanceof Ve&&!r.available&&(t||(t=r.name),r=null,n===this.args.length&&(r=t)),null!==r)break;return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function yt(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function mt(e,t,r,n){return 0===n.compare(t,r)}function gt(e,t,r){const n="=="!==e&&"!="!==e;return class i{constructor(e,t,r){this.type=V,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let s=t.parse(e[1],1,R);if(!s)return null;if(!yt(r,s.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${H(s.type)}'.`);let o=t.parse(e[2],2,R);if(!o)return null;if(!yt(r,o.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${H(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${H(s.type)}' and '${H(o.type)}'.`);n&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Ge(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Ge(s.type,[o])));let a=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,$),!a)return null}return new i(s,o,a)}evaluate(i){const s=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const t=Re(s),r=Re(o);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new ze(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Re(s),r=Re(o);if("string"!==e.kind||"string"!==r.kind)return t(i,s,o)}return this.collator?r(i,s,o,this.collator.evaluate(i)):t(i,s,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const xt=gt("==",(function(e,t,r){return t===r}),mt),vt=gt("!=",(function(e,t,r){return t!==r}),(function(e,t,r,n){return!mt(0,t,r,n)})),bt=gt("<",(function(e,t,r){return t",(function(e,t,r){return t>r}),(function(e,t,r,n){return n.compare(t,r)>0})),_t=gt("<=",(function(e,t,r){return t<=r}),(function(e,t,r,n){return n.compare(t,r)<=0})),St=gt(">=",(function(e,t,r){return t>=r}),(function(e,t,r,n){return n.compare(t,r)>=0}));class At{constructor(e,t,r){this.type=$,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const r=e[1];if("object"!=typeof r||Array.isArray(r))return t.error("Collator options argument must be an object.");const n=t.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,V);if(!n)return null;const i=t.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,V);if(!i)return null;let s=null;return r.locale&&(s=t.parse(r.locale,1,C),!s)?null:new At(n,i,s)}evaluate(e){return new Ie(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Tt{constructor(e,t,r,n,i){this.type=C,this.number=e,this.locale=t,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,B);if(!r)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=t.parse(n.locale,1,C),!i))return null;let s=null;if(n.currency&&(s=t.parse(n.currency,1,C),!s))return null;let o=null;if(n["min-fraction-digits"]&&(o=t.parse(n["min-fraction-digits"],1,B),!o))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,B),!a)?null:new Tt(r,i,s,o,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class It{constructor(e){this.type=q,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=e.length-1;++r){const s=e[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let e=null;if(s["font-scale"]&&(e=t.parse(s["font-scale"],1,B),!e))return null;let r=null;if(s["text-font"]&&(r=t.parse(s["text-font"],1,Z(C)),!r))return null;let o=null;if(s["text-color"]&&(o=t.parse(s["text-color"],1,L),!o))return null;let a=null;if(s["vertical-align"]){if("string"==typeof s["vertical-align"]&&!ke.includes(s["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${s["vertical-align"]}' instead.`);if(a=t.parse(s["vertical-align"],1,C),!a)return null}const l=n[n.length-1];l.scale=e,l.font=r,l.textColor=o,l.verticalAlign=a}else{const s=t.parse(e[r],1,R);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null,verticalAlign:null})}}return new It(n)}evaluate(e){return new Me(this.sections.map((t=>{const r=t.content.evaluate(e);return Re(r)===X?new Ee("",r,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new Ee($e(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class kt{constructor(e){this.type=X,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,C);return r?new kt(r):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),r=Ve.fromString(t);return r&&e.availableImages&&(r.available=e.availableImages.indexOf(t)>-1),r}eachChild(e){e(this.input)}outputDefined(){return!1}}class Et{constructor(e){this.type=B,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?t.error(`Expected argument of type string or array, but found ${H(r.type)} instead.`):new Et(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return[...t].length;if(Array.isArray(t))return t.length;throw new ze(`Expected value to be of type string or array, but found ${H(Re(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mt=8192;function Dt(e,t){const r=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(r*i*Mt),Math.round(n*i*Mt)]}function Pt(e,t){const r=Math.pow(2,t.z);return[(i=(e[0]/Mt+t.x)/r,360*i-180),(n=(e[1]/Mt+t.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i}function Ft(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function zt(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Bt(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function Ct(e,t,r){const n=e[0]-t[0],i=e[1]-t[1],s=e[0]-r[0],o=e[1]-r[1];return n*o-s*i==0&&n*s<=0&&i*o<=0}function Vt(e,t,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*s[0]&&!(!qt(e,t,r,n)||!qt(r,n,e,t));var i,s}function Lt(e,t,r){for(const n of r)for(let r=0;r0&&a<0||o<0&&a>0}function Ut(e,t,r){const n=[];for(let i=0;ir[2]){const t=.5*n;let i=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===i&&(i=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=i}Ft(t,e)}function Xt(e,t,r,n){const i=Math.pow(2,n.z)*Mt,s=[n.x*Mt,n.y*Mt],o=[];for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];jt(n,t,r,i),o.push(n)}return o}function Yt(e,t,r,n){const i=Math.pow(2,n.z)*Mt,s=[n.x*Mt,n.y*Mt],o=[];for(const r of e){const e=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Ft(t,r),e.push(r)}o.push(e)}if(t[2]-t[0]<=i/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of o)for(const n of e)jt(n,t,r,i)}var a;return o}class Zt{constructor(e,t){this.type=V,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ne(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const r of t.features){const{type:t,coordinates:n}=r.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Zt(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Zt(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Zt(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if("Polygon"===t.type){const s=Ut(t.coordinates,n,i),o=Xt(e.geometry(),r,n,i);if(!zt(r,n))return!1;for(const e of o)if(!Ot(e,s))return!1}if("MultiPolygon"===t.type){const s=Gt(t.coordinates,n,i),o=Xt(e.geometry(),r,n,i);if(!zt(r,n))return!1;for(const e of o)if(!Nt(e,s))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if("Polygon"===t.type){const s=Ut(t.coordinates,n,i),o=Yt(e.geometry(),r,n,i);if(!zt(r,n))return!1;for(const e of o)if(!Rt(e,s))return!1}if("MultiPolygon"===t.type){const s=Gt(t.coordinates,n,i),o=Yt(e.geometry(),r,n,i);if(!zt(r,n))return!1;for(const e of o)if(!$t(e,s))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Ht=class{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=i}};function Wt(e,t,r=0,n=e.length-1,i=Kt){for(;n>r;){if(n-r>600){const s=n-r+1,o=t-r+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Wt(e,t,Math.max(r,Math.floor(t-o*l/s+u)),Math.min(n,Math.floor(t+(s-o)*l/s+u)),i)}const s=e[t];let o=r,a=n;for(Jt(e,r,t),i(e[n],s)>0&&Jt(e,r,n);o0;)a--}0===i(e[r],s)?Jt(e,r,a):(a++,Jt(e,a,n)),a<=t&&(r=a+1),t<=a&&(n=a-1)}}function Jt(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function Kt(e,t){return et?1:0}function Qt(e,t){if(e.length<=1)return[e];const r=[];let n,i;for(const t of e){const e=tr(t);0!==e&&(t.area=Math.abs(e),void 0===i&&(i=e<0),i===e<0?(n&&r.push(n),n=[t]):n.push(t))}if(n&&r.push(n),t>1)for(let e=0;e1?(l=e[a+1][0],u=e[a+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(t[0]-l)*this.kx,h=(t[1]-u)*this.ky;const f=c*c+h*h;f180;)e-=360;return e}}function or(e,t){return t[0]-e[0]}function ar(e){return e[1]-e[0]+1}function lr(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const r=ar(e);if(t){if(2===r)return[e,null];const t=Math.floor(r/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===r)return[e,null];const n=Math.floor(r/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function cr(e,t){if(!lr(t,e.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)Ft(r,e[n]);return r}function hr(e){const t=[1/0,1/0,-1/0,-1/0];for(const r of e)for(const e of r)Ft(t,e);return t}function pr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fr(e,t,r){if(!pr(e)||!pr(t))return NaN;let n=0,i=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=n)return n;if(zt(i,s)){if(br(e,t))return 0}else if(br(t,e))return 0;let o=1/0;for(const n of e)for(let e=0,i=n.length,s=i-1;e0;){const i=o.pop();if(i[0]>=s)continue;const l=i[1],u=t?50:100;if(ar(l)<=u){if(!lr(l,e.length))return NaN;if(t){const t=vr(e,l,r,n);if(isNaN(t)||0===t)return t;s=Math.min(s,t)}else for(let t=l[0];t<=l[1];++t){const i=xr(e[t],r,n);if(s=Math.min(s,i),0===s)return 0}}else{const r=ur(l,t);_r(o,s,n,e,a,r[0]),_r(o,s,n,e,a,r[1])}}return s}function Tr(e,t,r,n,i,s=1/0){let o=Math.min(s,i.distance(e[0],r[0]));if(0===o)return o;const a=new Ht([[0,[0,e.length-1],[0,r.length-1]]],or);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],u=s[2],c=t?50:100,h=n?50:100;if(ar(l)<=c&&ar(u)<=h){if(!lr(l,e.length)&&lr(u,r.length))return NaN;let s;if(t&&n)s=mr(e,l,r,u,i),o=Math.min(o,s);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=u[0];e<=u[1];++e)if(s=dr(r[e],t,i),o=Math.min(o,s),0===o)return o}else if(!t&&n){const t=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=dr(e[r],t,i),o=Math.min(o,s),0===o)return o}else s=gr(e,l,r,u,i),o=Math.min(o,s)}else{const s=ur(l,t),c=ur(u,n);Sr(a,o,i,e,r,s[0],c[0]),Sr(a,o,i,e,r,s[0],c[1]),Sr(a,o,i,e,r,s[1],c[0]),Sr(a,o,i,e,r,s[1],c[1])}}return o}function Ir(e){return"MultiPolygon"===e.type?e.coordinates.map((e=>({type:"Polygon",coordinates:e}))):"MultiLineString"===e.type?e.coordinates.map((e=>({type:"LineString",coordinates:e}))):"MultiPoint"===e.type?e.coordinates.map((e=>({type:"Point",coordinates:e}))):[e]}class kr{constructor(e,t){this.type=B,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ne(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new kr(t,t.features.map((e=>Ir(e.geometry))).flat());if("Feature"===t.type)return new kr(t,Ir(t.geometry));if("type"in t&&"coordinates"in t)return new kr(t,Ir(t))}return t.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=e.geometry(),n=r.flat().map((t=>Pt([t.x,t.y],e.canonical)));if(0===r.length)return NaN;const i=new sr(n[0][1]);let s=1/0;for(const e of t){switch(e.type){case"Point":s=Math.min(s,Tr(n,!1,[e.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,Tr(n,!1,e.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,Ar(n,!1,e.coordinates,i,s))}if(0===s)return s}return s}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=e.geometry(),n=r.flat().map((t=>Pt([t.x,t.y],e.canonical)));if(0===r.length)return NaN;const i=new sr(n[0][1]);let s=1/0;for(const e of t){switch(e.type){case"Point":s=Math.min(s,Tr(n,!0,[e.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,Tr(n,!0,e.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,Ar(n,!0,e.coordinates,i,s))}if(0===s)return s}return s}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const r=e.geometry();if(0===r.length||0===r[0].length)return NaN;const n=Qt(r,0).map((t=>t.map((t=>t.map((t=>Pt([t.x,t.y],e.canonical))))))),i=new sr(n[0][0][0][1]);let s=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":s=Math.min(s,Ar([e.coordinates],!1,t,i,s));break;case"LineString":s=Math.min(s,Ar(e.coordinates,!0,t,i,s));break;case"Polygon":s=Math.min(s,wr(t,e.coordinates,i,s))}if(0===s)return s}return s}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Er{constructor(e){this.type=R,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=e[1];return null==r?t.error("Global state property must be defined."):"string"!=typeof r?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Er(r)}evaluate(e){var t;const r=null===(t=e.globals)||void 0===t?void 0:t.globalState;return r&&0!==Object.keys(r).length?ge(r,this.key):null}eachChild(){}outputDefined(){return!1}}const Mr={"==":xt,"!=":vt,">":wt,"<":bt,">=":St,"<=":_t,array:Ge,at:Ke,boolean:Ge,case:rt,coalesce:dt,collator:At,format:It,image:kt,in:Qe,"index-of":et,interpolate:ht,"interpolate-hcl":ht,"interpolate-lab":ht,length:Et,let:We,literal:qe,match:tt,number:Ge,"number-format":Tt,object:Ge,slice:nt,step:st,string:Ge,"to-boolean":Xe,"to-color":Xe,"to-number":Xe,"to-string":Xe,var:Je,within:Zt,distance:kr,"global-state":Er};class Dr{constructor(e,t,r,n){this.name=e,this.type=t,this._evaluate=r,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const r=e[0],n=Dr.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=s.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let a=null;for(const[n,s]of o){a=new He(t.registry,Cr,t.path,null,t.scope);const o=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(H).join(", ")})`:`(${H(t.type)}...)`;var t})).join(" | "),n=[];for(let r=1;r{r=t?r&&Cr(e):r&&e instanceof qe})),!!r&&Vr(e)&&Or(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Vr(e){if(e instanceof Dr){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Zt)return!1;if(e instanceof kr)return!1;let t=!0;return e.eachChild((e=>{t&&!Vr(e)&&(t=!1)})),t}function Lr(e){if(e instanceof Dr&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!Lr(e)&&(t=!1)})),t}function Or(e,t){if(e instanceof Dr&&t.indexOf(e.name)>=0)return!1;let r=!0;return e.eachChild((e=>{r&&!Or(e,t)&&(r=!1)})),r}function Nr(e){return{result:"success",value:e}}function Rr(e){return{result:"error",value:e}}function $r(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function qr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ur(e){return!!e.expression&&e.expression.interpolated}function Gr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function jr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Re(e)===N}function Xr(e){return e}function Yr(e,t){const r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),i=e.type||(Ur(t)?"exponential":"interval"),s=function(e){switch(e.type){case"color":return Te.parse;case"padding":return De.parse;case"numberArray":return Pe.parse;case"colorArray":return Fe.parse;default:return null}}(t);if(s&&((e=D({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],s(e[1])]))),e.default=s(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(o=e.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${e.colorSpace}"`);var o;const a=function(e){switch(e){case"exponential":return Jr;case"interval":return Wr;case"categorical":return Hr;case"identity":return Kr;default:throw new Error(`Unknown function type "${e}"`)}}(i);let l,u;if("categorical"===i){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];u=typeof e.stops[0][0]}if(r){const r={},n=[];for(let t=0;te[0])),evaluate:({zoom:r},n)=>Jr({stops:i,base:e.base},t,r).evaluate(r,n)}}if(n){const r="exponential"===i?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:ht.interpolationFactor.bind(void 0,r),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:r})=>a(e,t,r,l,u)}}return{kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[e.property]:void 0;return void 0===i?Zr(e.default,t.default):a(e,t,i,l,u)}}}function Zr(e,t,r){return void 0!==e?e:void 0!==t?t:void 0!==r?r:void 0}function Hr(e,t,r,n,i){return Zr(typeof r===i?n[r]:void 0,e.default,t.default)}function Wr(e,t,r){if("number"!==Gr(r))return Zr(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];const i=it(e.stops.map((e=>e[0])),r);return e.stops[i][1]}function Jr(e,t,r){const n=void 0!==e.base?e.base:1;if("number"!==Gr(r))return Zr(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];const s=it(e.stops.map((e=>e[0])),r),o=function(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}(r,n,e.stops[s][0],e.stops[s+1][0]),a=e.stops[s][1],l=e.stops[s+1][1],u=ft[t.type]||Xr;return"function"==typeof a.evaluate?{evaluate(...t){const r=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==r&&void 0!==n)return u(r,n,o,e.colorSpace)}}:u(a,l,o,e.colorSpace)}function Kr(e,t,r){switch(t.type){case"color":r=Te.parse(r);break;case"formatted":r=Me.fromString(r.toString());break;case"resolvedImage":r=Ve.fromString(r.toString());break;case"padding":r=De.parse(r);break;case"colorArray":r=Fe.parse(r);break;case"numberArray":r=Pe.parse(r);break;default:Gr(r)===t.type||"enum"===t.type&&t.values[r]||(r=void 0)}return Zr(r,e.default,t.default)}Dr.register(Mr,{error:[{kind:"error"},[C],(e,[t])=>{throw new ze(t.evaluate(e))}],typeof:[C,[R],(e,[t])=>H(Re(t.evaluate(e)))],"to-rgba":[Z(B,4),[L],(e,[t])=>{const[r,n,i,s]=t.evaluate(e).rgb;return[255*r,255*n,255*i,s]}],rgb:[L,[B,B,B],Pr],rgba:[L,[B,B,B,B],Pr],has:{type:V,overloads:[[[C],(e,[t])=>Fr(t.evaluate(e),e.properties())],[[C,N],(e,[t,r])=>Fr(t.evaluate(e),r.evaluate(e))]]},get:{type:R,overloads:[[[C],(e,[t])=>zr(t.evaluate(e),e.properties())],[[C,N],(e,[t,r])=>zr(t.evaluate(e),r.evaluate(e))]]},"feature-state":[R,[C],(e,[t])=>zr(t.evaluate(e),e.featureState||{})],properties:[N,[],e=>e.properties()],"geometry-type":[C,[],e=>e.geometryType()],id:[R,[],e=>e.id()],zoom:[B,[],e=>e.globals.zoom],"heatmap-density":[B,[],e=>e.globals.heatmapDensity||0],elevation:[B,[],e=>e.globals.elevation||0],"line-progress":[B,[],e=>e.globals.lineProgress||0],accumulated:[R,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[B,Br(B),(e,t)=>{let r=0;for(const n of t)r+=n.evaluate(e);return r}],"*":[B,Br(B),(e,t)=>{let r=1;for(const n of t)r*=n.evaluate(e);return r}],"-":{type:B,overloads:[[[B,B],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[B],(e,[t])=>-t.evaluate(e)]]},"/":[B,[B,B],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[B,[B,B],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[B,[],()=>Math.LN2],pi:[B,[],()=>Math.PI],e:[B,[],()=>Math.E],"^":[B,[B,B],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[B,[B],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[B,[B],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[B,[B],(e,[t])=>Math.log(t.evaluate(e))],log2:[B,[B],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[B,[B],(e,[t])=>Math.sin(t.evaluate(e))],cos:[B,[B],(e,[t])=>Math.cos(t.evaluate(e))],tan:[B,[B],(e,[t])=>Math.tan(t.evaluate(e))],asin:[B,[B],(e,[t])=>Math.asin(t.evaluate(e))],acos:[B,[B],(e,[t])=>Math.acos(t.evaluate(e))],atan:[B,[B],(e,[t])=>Math.atan(t.evaluate(e))],min:[B,Br(B),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[B,Br(B),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[B,[B],(e,[t])=>Math.abs(t.evaluate(e))],round:[B,[B],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[B,[B],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[B,[B],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[V,[C,R],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[V,[R],(e,[t])=>e.id()===t.value],"filter-type-==":[V,[C],(e,[t])=>e.geometryType()===t.value],"filter-<":[V,[C,R],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n{const r=e.id(),n=t.value;return typeof r==typeof n&&r":[V,[C,R],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[V,[R],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>n}],"filter-<=":[V,[C,R],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[V,[R],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<=n}],"filter->=":[V,[C,R],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[V,[R],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>=n}],"filter-has":[V,[R],(e,[t])=>t.value in e.properties()],"filter-has-id":[V,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[V,[Z(C)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[V,[Z(R)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[V,[C,Z(R)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[V,[C,Z(R)],(e,[t,r])=>function(e,t,r,n){for(;r<=n;){const i=r+n>>1;if(t[i]===e)return!0;t[i]>e?n=i-1:r=i+1}return!1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:V,overloads:[[[V,V],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[Br(V),(e,t)=>{for(const r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:V,overloads:[[[V,V],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[Br(V),(e,t)=>{for(const r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[V,[V],(e,[t])=>!t.evaluate(e)],"is-supported-script":[V,[C],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return!r||r(t.evaluate(e))}],upcase:[C,[C],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[C,[C],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[C,Br(R),(e,t)=>t.map((t=>$e(t.evaluate(e)))).join("")],"resolved-locale":[C,[$],(e,[t])=>t.evaluate(e).resolvedLocale()]});class Qr{constructor(e,t,r){this.expression=e,this._warningHistory={},this._evaluator=new Ze,this._defaultValue=t?function(e){if("color"===e.type&&jr(e.default))return new Te(0,0,0,0);switch(e.type){case"color":return Te.parse(e.default)||null;case"padding":return De.parse(e.default)||null;case"numberArray":return Pe.parse(e.default)||null;case"colorArray":return Fe.parse(e.default)||null;case"variableAnchorOffsetCollection":return Ce.parse(e.default)||null;case"projectionDefinition":return Le.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=r}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._globalState&&(e=un(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(e,t,r,n,i,s){this._globalState&&(e=un(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new ze(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function en(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Mr}function tn(e,t,r){const n=new He(Mr,Cr,[],t?function(e){const t={color:L,string:C,number:B,enum:C,boolean:V,formatted:q,padding:U,numberArray:j,colorArray:G,projectionDefinition:O,resolvedImage:X,variableAnchorOffsetCollection:Y};return"array"===e.type?Z(t[e.value]||R,e.length):t[e.type]}(t):void 0),i=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return i?Nr(new Qr(i,t,r)):Rr(n.errors)}class rn{constructor(e,t,r){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Lr(t.expression),this.globalStateRefs=ln(t.expression),this._globalState=r}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._globalState&&(e=un(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s){return this._globalState&&(e=un(e,this._globalState)),this._styleExpression.evaluate(e,t,r,n,i,s)}}class nn{constructor(e,t,r,n,i){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Lr(t.expression),this.globalStateRefs=ln(t.expression),this.interpolationType=n,this._globalState=i}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._globalState&&(e=un(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s){return this._globalState&&(e=un(e,this._globalState)),this._styleExpression.evaluate(e,t,r,n,i,s)}interpolationFactor(e,t,r){return this.interpolationType?ht.interpolationFactor(this.interpolationType,e,t,r):0}}function sn(e,t,r){const n=tn(e,t,r);if("error"===n.result)return n;const i=n.value.expression,s=Vr(i);if(!s&&!$r(t))return Rr([new P("","data expressions not supported")]);const o=Or(i,["zoom"]);if(!o&&!qr(t))return Rr([new P("","zoom expressions not supported")]);const a=an(i);return a||o?a instanceof P?Rr([a]):a instanceof ht&&!Ur(t)?Rr([new P("",'"interpolate" expressions cannot be used with this property')]):Nr(a?new nn(s?"camera":"composite",n.value,a.labels,a instanceof ht?a.interpolation:void 0,r):new rn(s?"constant":"source",n.value,r)):Rr([new P("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class on{constructor(e,t){this._parameters=e,this._specification=t,D(this,Yr(this._parameters,this._specification))}static deserialize(e){return new on(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function an(e){let t=null;if(e instanceof We)t=an(e.result);else if(e instanceof dt){for(const r of e.args)if(t=an(r),t)break}else(e instanceof st||e instanceof ht)&&e.input instanceof Dr&&"zoom"===e.input.name&&(t=e);return t instanceof P||e.eachChild((e=>{const r=an(e);r instanceof P?t=r:!t&&r?t=new P("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&r&&t!==r&&(t=new P("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}function ln(e,t=new Set){return e instanceof Er&&t.add(e.key),e.eachChild((e=>{ln(e,t)})),t}function un(e,t){const{zoom:r,heatmapDensity:n,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a}=null!=e?e:{};return{zoom:r,heatmapDensity:n,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:t}}function cn(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!cn(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const hn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function pn(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};cn(e)||(e=yn(e));const r=tn(e,hn,t);if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,t,n)=>r.value.evaluate(e,t,{},n),needGeometry:dn(e),getGlobalStateRefs:()=>ln(r.value.expression)}}function fn(e,t){return et?1:0}function dn(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?mn(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(yn))):"all"===t?["all"].concat(e.slice(1).map(yn)):"none"===t?["all"].concat(e.slice(1).map(yn).map(vn)):"in"===t?gn(e[1],e.slice(2)):"!in"===t?vn(gn(e[1],e.slice(2))):"has"===t?xn(e[1]):"!has"!==t||vn(xn(e[1]));var r}function mn(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function gn(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(fn)]]:["filter-in-small",e,["literal",t]]}}function xn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function vn(e){return["!",e]}function bn(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const r of e)t+=`${bn(r)},`;return`${t}]`}const r=Object.keys(e).sort();let n="{";for(let t=0;tn.maximum?[new M(t,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function En(e){const t=e.valueSpec,r=Sn(e.value.type);let n,i,s,o={};const a="categorical"!==r&&void 0===e.value.property,l=!a,u="array"===Gr(e.value.stops)&&"array"===Gr(e.value.stops[0])&&"object"===Gr(e.value.stops[0][0]),c=Tn({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===r)return[new M(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(In({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Gr(n)&&0===n.length&&t.push(new M(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&a&&c.push(new M(e.key,e.value,'missing required property "property"')),"identity"===r||e.value.stops||c.push(new M(e.key,e.value,'missing required property "stops"')),"exponential"===r&&e.valueSpec.expression&&!Ur(e.valueSpec)&&c.push(new M(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!$r(e.valueSpec)?c.push(new M(e.key,e.value,"property functions not supported")):a&&!qr(e.valueSpec)&&c.push(new M(e.key,e.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==e.value.property||c.push(new M(e.key,e.value,'"property" property is required')),c;function h(e){let r=[];const n=e.value,a=e.key;if("array"!==Gr(n))return[new M(a,n,`array expected, ${Gr(n)} found`)];if(2!==n.length)return[new M(a,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Gr(n[0]))return[new M(a,n,`object expected, ${Gr(n[0])} found`)];if(void 0===n[0].zoom)return[new M(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new M(a,n,"object stop key must have value")];if(s&&s>Sn(n[0].zoom))return[new M(a,n[0].zoom,"stop zoom values must appear in ascending order")];Sn(n[0].zoom)!==s&&(s=Sn(n[0].zoom),i=void 0,o={}),r=r.concat(Tn({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:kn,value:p}}))}else r=r.concat(p({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return en(An(n[1]))?r.concat([new M(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function p(e,s){const a=Gr(e.value),l=Sn(e.value),u=null!==e.value?e.value:s;if(n){if(a!==n)return[new M(e.key,u,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new M(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==r){let n=`number expected, ${a} found`;return $r(t)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new M(e.key,u,n)]}return"categorical"!==r||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===a&&void 0!==i&&lnew M(`${e.key}${t.key}`,e.value,t.message)));const r=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!r.outputDefined())return[new M(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Lr(r))return[new M(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Lr(r))return[new M(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Or(r,["zoom","feature-state"]))return[new M(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Vr(r))return[new M(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Dn(e){const t=e.key,r=e.value,n=Gr(r);return"string"!==n?[new M(t,r,`color expected, ${n} found`)]:Te.parse(String(r))?[]:[new M(t,r,`color expected, "${r}" found`)]}function Pn(e){const t=e.key,r=e.value,n=e.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(Sn(r))&&i.push(new M(t,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(Sn(r))&&i.push(new M(t,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function Fn(e){return cn(An(e.value))?Mn(D({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):zn(e)}function zn(e){const t=e.value,r=e.key;if("array"!==Gr(t))return[new M(r,t,`array expected, ${Gr(t)} found`)];const n=e.styleSpec;let i,s=[];if(t.length<1)return[new M(r,t,"filter array must have at least 1 element")];switch(s=s.concat(Pn({key:`${r}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),Sn(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Sn(t[1])&&s.push(new M(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&s.push(new M(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(i=Gr(t[1]),"string"!==i&&s.push(new M(`${r}[1]`,t[1],`string expected, ${i} found`)));for(let o=2;o{e in r&&t.push(new M(n,r[e],`"${e}" is prohibited for ref layers`))})),i.layers.forEach((t=>{Sn(t.id)===a&&(e=t)})),e?e.ref?t.push(new M(n,r.ref,"ref cannot reference another ref layer")):o=Sn(e.type):t.push(new M(n,r.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(r.source){const e=i.sources&&i.sources[r.source],s=e&&Sn(e.type);e?"vector"===s&&"raster"===o?t.push(new M(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o||"raster-dem"!==s&&"color-relief"===o?t.push(new M(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?t.push(new M(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==o&&"color-relief"!==o?t.push(new M(n,r.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==o||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&e.lineMetrics||t.push(new M(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new M(n,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new M(n,r.source,`source "${r.source}" not found`))}else t.push(new M(n,r,'missing required property "source"'));return t=t.concat(Tn({key:n,value:r,valueSpec:s.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:r,objectKey:"type"}),filter:Fn,layout:e=>Tn({layer:r,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Vn(D({layerType:o},e))}}),paint:e=>Tn({layer:r,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Cn(D({layerType:o},e))}})}})),t}function On(e){const t=e.value,r=e.key,n=Gr(t);return"string"!==n?[new M(r,t,`string expected, ${n} found`)]:[]}const Nn={promoteId:function({key:e,value:t}){if("string"===Gr(t))return On({key:e,value:t});{const r=[];for(const n in t)r.push(...On({key:`${e}.${n}`,value:t[n]}));return r}}};function Rn(e){const t=e.value,r=e.key,n=e.styleSpec,i=e.style,s=e.validateSpec;if(!t.type)return[new M(r,t,'"type" is required')];const o=Sn(t.type);let a;switch(o){case"vector":case"raster":return a=Tn({key:r,value:t,valueSpec:n[`source_${o.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:Nn,validateSpec:s}),a;case"raster-dem":return a=function(e){var t;const r=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,i=e.styleSpec,s=i.source_raster_dem,o=e.style;let a=[];const l=Gr(n);if(void 0===n)return a;if("object"!==l)return a.push(new M("source_raster_dem",n,`object expected, ${l} found`)),a;const u="custom"===Sn(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!u&&c.includes(t)?a.push(new M(t,n[t],`In "${r}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:s[t],validateSpec:e.validateSpec,style:o,styleSpec:i})):a.push(new M(t,n[t],`unknown property "${t}"`));return a}({sourceName:r,value:t,style:e.style,styleSpec:n,validateSpec:s}),a;case"geojson":if(a=Tn({key:r,value:t,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:Nn}),t.cluster)for(const e in t.clusterProperties){const[n,i]=t.clusterProperties[e],s="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Mn({key:`${r}.${e}.map`,value:i,expressionContext:"cluster-map"})),a.push(...Mn({key:`${r}.${e}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return a;case"video":return Tn({key:r,value:t,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case"image":return Tn({key:r,value:t,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case"canvas":return[new M(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pn({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function $n(e){const t=e.value,r=e.styleSpec,n=r.light,i=e.style;let s=[];const o=Gr(t);if(void 0===t)return s;if("object"!==o)return s=s.concat([new M("light",t,`object expected, ${o} found`)]),s;for(const o in t){const a=o.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:o,value:t[o],valueSpec:r.transition,validateSpec:e.validateSpec,style:i,styleSpec:r}):n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],validateSpec:e.validateSpec,style:i,styleSpec:r}):[new M(o,t[o],`unknown property "${o}"`)])}return s}function qn(e){const t=e.value,r=e.styleSpec,n=r.sky,i=e.style,s=Gr(t);if(void 0===t)return[];if("object"!==s)return[new M("sky",t,`object expected, ${s} found`)];let o=[];for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],style:i,styleSpec:r}):[new M(s,t[s],`unknown property "${s}"`)]);return o}function Un(e){const t=e.value,r=e.styleSpec,n=r.terrain,i=e.style;let s=[];const o=Gr(t);if(void 0===t)return s;if("object"!==o)return s=s.concat([new M("terrain",t,`object expected, ${o} found`)]),s;for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],validateSpec:e.validateSpec,style:i,styleSpec:r}):[new M(o,t[o],`unknown property "${o}"`)]);return s}function Gn(e){let t=[];const r=e.value,n=e.key;if(Array.isArray(r)){const i=[],s=[];for(const o in r)r[o].id&&i.includes(r[o].id)&&t.push(new M(n,r,`all the sprites' ids must be unique, but ${r[o].id} is duplicated`)),i.push(r[o].id),r[o].url&&s.includes(r[o].url)&&t.push(new M(n,r,`all the sprites' URLs must be unique, but ${r[o].url} is duplicated`)),s.push(r[o].url),t=t.concat(Tn({key:`${n}[${o}]`,value:r[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return On({key:n,value:r})}function jn(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new M(e.key,e.value,`object expected, ${Gr(e.value)} found`)];var t}const Xn={"*":()=>[],array:In,boolean:function(e){const t=e.value,r=e.key,n=Gr(t);return"boolean"!==n?[new M(r,t,`boolean expected, ${n} found`)]:[]},number:kn,color:Dn,constants:_n,enum:Pn,filter:Fn,function:En,layer:Ln,object:Tn,source:Rn,light:$n,sky:qn,terrain:Un,projection:function(e){const t=e.value,r=e.styleSpec,n=r.projection,i=e.style,s=Gr(t);if(void 0===t)return[];if("object"!==s)return[new M("projection",t,`object expected, ${s} found`)];let o=[];for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],style:i,styleSpec:r}):[new M(s,t[s],`unknown property "${s}"`)]);return o},projectionDefinition:function(e){const t=e.key;let r=e.value;r=r instanceof String?r.valueOf():r;const n=Gr(r);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(r)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(r)?["array","string"].includes(n)?[]:[new M(t,r,`projection expected, invalid type "${n}" found`)]:[new M(t,r,`projection expected, invalid array ${JSON.stringify(r)} found`)]},string:On,formatted:function(e){return 0===On(e).length?[]:Mn(e)},resolvedImage:function(e){return 0===On(e).length?[]:Mn(e)},padding:function(e){const t=e.key,r=e.value;if("array"===Gr(r)){if(r.length<1||r.length>4)return[new M(t,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),e.constants&&(r=r.concat(_n({key:"constants",value:e.constants}))),Jn(r)}function Wn(e){return function(t){return e(Object.assign({},t,{validateSpec:Yn}))}}function Jn(e){return[].concat(e).sort(((e,t)=>e.line-t.line))}function Kn(e){return function(...t){return Jn(e.apply(this,t))}}Hn.source=Kn(Wn(Rn)),Hn.sprite=Kn(Wn(Gn)),Hn.glyphs=Kn(Wn(Zn)),Hn.light=Kn(Wn($n)),Hn.sky=Kn(Wn(qn)),Hn.terrain=Kn(Wn(Un)),Hn.state=Kn(Wn(jn)),Hn.layer=Kn(Wn(Ln)),Hn.filter=Kn(Wn(Fn)),Hn.paintProperty=Kn(Wn(Cn)),Hn.layoutProperty=Kn(Wn(Vn));const Qn="AbortError";function ei(){return new Error(Qn)}const ti={REGISTERED_PROTOCOLS:{}};function ri(e,t){ti.REGISTERED_PROTOCOLS[e]=t}function ni(e){delete ti.REGISTERED_PROTOCOLS[e]}const ii="global-dispatcher";class si extends Error{constructor(e,t,r,n){super(`AJAXError: ${t} (${e}): ${r}`),this.status=e,this.statusText=t,this.url=r,this.body=n}}const oi=()=>b(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,ai=function(t,r){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=ti.REGISTERED_PROTOCOLS[(n=t.url).substring(0,n.indexOf("://"))];if(e)return e(t,r);if(b(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ii},r)}var n;if(!(e=>/^file:/.test(e)||/^file:/.test(oi())&&!/^\w+:/.test(e))(t.url)){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,r){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:oi(),signal:r.signal});let n,i;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e)}catch(e){throw new si(0,e.message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new si(n.status,n.statusText,t.url,e)}i="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw ei();return{data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(t,r);if(b(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ii},r)}return function(e,t){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(s.responseType="arraybuffer");for(const t in e.headers)s.setRequestHeader(t,e.headers[t]);"json"===e.type&&(s.responseType="text",(null===(i=e.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===e.credentials,s.onerror=()=>{n(new Error(s.statusText))},s.onload=()=>{if(!t.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let t=s.response;if("json"===e.type)try{t=JSON.parse(s.response)}catch(e){return void n(e)}r({data:t,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")})}else{const t=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new si(s.status,s.statusText,e.url,t))}},t.signal.addEventListener("abort",(()=>{s.abort(),n(ei())})),s.send(e.body)}))}(t,r)},li={};function ui(e,t,r={}){if(li[e])throw new Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),li[e]={klass:t,omit:r.omit||[],shallow:r.shallow||[]}}ui("Object",Object),ui("Set",Set),ui("TransferableGridIndex",I),ui("Color",Te),ui("Error",Error),ui("AJAXError",si),ui("ResolvedImage",Ve),ui("StylePropertyFunction",on),ui("StyleExpression",Qr,{omit:["_evaluator"]}),ui("ZoomDependentExpression",nn),ui("ZoomConstantExpression",rn),ui("CompoundExpression",Dr,{omit:["_evaluate"]});for(const e in Mr)Mr[e]._classRegistryKey||ui(`Expression_${e}`,Mr[e]);function ci(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function hi(e){return e.$name||e.constructor._classRegistryKey}function pi(e){return!function(e){if(null===e||"object"!=typeof e)return!1;const t=hi(e);return!(!t||"Object"===t)}(e)&&(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||ci(e)||w(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function fi(e,t){if(pi(e))return(ci(e)||w(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){const r=[];for(const n of e)r.push(fi(n,t));return r}if("object"!=typeof e)throw new Error("can't serialize object of type "+typeof e);const r=hi(e);if(!r)throw new Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!li[r])throw new Error(`${r} is not registered.`);const{klass:n}=li[r],i=n.serialize?n.serialize(e,t):{};if(n.serialize){if(t&&i===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const n in e){if(!e.hasOwnProperty(n))continue;if(li[r].omit.indexOf(n)>=0)continue;const s=e[n];i[n]=li[r].shallow.indexOf(n)>=0?s:fi(s,t)}e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}function di(e){if(pi(e))return e;if(Array.isArray(e))return e.map(di);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=hi(e)||"Object";if(!li[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:r}=li[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(e);const n=Object.create(r.prototype);for(const r of Object.keys(e)){if("$name"===r)continue;const i=e[r];n[r]=li[t].shallow.indexOf(r)>=0?i:di(i)}return n}class yi{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const mi={once:!0};class gi{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new yi((()=>this.process())),this.subscription=A(this.target,"message",(e=>this.receive(e)),!1),this.globalScope=b(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=t?A(t.signal,"abort",(()=>{null==s||s.unsubscribe(),delete this.resolveRejects[i];const t={id:i,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)}),mi):null;this.resolveRejects[i]={resolve:e=>{null==s||s.unsubscribe(),r(e)},reject:e=>{null==s||s.unsubscribe(),n(e)}};const o=[],a=Object.assign(Object.assign({},e),{id:i,sourceMapId:this.mapId,origin:location.origin,data:fi(e.data,o)});this.target.postMessage(a,{transfer:o})}))}receive(e){const t=e.data,r=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[r];const e=this.abortControllers[r];return delete this.abortControllers[r],void(e&&e.abort())}if(b(self)||t.mustQueue)return this.tasks[r]=t,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(t,r){return e(this,void 0,void 0,(function*(){if(""===r.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(r.error?e.reject(di(r.error)):e.resolve(di(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=di(r.data),n=new AbortController;this.abortControllers[t]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,e,n);this.completeTask(t,null,i)}catch(e){this.completeTask(t,e)}}))}completeTask(e,t,r){const n=[];delete this.abortControllers[e];const i={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?fi(t):null,data:fi(r,n)};this.target.postMessage(i,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}}function xi(e,t,r){r[e]&&-1!==r[e].indexOf(t)||(r[e]=r[e]||[],r[e].push(t))}function vi(e,t,r){if(r&&r[e]){const n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}class bi{constructor(e,t={}){d(this,t),this.type=e}}class wi extends bi{constructor(e,t={}){super("error",d({error:e},t))}}class _i{on(e,t){return this._listeners=this._listeners||{},xi(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return vi(e,t,this._listeners),vi(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},xi(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new bi(e,t||{}));const r=e.type;if(this.listens(r)){e.target=this;const t=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of t)r.call(this,e);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const t of n)vi(r,t,this._oneTimeListeners),t.call(this,e);const i=this._eventedParent;i&&(d(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof wi&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e)}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}const Si=Hn,Ai=Si.paintProperty,Ti=Si.layoutProperty;class Ii{constructor(){this.first=!0}update(e,t){const r=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}})).filter((e=>e));return new RegExp(t.join("|"),"u")}const zi=Fi(["Arab","Dupl","Mong","Ougr","Syrc"]);function Bi(e){return!zi.test(String.fromCodePoint(e))}function Ci(e){return!(Ei(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Vi=Fi(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Li(e){return Vi.test(String.fromCodePoint(e))}function Oi(e,t){return!(!t&&Li(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Ni(e){for(const t of e)if(Li(t.codePointAt(0)))return!0;return!1}const Ri=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Ri.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,r){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((e=>{this.loadScriptResolve=e}));r(e);const i=new Promise((e=>setTimeout((()=>e()),this.TIMEOUT)));if(yield Promise.race([n,i]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class $i{constructor(e,t){this.isSupportedScript=qi,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new Ii,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ii,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),r=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*t}}}function qi(e){return function(e,t){for(const r of e)if(!Oi(r.codePointAt(0),t))return!1;return!0}(e,"loaded"===Ri.getRTLTextPluginStatus())}const Ui="-transition";class Gi{constructor(e,t,r){this.property=e,this.value=t,this.expression=function(e,t,r){if(jr(e))return new on(e,t);if(en(e)){const n=sn(e,t,r);if("error"===n.result)throw new Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return n.value}{let r=e;return"color"===t.type&&"string"==typeof e?r=Te.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?r=Ce.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(r=Le.parse(e)):r=Fe.parse(e):r=Pe.parse(e):r=De.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>r}}}(void 0===t?e.specification.default:t,e.specification,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,r){return this.property.possiblyEvaluate(this,e,t,r)}}class ji{constructor(e,t){this.property=e,this.value=new Gi(e,void 0,t)}transitioned(e,t){return new Yi(this.property,this.value,t,d({},e.transition,this.transition),e.now)}untransitioned(){return new Yi(this.property,this.value,null,{},0)}}class Xi{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}getValue(e){return m(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new ji(this._values[e].property,this._globalState)),this._values[e].value=new Gi(this._values[e].property,null===t?void 0:m(t),this._globalState)}getTransition(e){return m(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new ji(this._values[e].property,this._globalState)),this._values[e].transition=m(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);const n=this.getTransition(t);void 0!==n&&(e[`${t}${Ui}`]=n)}return e}transitioned(e,t){const r=new Zi(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(e,t._values[n]);return r}untransitioned(){const e=new Zi(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Yi{constructor(e,t,r,n,i){this.property=e,this.value=t,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,e.specification.transition&&(n.delay||n.duration)&&(this.prior=r)}possiblyEvaluate(e,t,r){const n=e.now||0,i=this.value.possiblyEvaluate(e,t,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n=1)return 1;const t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}(o))}}return i}}class Zi{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,r){const n=new Ji(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(e,t,r);return n}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Hi{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=t}hasValue(e){return void 0!==this._values[e].value}getValue(e){return m(this._values[e].value)}setValue(e,t){this._values[e]=new Gi(this._values[e].property,null===t?void 0:m(t),this._globalState)}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r)}return e}possiblyEvaluate(e,t,r){const n=new Ji(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(e,t,r);return n}}class Wi{constructor(e,t,r){this.property=e,this.value=t,this.parameters=r}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,r,n){return this.property.evaluate(this.value,this.parameters,e,t,r,n)}}class Ji{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Ki{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,r){const n=ft[this.specification.type];return n?n(e,t,r):e}}class Qi{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,r,n){return new Wi(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},r,n)}:e.expression,t)}interpolate(e,t,r){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Wi(this,{kind:"constant",value:void 0},e.parameters);const n=ft[this.specification.type];if(n){const i=n(e.value.value,t.value.value,r);return new Wi(this,{kind:"constant",value:i},e.parameters)}return e}evaluate(e,t,r,n,i,s){return"constant"===e.kind?e.value:e.evaluate(t,r,n,i,s)}}class es extends Qi{possiblyEvaluate(e,t,r,n){if(void 0===e.value)return new Wi(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const i=e.expression.evaluate(t,null,{},r,n),s="resolvedImage"===e.property.specification.type&&"string"!=typeof i?i.name:i,o=this._calculate(s,s,s,t);return new Wi(this,{kind:"constant",value:o},t)}if("camera"===e.expression.kind){const r=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Wi(this,{kind:"constant",value:r},t)}return new Wi(this,e.expression,t)}evaluate(e,t,r,n,i,s){if("source"===e.kind){const o=e.evaluate(t,r,n,i,s);return this._calculate(o,o,o,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},r,n),e.evaluate({zoom:Math.floor(t.zoom)},r,n),e.evaluate({zoom:Math.floor(t.zoom)+1},r,n),t):e.value}_calculate(e,t,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:r,to:t}}interpolate(e){return e}}class ts{constructor(e){this.specification=e}possiblyEvaluate(e,t,r,n){if(void 0!==e.value){if("constant"===e.expression.kind){const i=e.expression.evaluate(t,null,{},r,n);return this._calculate(i,i,i,t)}return this._calculate(e.expression.evaluate(new $i(Math.floor(t.zoom-1),t)),e.expression.evaluate(new $i(Math.floor(t.zoom),t)),e.expression.evaluate(new $i(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:r,to:t}}interpolate(e){return e}}class rs{constructor(e){this.specification=e}possiblyEvaluate(e,t,r,n){return!!e.expression.evaluate(t,null,{},r,n)}interpolate(){return!1}}class ns{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const r=e[t];r.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new Gi(r,void 0,void 0),i=this.defaultTransitionablePropertyValues[t]=new ji(r,void 0);this.defaultTransitioningPropertyValues[t]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}ui("DataDrivenProperty",Qi),ui("DataConstantProperty",Ki),ui("CrossFadedDataDrivenProperty",es),ui("CrossFadedProperty",ts),ui("ColorRampProperty",rs);class is extends _i{constructor(e,t,r){if(super(),this.id=e.id,this.type=e.type,this._globalState=r,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=pn(e.filter,r)),t.layout&&(this._unevaluatedLayout=new Hi(t.layout,r)),t.paint)){this._transitionablePaint=new Xi(t.paint,r);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ji(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=pn(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const r=this._unevaluatedLayout._values[t];for(const t of r.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const r in this._transitionablePaint._values){const n=this._transitionablePaint._values[r].value;for(const i of n.getGlobalStateRefs()){const s=null!==(e=t.get(i))&&void 0!==e?e:[];s.push({name:r,value:n.value}),t.set(i,s)}}return t}setLayoutProperty(e,t,r={}){null!=t&&this._validate(Ti,`layers.${this.id}.layout.${e}`,e,t,r)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Ui)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,r={}){if(null!=t&&this._validate(Ai,`layers.${this.id}.paint.${e}`,e,t,r))return!1;if(e.endsWith(Ui))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const r=this._transitionablePaint._values[e],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const o=this._transitionablePaint._values[e].value;return o.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(e,s,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,r){return!1}isHidden(e,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),function(e,t){const r={};for(const n in e)t.call(this,e[n],n,e)&&(r[n]=e[n]);return r}(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,r,n,i={}){return(!i||!1!==i.validate)&&function(e,t){let r=!1;if(t&&t.length)for(const n of t)e.fire(new wi(new Error(n.message))),r=!0;return r}(this,e.call(Si,{key:t,layerType:this.type,objectKey:r,value:n,styleSpec:k,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Wi&&$r(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}const ss={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class os{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class as{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function ls(e,t=1){let r=0,n=0;return{members:e.map((e=>{const i=ss[e.type].BYTES_PER_ELEMENT,s=r=us(r,Math.max(t,i)),o=e.components||1;return n=Math.max(n,i),r+=i*o,{name:e.name,type:e.type,components:o,offset:s}})),size:us(r,Math.max(n,t)),alignment:t}}function us(e,t){return Math.ceil(e/t)*t}class cs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=r,e}}cs.prototype.bytesPerElement=4,ui("StructArrayLayout2i4",cs);class hs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}hs.prototype.bytesPerElement=6,ui("StructArrayLayout3i6",hs);class ps extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,e}}ps.prototype.bytesPerElement=8,ui("StructArrayLayout4i8",ps);class fs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,this.int16[a+5]=o,e}}fs.prototype.bytesPerElement=12,ui("StructArrayLayout2i4i12",fs);class ds extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.uint8[l+4]=n,this.uint8[l+5]=i,this.uint8[l+6]=s,this.uint8[l+7]=o,e}}ds.prototype.bytesPerElement=8,ui("StructArrayLayout2i4ub8",ds);class ys extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=r,e}}ys.prototype.bytesPerElement=8,ui("StructArrayLayout2f8",ys);class ms extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s,o,a,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,r,n,i,s,o,a,l,u)}emplace(e,t,r,n,i,s,o,a,l,u,c){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=r,this.uint16[h+2]=n,this.uint16[h+3]=i,this.uint16[h+4]=s,this.uint16[h+5]=o,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,e}}ms.prototype.bytesPerElement=20,ui("StructArrayLayout10ui20",ms);class gs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s,o,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,r,n,i,s,o,a)}emplace(e,t,r,n,i,s,o,a,l){const u=8*e;return this.uint16[u+0]=t,this.uint16[u+1]=r,this.uint16[u+2]=n,this.uint16[u+3]=i,this.uint16[u+4]=s,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=l,e}}gs.prototype.bytesPerElement=16,ui("StructArrayLayout8ui16",gs);class xs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,r,n,i,s,o,a,l,u,c,h)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=o,this.uint16[f+6]=a,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,e}}xs.prototype.bytesPerElement=24,ui("StructArrayLayout4i4ui4i24",xs);class vs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=r,this.float32[i+2]=n,e}}vs.prototype.bytesPerElement=12,ui("StructArrayLayout3f12",vs);class bs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}bs.prototype.bytesPerElement=4,ui("StructArrayLayout1ul4",bs);class ws extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s,o,a,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,n,i,s,o,a,l)}emplace(e,t,r,n,i,s,o,a,l,u){const c=10*e,h=5*e;return this.int16[c+0]=t,this.int16[c+1]=r,this.int16[c+2]=n,this.int16[c+3]=i,this.int16[c+4]=s,this.int16[c+5]=o,this.uint32[h+3]=a,this.uint16[c+8]=l,this.uint16[c+9]=u,e}}ws.prototype.bytesPerElement=20,ui("StructArrayLayout6i1ul2ui20",ws);class _s extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,this.int16[a+5]=o,e}}_s.prototype.bytesPerElement=12,ui("StructArrayLayout2i2i2i12",_s);class Ss extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const o=4*e,a=8*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=n,this.int16[a+6]=i,this.int16[a+7]=s,e}}Ss.prototype.bytesPerElement=16,ui("StructArrayLayout2f1f2i16",Ss);class As extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=16*e,l=4*e,u=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.int16[u+6]=s,this.int16[u+7]=o,e}}As.prototype.bytesPerElement=16,ui("StructArrayLayout2ub2f2i16",As);class Ts extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,this.uint16[i+2]=n,e}}Ts.prototype.bytesPerElement=6,ui("StructArrayLayout3ui6",Ts);class Is extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g){const x=24*e,v=12*e,b=48*e;return this.int16[x+0]=t,this.int16[x+1]=r,this.uint16[x+2]=n,this.uint16[x+3]=i,this.uint32[v+2]=s,this.uint32[v+3]=o,this.uint32[v+4]=a,this.uint16[x+10]=l,this.uint16[x+11]=u,this.uint16[x+12]=c,this.float32[v+7]=h,this.float32[v+8]=p,this.uint8[b+36]=f,this.uint8[b+37]=d,this.uint8[b+38]=y,this.uint32[v+10]=m,this.int16[x+22]=g,e}}Is.prototype.bytesPerElement=48,ui("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Is);class ks extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,T,I,k){const E=this.length;return this.resize(E+1),this.emplace(E,e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,T,I,k)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,A,T,I,k,E){const M=32*e,D=16*e;return this.int16[M+0]=t,this.int16[M+1]=r,this.int16[M+2]=n,this.int16[M+3]=i,this.int16[M+4]=s,this.int16[M+5]=o,this.int16[M+6]=a,this.int16[M+7]=l,this.uint16[M+8]=u,this.uint16[M+9]=c,this.uint16[M+10]=h,this.uint16[M+11]=p,this.uint16[M+12]=f,this.uint16[M+13]=d,this.uint16[M+14]=y,this.uint16[M+15]=m,this.uint16[M+16]=g,this.uint16[M+17]=x,this.uint16[M+18]=v,this.uint16[M+19]=b,this.uint16[M+20]=w,this.uint16[M+21]=_,this.uint16[M+22]=S,this.uint32[D+12]=A,this.float32[D+13]=T,this.float32[D+14]=I,this.uint16[M+30]=k,this.uint16[M+31]=E,e}}ks.prototype.bytesPerElement=64,ui("StructArrayLayout8i15ui1ul2f2ui64",ks);class Es extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Es.prototype.bytesPerElement=4,ui("StructArrayLayout1f4",Es);class Ms extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.uint16[6*e+0]=t,this.float32[i+1]=r,this.float32[i+2]=n,e}}Ms.prototype.bytesPerElement=12,ui("StructArrayLayout1ui2f12",Ms);class Ds extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e;return this.uint32[2*e+0]=t,this.uint16[i+2]=r,this.uint16[i+3]=n,e}}Ds.prototype.bytesPerElement=8,ui("StructArrayLayout1ul2ui8",Ds);class Ps extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,e}}Ps.prototype.bytesPerElement=4,ui("StructArrayLayout2ui4",Ps);class Fs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Fs.prototype.bytesPerElement=2,ui("StructArrayLayout1ui2",Fs);class zs extends as{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,e}}zs.prototype.bytesPerElement=16,ui("StructArrayLayout4f16",zs);class Bs extends os{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new t(this.anchorPointX,this.anchorPointY)}}Bs.prototype.size=20;class Cs extends ws{get(e){return new Bs(this,e)}}ui("CollisionBoxArray",Cs);class Vs extends os{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Vs.prototype.size=48;class Ls extends Is{get(e){return new Vs(this,e)}}ui("PlacedSymbolArray",Ls);class Os extends os{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Os.prototype.size=64;class Ns extends ks{get(e){return new Os(this,e)}}ui("SymbolInstanceArray",Ns);class Rs extends Es{getoffsetX(e){return this.float32[1*e+0]}}ui("GlyphOffsetArray",Rs);class $s extends hs{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ui("SymbolLineVertexArray",$s);class qs extends os{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}qs.prototype.size=12;class Us extends Ms{get(e){return new qs(this,e)}}ui("TextAnchorOffsetArray",Us);class Gs extends os{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Gs.prototype.size=8;class js extends Ds{get(e){return new Gs(this,e)}}ui("FeatureIndexArray",js);class Xs extends cs{}class Ys extends cs{}class Zs extends cs{}class Hs extends fs{}class Ws extends ds{}class Js extends ys{}class Ks extends ms{}class Qs extends gs{}class eo extends xs{}class to extends vs{}class ro extends bs{}class no extends _s{}class io extends As{}class so extends Ts{}class oo extends Ps{}const ao=ls([{name:"a_pos",components:2,type:"Int16"}],4),{members:lo}=ao;class uo{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,r,n){const i=this.segments[this.segments.length-1];return e>uo.MAX_VERTEX_ARRAY_LENGTH&&x(`Max vertices per segment is ${uo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${uo.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!i||i.vertexLength+e>uo.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n?this.createNewSegment(t,r,n):i}createNewSegment(e,t,r){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==r&&(n.sortKey=r),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,r){return this.prepareSegment(0,e,t,r)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,r,n){return new uo([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function co(e,t){return 256*(e=f(Math.floor(e),0,255))+f(Math.floor(t),0,255)}uo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ui("SegmentVector",uo);const ho=ls([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),po=ls([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var fo,yo,mo,go={exports:{}},xo={exports:{}},vo={exports:{}},bo=function(){if(mo)return go.exports;mo=1;var e=(fo||(fo=1,xo.exports=function(e,t){var r,n,i,s,o,a,l,u;for(n=e.length-(r=3&e.length),i=t,o=3432918353,a=461845907,u=0;u>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),xo.exports),t=(yo||(yo=1,vo.exports=function(e,t){for(var r,n=e.length,i=t^n,s=0;n>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(s)|(255&e.charCodeAt(++s))<<8|(255&e.charCodeAt(++s))<<16|(255&e.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&e.charCodeAt(s+2))<<16;case 2:i^=(255&e.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),vo.exports);return go.exports=e,go.exports.murmur3=e,go.exports.murmur2=t,go.exports}(),wo=r(bo);class _o{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,r,n){this.ids.push(So(e)),this.positions.push(t,r,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=So(e);let r=0,n=this.ids.length-1;for(;r>1;this.ids[e]>=t?n=e:r=e+1}const i=[];for(;this.ids[r]===t;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(e,t){const r=new Float64Array(e.ids),n=new Uint32Array(e.positions);return Ao(r,n,0,r.length-1),t&&t.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(e){const t=new _o;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function So(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:wo(String(e))}function Ao(e,t,r,n){for(;r>1];let s=r-1,o=n+1;for(;;){do{s++}while(e[s]i);if(s>=o)break;To(e,s,o),To(t,3*s,3*o),To(t,3*s+1,3*o+1),To(t,3*s+2,3*o+2)}o-r`u_${e}`)),this.type=r}setUniform(e,t,r){e.set(r.constantOr(this.value))}getBinding(e,t,r){return"color"===this.type?new Mo(e,t):new ko(e,t)}}class Fo{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,r,n){let i=null;"u_pattern_to"===n?i=this.patternTo:"u_pattern_from"===n?i=this.patternFrom:"u_dasharray_to"===n?i=this.dashTo:"u_dasharray_from"===n?i=this.dashFrom:"u_pixel_ratio_to"===n?i=this.pixelRatioTo:"u_pixel_ratio_from"===n&&(i=this.pixelRatioFrom),null!==i&&e.set(i)}getBinding(e,t,r){return"u_pattern"===r.substr(0,9)||"u_dasharray_"===r.substr(0,12)?new Eo(e,t):new ko(e,t)}}class zo{constructor(e,t,r,n){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(e,t,r){const n=this.paintVertexArray.length,i=this.expression.evaluate(new $i(0,r),t,{},r.canonical,[],r.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(n,e,i)}updatePaintArray(e,t,r,n,i){const s=this.expression.evaluate(new $i(0,i),r,n);this._setPaintValue(e,t,s)}_setPaintValue(e,t,r){if("color"===this.type){const n=Do(r);for(let r=e;r`u_${e}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s}populatePaintArray(e,t,r){const n=this.expression.evaluate(new $i(this.zoom,r),t,{},r.canonical,[],r.formattedSection),i=this.expression.evaluate(new $i(this.zoom+1,r),t,{},r.canonical,[],r.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(s,e,n,i)}updatePaintArray(e,t,r,n,i){const s=this.expression.evaluate(new $i(this.zoom,i),r,n),o=this.expression.evaluate(new $i(this.zoom+1,i),r,n);this._setPaintValue(e,t,s,o)}_setPaintValue(e,t,r,n){if("color"===this.type){const i=Do(r),s=Do(n);for(let r=e;r`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const r=this.binders[t];if(r instanceof zo||r instanceof Bo)for(let t=0;t!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Oo(n,t,r);this.needsUpload=!1,this._featureMap=new _o,this._bufferOffset=0}populatePaintArrays(e,t,r,n){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,n);void 0!==t.id&&this._featureMap.add(t.id,r,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(e,this._featureMap,t,i,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Ro(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function $o(e,t,r){const n={color:{source:ys,composite:zs},number:{source:Es,composite:ys}},i=function(e){return{"line-pattern":{source:Ks,composite:Ks},"fill-pattern":{source:Ks,composite:Ks},"fill-extrusion-pattern":{source:Ks,composite:Ks},"line-dasharray":{source:Qs,composite:Qs}}[e]}(e);return i&&i[r]||n[t][r]}ui("ConstantBinder",Po),ui("CrossFadedConstantBinder",Fo),ui("SourceExpressionBinder",zo),ui("CrossFadedPatternBinder",Vo),ui("CrossFadedDasharrayBinder",Lo),ui("CompositeExpressionBinder",Bo),ui("ProgramConfiguration",Oo,{omit:["_buffers"]}),ui("ProgramConfigurationSet",No);const qo=Math.pow(2,14)-1,Uo=-qo-1;function Go(e){const t=p/e.extent,r=e.loadGeometry();for(let e=0;er.x+1||sr.y+1)&&x("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function jo(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Go(e):[]}}const Xo=-32768;function Yo(e,t,r,n,i){e.emplaceBack(Xo+8*t+n,Xo+8*r+i)}class Zo{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ys,this.indexArray=new so,this.segments=new uo,this.programConfigurations=new No(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,r){const n=this.layers[0],i=[];let s=null,o=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;s=e.layout.get("circle-sort-key"),o=!s.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=jo(t,e);if(!this.layers[0]._featureFilter.filter(new $i(this.zoom),u,r))continue;const c=o?s.evaluate(u,{},r):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?u.geometry:Go(t),patterns:{},sortKey:c};i.push(h)}o&&i.sort(((e,t)=>e.sortKey-t.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:o}=n,a=e[s].feature;this.addFeature(n,i,s,r,l),t.featureIndex.insert(a,i,s,o,this.index)}}update(e,t,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:r})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,lo),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,r,n,i=1){let s;switch(i){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${i}; valid values are 1, 3, 5, 7.`)}const o=s.length;for(const r of t)for(const t of r){const r=t.x,n=t.y;if(r<0||r>=p||n<0||n>=p)continue;const i=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),a=i.vertexLength;for(let e=0;e1){if(Qo(e,t))return!0;for(let n=0;n1?r:r.sub(t)._mult(i)._add(t))}function na(e,t){let r,n,i,s=!1;for(let o=0;ot.y!=i.y>t.y&&t.x<(i.x-n.x)*(t.y-n.y)/(i.y-n.y)+n.x&&(s=!s)}return s}function ia(e,t){let r=!1;for(let n=0,i=e.length-1;nt.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(r=!r)}return r}function sa(e,t,r){const n=r[0],i=r[2];if(e.xi.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const s=v(e,t,r[0]);return s!==v(e,t,r[1])||s!==v(e,t,r[2])||s!==v(e,t,r[3])}function oa(e,t,r){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:r.programConfigurations.get(t.id).getMaxValue(e)}function aa(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function la(e,r,n,i,s){if(!r[0]&&!r[1])return e;const o=t.convert(r)._mult(s);"viewport"===n&&o._rotate(-i);const a=[];for(let t=0;tda(e,t,r,n)))}(l,i,o,a),f=u),fa({queryGeometry:p,size:f,transform:i,unwrappedTileID:o,getElevation:a,pitchAlignment:h,pitchScale:c},n)}}class va extends Zo{}let ba;ui("HeatmapBucket",va,{omit:["layers"]});var wa={get paint(){return ba=ba||new ns({"heatmap-radius":new Qi(k.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Qi(k.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Ki(k.paint_heatmap["heatmap-intensity"]),"heatmap-color":new rs(k.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Ki(k.paint_heatmap["heatmap-opacity"])})}};function _a(e,{width:t,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${t*r*n}`)}else i=new Uint8Array(t*r*n);return e.width=t,e.height=r,e.data=i,e}function Sa(e,{width:t,height:r},n){if(t===e.width&&r===e.height)return;const i=_a({},{width:t,height:r},n);Aa(e,i,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,r)},n),e.width=t,e.height=r,e.data=i.data}function Aa(e,t,r,n,i,s){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const o=e.data,a=t.data;if(o===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);i.setPixel(n/4/r,s/4,a)};if(e.clips)for(let t=0,i=0;tthis.max&&(this.max=r),r=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}unpack(e,t,r){return e*this.redFactor+t*this.greenFactor+r*this.blueFactor-this.baseShift}pack(e){return Va(e,this.getUnpackVector())}getPixels(){return new Ia({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,i=t*this.dim+this.dim,s=r*this.dim,o=r*this.dim+this.dim;switch(t){case-1:n=i-1;break;case 1:i=n+1}switch(r){case-1:s=o-1;break;case 1:o=s+1}const a=-t*this.dim,l=-r*this.dim;for(let t=s;t0)for(let i=t;i=t;i-=n)s=cl(i/n|0,e[i],e[i+1],s);return s&&il(s,s.next)&&(hl(s),s=s.next),s}function Ua(e,t){if(!e)return e;t||(t=e);let r,n=e;do{if(r=!1,n.steiner||!il(n,n.next)&&0!==nl(n.prev,n,n.next))n=n.next;else{if(hl(n),n=t=n.prev,n===n.next)break;r=!0}}while(r||n!==t);return t}function Ga(e,t,r,n,i,s,o){if(!e)return;!o&&s&&function(e,t,r,n){let i=e;do{0===i.z&&(i.z=Ka(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,r=1;do{let n,i=e;e=null;let s=null;for(t=0;i;){t++;let o=i,a=0;for(let e=0;e0||l>0&&o;)0!==a&&(0===l||!o||i.z<=o.z)?(n=i,i=i.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;i=o}s.nextZ=null,r*=2}while(t>1)}(i)}(e,n,i,s);let a=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(s?Xa(e,n,i,s):ja(e))t.push(l.i,e.i,u.i),hl(e),e=u.next,a=u.next;else if((e=u)===a){o?1===o?Ga(e=Ya(Ua(e),t),t,r,n,i,s,2):2===o&&Za(e,t,r,n,i,s):Ga(Ua(e),t,r,n,i,s,1);break}}}function ja(e){const t=e.prev,r=e,n=e.next;if(nl(t,r,n)>=0)return!1;const i=t.x,s=r.x,o=n.x,a=t.y,l=r.y,u=n.y,c=Math.min(i,s,o),h=Math.min(a,l,u),p=Math.max(i,s,o),f=Math.max(a,l,u);let d=n.next;for(;d!==t;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&tl(i,a,s,l,o,u,d.x,d.y)&&nl(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Xa(e,t,r,n){const i=e.prev,s=e,o=e.next;if(nl(i,s,o)>=0)return!1;const a=i.x,l=s.x,u=o.x,c=i.y,h=s.y,p=o.y,f=Math.min(a,l,u),d=Math.min(c,h,p),y=Math.max(a,l,u),m=Math.max(c,h,p),g=Ka(f,d,t,r,n),x=Ka(y,m,t,r,n);let v=e.prevZ,b=e.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==o&&tl(a,c,l,h,u,p,v.x,v.y)&&nl(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&tl(a,c,l,h,u,p,b.x,b.y)&&nl(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=y&&v.y>=d&&v.y<=m&&v!==i&&v!==o&&tl(a,c,l,h,u,p,v.x,v.y)&&nl(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=y&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&tl(a,c,l,h,u,p,b.x,b.y)&&nl(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Ya(e,t){let r=e;do{const n=r.prev,i=r.next.next;!il(n,i)&&sl(n,r,r.next,i)&&ll(n,i)&&ll(i,n)&&(t.push(n.i,r.i,i.i),hl(r),hl(r.next),r=e=i),r=r.next}while(r!==e);return Ua(r)}function Za(e,t,r,n,i,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&rl(o,e)){let a=ul(o,e);return o=Ua(o,o.next),a=Ua(a,a.next),Ga(o,t,r,n,i,s,0),void Ga(a,t,r,n,i,s,0)}e=e.next}o=o.next}while(o!==e)}function Ha(e,t){let r=e.x-t.x;return 0===r&&(r=e.y-t.y,0===r)&&(r=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),r}function Wa(e,t){const r=function(e,t){let r=t;const n=e.x,i=e.y;let s,o=-1/0;if(il(e,r))return r;do{if(il(e,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const e=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=n&&e>o&&(o=e,s=r.x=r.x&&r.x>=l&&n!==r.x&&el(is.x||r.x===s.x&&Ja(s,r)))&&(s=r,c=t)}r=r.next}while(r!==a);return s}(e,t);if(!r)return t;const n=ul(r,e);return Ua(n,n.next),Ua(r,r.next)}function Ja(e,t){return nl(e.prev,e,t.prev)<0&&nl(t.next,e,e.next)<0}function Ka(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Qa(e){let t=e,r=e;do{(t.x=(e-o)*(s-a)&&(e-o)*(n-a)>=(r-o)*(t-a)&&(r-o)*(s-a)>=(i-o)*(n-a)}function tl(e,t,r,n,i,s,o,a){return!(e===o&&t===a)&&el(e,t,r,n,i,s,o,a)}function rl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&sl(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(ll(e,t)&&ll(t,e)&&function(e,t){let r=e,n=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(nl(e.prev,e,t.prev)||nl(e,t.prev,t))||il(e,t)&&nl(e.prev,e,e.next)>0&&nl(t.prev,t,t.next)>0)}function nl(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function il(e,t){return e.x===t.x&&e.y===t.y}function sl(e,t,r,n){const i=al(nl(e,t,r)),s=al(nl(e,t,n)),o=al(nl(r,n,e)),a=al(nl(r,n,t));return i!==s&&o!==a||!(0!==i||!ol(e,r,t))||!(0!==s||!ol(e,n,t))||!(0!==o||!ol(r,e,n))||!(0!==a||!ol(r,t,n))}function ol(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function al(e){return e>0?1:e<0?-1:0}function ll(e,t){return nl(e.prev,e,e.next)<0?nl(e,t,e.next)>=0&&nl(e,e.prev,t)>=0:nl(e,t,e.prev)<0||nl(e,e.next,t)<0}function ul(e,t){const r=pl(e.i,e.x,e.y),n=pl(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function cl(e,t,r,n){const i=pl(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function hl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function pl(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class fl{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const r=0|Math.round(e),n=0|Math.round(t),i=this._getKey(r,n);if(this._vertexDictionary.has(i))return this._vertexDictionary.get(i);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(i,s),this._vertexBuffer.push(r,n),s}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const r=[];for(let n=0;n0?(r.push(i),r.push(o),r.push(s)):(r.push(i),r.push(s),r.push(o))}return r}(this._vertexBuffer,e);const t=[],r=e.length;for(let n=0;n=1||v<=0)||y&&(ai)){u>=n&&u<=i&&s.push(r[(e+1)%3]);continue}!y&&x>0&&s.push(this._vertexToIndex(o+p*x,a+f*x));const b=o+p*Math.max(x,0),w=o+p*Math.min(v,1);d||this._generateIntraEdgeVertices(s,o,a,l,u,b,w),!y&&v<1&&s.push(this._vertexToIndex(o+p*v,a+f*v)),(y||u>=n&&u<=i)&&s.push(r[(e+1)%3]),!y&&(u<=n||u>=i)&&this._generateInterEdgeVertices(s,o,a,l,u,c,h,w,n,i)}return s}_generateIntraEdgeVertices(e,t,r,n,i,s,o){const a=n-t,l=i-r,u=0===l,c=u?Math.min(t,n):Math.min(s,o),h=u?Math.max(t,n):Math.max(s,o),p=Math.floor(c/this._granularityCellSize)+1,f=Math.ceil(h/this._granularityCellSize)-1;if(u?t=p;n--){const i=n*this._granularityCellSize;e.push(this._vertexToIndex(i,r+l*(i-t)/a))}}_generateInterEdgeVertices(e,t,r,n,i,s,o,a,l,u){const c=i-r,h=s-n,p=o-i,f=(l-i)/p,d=(u-i)/p,y=Math.min(f,d),m=Math.max(f,d),g=n+h*y;let x=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,b=a=1||m<=0){const e=r-o,n=s+(t-s)*Math.min((l-o)/e,(u-o)/e);x=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,b=a0?u:l;if(b)for(let t=x;t<=v;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,_));else for(let t=v;t>=x;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,_))}_generateOutline(e){const t=[];for(const r of e){const e=vl(r,this._granularity,!0),n=this._pointArrayToIndices(e),i=[];for(let e=1;ei!=(s===yl)?(e.push(t),e.push(r),e.push(this._vertexToIndex(n,s)),e.push(r),e.push(this._vertexToIndex(i,s)),e.push(this._vertexToIndex(n,s))):(e.push(r),e.push(t),e.push(this._vertexToIndex(n,s)),e.push(this._vertexToIndex(i,s)),e.push(r),e.push(this._vertexToIndex(n,s)))}_fillPoles(e,t,r){const n=this._vertexBuffer,i=p,s=e.length;for(let o=2;o80*r){a=e[0],l=e[1];let t=a,n=l;for(let s=r;st&&(t=r),i>n&&(n=i)}u=Math.max(t-a,n-l),u=0!==u?32767/u:0}return Ga(s,o,r,a,l,u,0),o}(r,n),t=this._convertIndices(r,e);i=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let s=[];return t&&(s=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(i),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_convertIndices(e,t){const r=[];for(let n=0;n0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,r=y>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,n=Math.abs(x-e),i=Math.abs(v-r),s=Math.abs(x-c),o=Math.abs(v-h),u=p?n/m:Number.POSITIVE_INFINITY,b=f?i/g:Number.POSITIVE_INFINITY;if((s<=n||!p)&&(o<=i||!f))break;if(u=0?o-1:s-1,i=(a+1)%s,l=e[2*t[n]],u=e[2*t[i]],c=e[2*t[o]],h=e[2*t[o]+1],p=e[2*t[a]+1];let f=!1;if(lu)f=!1;else{const r=p-h,s=-(e[2*t[a]]-c),o=h((u-c)*r+(e[2*t[i]+1]-h)*s)*o&&(f=!0)}if(f){const e=t[n],i=t[o],l=t[a];e!==i&&e!==l&&i!==l&&r.push(l,i,e),o--,o<0&&(o=s-1)}else{const e=t[i],n=t[o],l=t[a];e!==n&&e!==l&&n!==l&&r.push(l,n,e),a++,a>=s&&(a=0)}if(n===i)break}}function wl(e,t,r,n,i,s,o,a,l){const u=i.length/2,c=o&&a&&l;if(uuo.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,r),l=a.count,y=!0,m=!0,g=!0,c=0);const x=_l(o,n,s,a,p,y,u),v=_l(o,n,s,a,f,m,u),b=_l(o,n,s,a,d,g,u);r.emplaceBack(c+x-l,c+v-l,c+b-l),u.primitiveLength++}}(t,r,n,i,s,e),c&&function(e,t,r,n,i,s){const o=[];for(let e=0;euo.MAX_VERTEX_ARRAY_LENGTH&&(u=e.createNewSegment(t,r),l=a.count,d=!0,y=!0,c=0);const m=_l(o,n,s,a,i,d,u),g=_l(o,n,s,a,h,y,u);r.emplaceBack(c+m-l,c+g-l),u.primitiveLength++}}}(o,r,a,i,l,e),t.forceNewSegmentOnNextPrepare(),null==o||o.forceNewSegmentOnNextPrepare()}function _l(e,t,r,n,i,s,o){if(s){const s=n.count;return r(t[2*i],t[2*i+1]),e[i]=n.count,n.count++,o.vertexLength++,s}return e[i]}class Sl{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Zs,this.indexArray=new so,this.indexArray2=new oo,this.programConfigurations=new No(e.layers,e.zoom),this.segments=new uo,this.segments2=new uo,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,r){this.hasDependencies=Ra("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),i=!n.isConstant(),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=jo(o,e);if(!this.layers[0]._featureFilter.filter(new $i(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,t.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Go(o),patterns:{},sortKey:h};s.push(p)}i&&s.sort(((e,t)=>e.sortKey-t.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:o}=n;if(this.hasDependencies){const e=$a("fill",this.layers,n,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(n,i,s,r,{},t.subdivisionGranularity);t.featureIndex.insert(e[s].feature,i,s,o,this.index)}}update(e,t,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:r})}addFeatures(e,t,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,r,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Na),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,r,n,i,s){for(const e of Qt(t,500)){const t=xl(e,n,s.fill.getGranularityForZoomLevel(n.z)),r=this.layoutVertexArray;wl(((e,t)=>{r.emplaceBack(e,t)}),this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{imagePositions:i,canonical:n})}}let Al,Tl;ui("FillBucket",Sl,{omit:["layers","patternFeatures"]});var Il={get paint(){return Tl=Tl||new ns({"fill-antialias":new Ki(k.paint_fill["fill-antialias"]),"fill-opacity":new Qi(k.paint_fill["fill-opacity"]),"fill-color":new Qi(k.paint_fill["fill-color"]),"fill-outline-color":new Qi(k.paint_fill["fill-outline-color"]),"fill-translate":new Ki(k.paint_fill["fill-translate"]),"fill-translate-anchor":new Ki(k.paint_fill["fill-translate-anchor"]),"fill-pattern":new es(k.paint_fill["fill-pattern"])})},get layout(){return Al=Al||new ns({"fill-sort-key":new Qi(k.layout_fill["fill-sort-key"])})}};class kl extends is{constructor(e,t){super(e,Il,t)}recalculate(e,t){super.recalculate(e,t);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Sl(e)}queryRadius(){return aa(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:r,pixelsToTileUnits:n}){return Jo(la(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-r.bearingInRadians,n),t)}isTileClipped(){return!0}}const El=ls([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Ml=ls([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Dl}=El;class Pl{constructor(e,t,r,n,i){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=i,e.readFields(Fl,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const r=e.readVarint()+e.pos,n=[];let i,s=1,o=0,a=0,l=0;for(;e.pos>3}if(o--,1===s||2===s)a+=e.readSVarint(),l+=e.readSVarint(),1===s&&(i&&n.push(i),i=[]),i&&i.push(new t(a,l));else{if(7!==s)throw new Error(`unknown command ${s}`);i&&i.push(i[0].clone())}}return i&&n.push(i),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let r=1,n=0,i=0,s=0,o=1/0,a=-1/0,l=1/0,u=-1/0;for(;e.pos>3}if(n--,1===r||2===r)i+=e.readSVarint(),s+=e.readSVarint(),ia&&(a=i),su&&(u=s);else if(7!==r)throw new Error(`unknown command ${r}`)}return[o,l,a,u]}toGeoJSON(e,t,r){const n=this.extent*Math.pow(2,r),i=this.extent*e,s=this.extent*t,o=this.loadGeometry();function a(e){return[360*(e.x+i)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function l(e){return e.map(a)}let u;if(1===this.type){const e=[];for(const t of o)e.push(t[0]);const t=l(e);u=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=o.map(l);u=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const r=[];let n,i;for(let s=0;s=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Pl(this._pbf,t,this.extent,this._keys,this._values)}}function Cl(e,t,r){15===e?t.version=r.readVarint():1===e?t.name=r.readString():5===e?t.extent=r.readVarint():2===e?t._features.push(r.pos):3===e?t._keys.push(r.readString()):4===e&&t._values.push(function(e){let t=null;const r=e.readVarint()+e.pos;for(;e.pos>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(r))}class Vl{constructor(e,t){this.layers=e.readFields(Ll,{},t)}}function Ll(e,t,r){if(3===e){const e=new Bl(r,r.readVarint()+r.pos);e.length&&(t[e.name]=e)}}const Ol=Math.pow(2,13);function Nl(e,t,r,n,i,s,o,a){e.emplaceBack(t,r,2*Math.floor(n*Ol)+o,i*Ol*2,s*Ol*2,Math.round(a))}class Rl{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Hs,this.centroidVertexArray=new Xs,this.indexArray=new so,this.programConfigurations=new No(e.layers,e.zoom),this.segments=new uo,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,r){this.features=[],this.hasDependencies=Ra("fill-extrusion",this.layers,t);for(const{feature:n,id:i,index:s,sourceLayerIndex:o}of e){const e=this.layers[0]._featureFilter.needGeometry,a=jo(n,e);if(!this.layers[0]._featureFilter.filter(new $i(this.zoom),a,r))continue;const l={id:i,sourceLayerIndex:o,index:s,geometry:e?a.geometry:Go(n),properties:n.properties,type:n.type,patterns:{}};this.hasDependencies?this.features.push($a("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,s,r,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,s,o,this.index,!0)}}addFeatures(e,t,r){for(const n of this.features){const{geometry:i}=n;this.addFeature(n,i,n.index,t,r,e.subdivisionGranularity)}}update(e,t,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:r})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Dl),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ml.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,r,n,i,s){for(const r of Qt(t,500)){const t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,n,e,r,s);const o=this.layoutVertexArray.length-i,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{Nl(u,e,t,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let r=0;for(let n=1;nuo.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const o=i.sub(s)._perp()._unit(),a=s.dist(i);r+a>32768&&(r=0),Nl(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,0,r),Nl(this.layoutVertexArray,i.x,i.y,o.x,o.y,0,1,r),r+=a,Nl(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,r),Nl(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,r);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function $l(e,t){for(let r=0;rp)||e.y===t.y&&(e.y<0||e.y>p)}function Ul(e){return e.every((e=>e.x<0))||e.every((e=>e.x>p))||e.every((e=>e.y<0))||e.every((e=>e.y>p))}let Gl;ui("FillExtrusionBucket",Rl,{omit:["layers","features"]});var jl={get paint(){return Gl=Gl||new ns({"fill-extrusion-opacity":new Ki(k["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Qi(k["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Ki(k["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Ki(k["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new es(k["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Qi(k["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Qi(k["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Ki(k["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Xl extends is{constructor(e,t){super(e,jl,t)}createBucket(e){return new Rl(e)}queryRadius(){return aa(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:n,geometry:i,transform:s,pixelsToTileUnits:o,pixelPosMatrix:a}){const l=la(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-s.bearingInRadians,o),u=this.paint.get("fill-extrusion-height").evaluate(r,n),c=this.paint.get("fill-extrusion-base").evaluate(r,n),p=function(e,r){const n=[];for(const i of e){const e=[i.x,i.y,0,1];h(e,e,r),n.push(new t(e[0]/e[3],e[1]/e[3]))}return n}(l,a),f=function(e,r,n,i){const s=[],o=[],a=i[8]*r,l=i[9]*r,u=i[10]*r,c=i[11]*r,h=i[8]*n,p=i[9]*n,f=i[10]*n,d=i[11]*n;for(const r of e){const e=[],n=[];for(const s of r){const r=s.x,o=s.y,y=i[0]*r+i[4]*o+i[12],m=i[1]*r+i[5]*o+i[13],g=i[2]*r+i[6]*o+i[14],x=i[3]*r+i[7]*o+i[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,A=x+d,T=new t((y+a)/b,(m+l)/b);T.z=v/b,e.push(T);const I=new t(w/A,_/A);I.z=S/A,n.push(I)}s.push(e),o.push(n)}return[s,o]}(i,c,u,a);return function(e,t,r){let n=1/0;Jo(r,t)&&(n=Zl(r,t[0]));for(let i=0;ie.id)),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Ws,this.layoutVertexArray2=new Js,this.indexArray=new so,this.programConfigurations=new No(e.layers,e.zoom),this.segments=new uo,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,r){this.hasDependencies=Ra("line",this.layers,t)||this.hasLineDasharray(this.layers);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:t,id:o,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=jo(t,e);if(!this.layers[0]._featureFilter.filter(new $i(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:o,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?u.geometry:Go(t),patterns:{},dashes:{},sortKey:c};s.push(h)}i&&s.sort(((e,t)=>e.sortKey-t.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:o}=n;this.hasDependencies?(Ra("line",this.layers,t)?$a("line",this.layers,n,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,n,this.zoom,t),this.patternFeatures.push(n)):this.addFeature(n,i,s,r,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[s].feature,i,s,o,this.index)}}update(e,t,r,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:r,dashPositions:n})}addFeatures(e,t,r,n){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Kl)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Wl),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,r,n,i,s,o){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),u=a.get("line-cap"),c=a.get("line-miter-limit"),h=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const r of t)this.addLine(r,e,l,u,c,h,n,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{imagePositions:i,dashPositions:s,canonical:n})}addLine(e,t,r,n,i,s,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=vl(e,o?a.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[u-1].equals(e[u-2]);)u--;let c=0;for(;c0;if(w&&t>c){const e=f.dist(d);if(e>2*h){const t=f.sub(f.sub(d)._mult(h/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,m,0,0,p),d=t}}const S=d&&y;let A=S?r:l?"butt":n;if(S&&"round"===A&&(vi&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v100)o=g.mult(-1);else{const e=v*m.add(g).mag()/m.sub(g).mag();o._perp()._mult(e*(_?-1:1))}this.addCurrentVertex(f,o,0,0,p),this.addCurrentVertex(f,o.mult(-1),0,0,p)}else if("bevel"===A||"fakeround"===A){const e=-Math.sqrt(v*v-1),t=_?e:0,r=_?0:e;if(d&&this.addCurrentVertex(f,m,t,r,p),"fakeround"===A){const e=Math.round(180*b/Math.PI/20);for(let t=1;t2*h){const t=f.add(y.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,p),f=t}}}}addCurrentVertex(e,t,r,n,i,s=!1){const o=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*r,t.y-t.x*r,s,!1,r,i),this.addHalfVertex(e,o,a,s,!0,-n,i),this.distance>eu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,r,n,i,s))}addHalfVertex({x:e,y:t},r,n,i,s,o,a){const l=.5*(this.lineClips?this.scaledDistance*(eu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const u=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),a.primitiveLength++),s?this.e2=u:this.e1=u}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,r,n){for(const i of e){const e=i.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const s="round"===i.layout.get("line-cap"),o={dasharray:e.value.evaluate({zoom:r-1},t,{}),round:s},a={dasharray:e.value.evaluate({zoom:r},t,{}),round:s},l={dasharray:e.value.evaluate({zoom:r+1},t,{}),round:s},u=`${o.dasharray.join(",")},${o.round}`,c=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;n.dashDependencies[u]=o,n.dashDependencies[c]=a,n.dashDependencies[h]=l,t.dashes[i.id]={min:u,mid:c,max:h}}}}let ru,nu;ui("LineBucket",tu,{omit:["layers","patternFeatures"]});var iu={get paint(){return nu=nu||new ns({"line-opacity":new Qi(k.paint_line["line-opacity"]),"line-color":new Qi(k.paint_line["line-color"]),"line-translate":new Ki(k.paint_line["line-translate"]),"line-translate-anchor":new Ki(k.paint_line["line-translate-anchor"]),"line-width":new Qi(k.paint_line["line-width"]),"line-gap-width":new Qi(k.paint_line["line-gap-width"]),"line-offset":new Qi(k.paint_line["line-offset"]),"line-blur":new Qi(k.paint_line["line-blur"]),"line-dasharray":new es(k.paint_line["line-dasharray"]),"line-pattern":new es(k.paint_line["line-pattern"]),"line-gradient":new rs(k.paint_line["line-gradient"])})},get layout(){return ru=ru||new ns({"line-cap":new Ki(k.layout_line["line-cap"]),"line-join":new Qi(k.layout_line["line-join"]),"line-miter-limit":new Ki(k.layout_line["line-miter-limit"]),"line-round-limit":new Ki(k.layout_line["line-round-limit"]),"line-sort-key":new Qi(k.layout_line["line-sort-key"])})}};class su extends Qi{possiblyEvaluate(e,t){return t=new $i(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,n){return t=d({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,n)}}let ou;class au extends is{constructor(e,t){super(e,iu,t),this.gradientVersion=0,ou||(ou=new su(iu.paint.properties["line-width"].specification),ou.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof st,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=ou.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new tu(e)}queryRadius(e){const t=e,r=lu(oa("line-width",this,t),oa("line-gap-width",this,t)),n=oa("line-offset",this,t);return r/2+Math.abs(n)+aa(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:r,featureState:n,geometry:i,transform:s,pixelsToTileUnits:o}){const a=la(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-s.bearingInRadians,o),l=o/2*lu(this.paint.get("line-width").evaluate(r,n),this.paint.get("line-gap-width").evaluate(r,n)),u=this.paint.get("line-offset").evaluate(r,n);return u&&(i=function(e,r){const n=[];for(let i=0;i=3)for(let t=0;t0?t+2*e:e}const uu=ls([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),cu=ls([{name:"a_projected_pos",components:3,type:"Float32"}],4);ls([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const hu=ls([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ls([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const pu=ls([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function fu(e,t,r){return e.sections.forEach((e=>{e.text=function(e,t,r){const n=t.layout.get("text-transform").evaluate(r,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Ri.applyArabicShaping&&(e=Ri.applyArabicShaping(e)),e}(e.text,t,r)})),e}ls([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4),ls([{name:"triangle",components:3,type:"Uint16"}]),ls([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),ls([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),ls([{type:"Float32",name:"offsetX"}]),ls([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ls([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var du=24;const yu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},mu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},gu={40:!0};function xu(e,t,r,n,i,s){if("fontStack"in t){const n=r[t.fontStack],s=n&&n[e];return s?s.metrics.advance*t.scale+i:0}{const e=n[t.imageName];return e?e.displaySize[0]*t.scale*du/s+i:0}}function vu(e,t,r,n){const i=Math.pow(e-t,2);return n?eMath.max(e,this.sections[t].scale)),0)}getMaxImageSize(e){let t=0,r=0;for(let n=0;nr)))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void x("Can't add FormattedSection with an empty image.");const r=this.getNextImageSectionCharCode();r?(this.text+=String.fromCharCode(r),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this.sectionIndex.push(this.sections.length-1)):x("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,r,n,i){const s=[],o=this.determineAverageLineWidth(e,t,r,n,i),a=this.hasZeroWidthSpaces();let l=0,u=0;const c=this.text[Symbol.iterator]();let h=c.next();const p=this.text[Symbol.iterator]();p.next();let f=p.next();const d=this.text[Symbol.iterator]();d.next(),d.next();let y=d.next();for(;!h.done;){const t=this.getSection(u),m=h.value.codePointAt(0);if(Mi(m)||(l+=xu(m,t,r,n,e,i)),!f.done){const e=ki(m),r=f.value.codePointAt(0);(mu[m]||e||"imageName"in t||!y.done&&gu[r])&&s.push(wu(u+1,l,o,s,bu(m,r,e&&a),!1))}u++,h=c.next(),f=p.next(),y=d.next()}return _u(wu(this.length(),l,o,s,0,!0))}determineAverageLineWidth(e,t,r,n,i){let s=0,o=0;for(const t of this.text){const a=this.getSection(o);s+=xu(t.codePointAt(0),a,r,n,e,i),o++}return s/Math.max(1,Math.ceil(s/t))}}const Au=4294967296,Tu=1/Au,Iu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class ku{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,r=this.length){for(;this.pos>3,i=this.pos;this.type=7&r,e(n,t,this),this.pos===i&&this.skip(r)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Au;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Au;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let r,n;return n=t[this.pos++],r=127&n,n<128?r:(n=t[this.pos++],r|=(127&n)<<7,n<128?r:(n=t[this.pos++],r|=(127&n)<<14,n<128?r:(n=t[this.pos++],r|=(127&n)<<21,n<128?r:(n=t[this.pos],r|=(15&n)<<28,function(e,t,r){const n=r.buf;let i,s;if(s=n[r.pos++],i=(112&s)>>4,s<128)return Eu(e,i,t);if(s=n[r.pos++],i|=(127&s)<<3,s<128)return Eu(e,i,t);if(s=n[r.pos++],i|=(127&s)<<10,s<128)return Eu(e,i,t);if(s=n[r.pos++],i|=(127&s)<<17,s<128)return Eu(e,i,t);if(s=n[r.pos++],i|=(127&s)<<24,s<128)return Eu(e,i,t);if(s=n[r.pos++],i|=(1&s)<<31,s<128)return Eu(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(r,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Iu?Iu.decode(this.buf.subarray(t,e)):function(e,t,r){let n="",i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+u>r)break;1===u?t<128&&(l=t):2===u?(s=e[i+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===u?(s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const r=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7)}(r,0,t),function(e,t){const r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(n,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,r){for(let n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=n;continue}if(n<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);n<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:(n<65536?e[r++]=n>>12|224:(e[r++]=n>>18|240,e[r++]=n>>12&63|128),e[r++]=n>>6&63|128),e[r++]=63&n|128)}return r}(this.buf,e,this.pos);const r=this.pos-t;r>=128&&Mu(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let r=0;r=128&&Mu(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,r){this.writeTag(e,2),this.writeRawMessage(t,r)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Du,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Pu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Bu,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Fu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,zu,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Cu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Vu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Lu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ou,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Eu(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Mu(e,t,r){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(n);for(let t=r.pos-1;t>=e;t--)r.buf[t+n]=r.buf[t]}function Du(e,t){for(let r=0;rt.h-e.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let i=0,s=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const r=n[e];if(!(t.w>r.w||t.h>r.h)){if(t.x=r.x,t.y=r.y,s=Math.max(s,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===r.w&&t.h===r.h){const t=n.pop();t&&ey.toCodeUnitIndex(e)));const e=x(y.toString(),g);for(const t of e){const e=[...t].map((()=>0));m.push(new Su(t,y.sections,e))}}else if(v){m=[],g=g.map((e=>y.toCodeUnitIndex(e)));let e=0;const t=[];for(const r of y.text)t.push(...Array(r.length).fill(y.sectionIndex[e])),e++;const r=v(y.text,t,g);for(const e of r){const t=[];let r="";for(const n of e[0])t.push(e[1][r.length]),r+=n;m.push(new Su(e[0],y.sections,t))}}else m=function(e,t){const r=[];let n=0;for(const i of t)r.push(e.substring(n,i)),n=i;return nu){const e=Math.ceil(s/u);i*=e/o,o=e}return{x1:n,y1:i,x2:n+s,y2:i+o}}function Qu(e,t,r,n,i,s){const o=e.image;let a;if(o.content){const e=o.content,t=o.pixelRatio||1;a=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}const l=t.left*s,u=t.right*s;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-o.displaySize[0])/2,h=f+o.displaySize[0]);const d=t.top*s,y=t.bottom*s;return"height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+y+n[2]):(c=i[1]+(d+y-o.displaySize[1])/2,p=c+o.displaySize[1]),{image:o,top:c,right:h,bottom:p,left:f,collisionPadding:a}}ui("ImagePosition",Ru),ui("ImageAtlas",$u),function(e){e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e[e.horizontalOnly=3]="horizontalOnly"}(qu||(qu={}));const ec=128,tc=32640;function rc(e,t){const{expression:r}=t;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new $i(e+1))};if("source"===r.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=r;let i=0;for(;ie.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=rc(this.zoom,t["text-size"]),this.iconSizeData=rc(this.zoom,t["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.canOverlap="never"!==nc(r,"text-overlap","text-allow-overlap")||"never"!==nc(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>qu[e]))),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID}createArrays(){this.text=new lc(new No(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new lc(new No(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new $s,this.symbolInstances=new Ns,this.textAnchorOffsets=new Us}calculateGlyphDependencies(e,t,r,n,i){for(const s of e)if(t[s.codePointAt(0)]=!0,(r||n)&&i){const e=yu[s];e&&(t[e.codePointAt(0)]=!0)}}populate(e,t,r){const n=this.layers[0],i=n.layout,s=i.get("text-font"),o=i.get("text-field"),a=i.get("icon-image"),l=("constant"!==o.value.kind||o.value.value instanceof Me&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==a.value.kind||!!a.value.value||Object.keys(a.parameters).length>0,c=i.get("symbol-sort-key");if(this.features=[],!l&&!u)return;const h=t.iconDependencies,p=t.glyphDependencies,f=t.availableImages,d=new $i(this.zoom);for(const{feature:t,id:o,index:a,sourceLayerIndex:y}of e){const e=n._featureFilter.needGeometry,m=jo(t,e);if(!n._featureFilter.filter(d,m,r))continue;let g,x;if(e||(m.geometry=Go(t)),l){const e=n.getValueAndResolveTokens("text-field",m,r,f),t=Me.factory(e),i=this.hasRTLText=this.hasRTLText||ac(t);(!i||"unavailable"===Ri.getRTLTextPluginStatus()||i&&Ri.isParsed())&&(g=fu(t,n,m))}if(u){const e=n.getValueAndResolveTokens("icon-image",m,r,f);x=e instanceof Ve?e:Ve.fromString(e)}if(!g&&!x)continue;const v=this.sortFeaturesByKey?c.evaluate(m,{},r):void 0;if(this.features.push({id:o,text:g,icon:x,index:a,sourceLayerIndex:y,geometry:m.geometry,properties:t.properties,type:Pl.types[t.type],sortKey:v}),x&&(h[x.name]=!0),g){const e=s.evaluate(m,{},r).join(","),t="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(qu.vertical)>=0;for(const r of g.sections)if(r.image)h[r.image.name]=!0;else{const n=Di(g.toString()),i=r.fontStack||e,s=p[i]=p[i]||{};this.calculateGlyphDependencies(r.text,s,t,this.allowVerticalPlacement,n)}}}"line"===i.get("symbol-placement")&&(this.features=function(e){const t={},r={},n=[];let i=0;function s(t){n.push(e[t]),i++}function o(e,t,i){const s=r[e];return delete r[e],r[t]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function a(e,r,i){const s=t[r];return delete t[r],t[e]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(e,t,r){const n=r?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let u=0;ue.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:r}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:r}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,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(e,t){const r=this.lineVertexArray.length;if(void 0!==e.segment){let r=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const i={};for(let n=e.segment+1;n=0;r--)i[r]={x:t[r].x,y:t[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=t[r-1].dist(t[r]));for(let e=0;e0}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(e,t){const r=e.placedSymbolArray.get(t),n=r.vertexStartIndex+4*r.numGlyphs;for(let t=r.vertexStartIndex;tn[e]-n[t]||i[t]-i[e])),s}addToSortKeyRanges(e,t){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach(((e,t,r)=>{e>=0&&r.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)})),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let hc,pc;ui("SymbolBucket",cc,{omit:["layers","collisionBoxArray","features","compareText"]}),cc.MAX_GLYPHS=65535,cc.addDynamicAttributes=oc;var fc={get paint(){return pc=pc||new ns({"icon-opacity":new Qi(k.paint_symbol["icon-opacity"]),"icon-color":new Qi(k.paint_symbol["icon-color"]),"icon-halo-color":new Qi(k.paint_symbol["icon-halo-color"]),"icon-halo-width":new Qi(k.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Qi(k.paint_symbol["icon-halo-blur"]),"icon-translate":new Ki(k.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ki(k.paint_symbol["icon-translate-anchor"]),"text-opacity":new Qi(k.paint_symbol["text-opacity"]),"text-color":new Qi(k.paint_symbol["text-color"],{runtimeType:L,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Qi(k.paint_symbol["text-halo-color"]),"text-halo-width":new Qi(k.paint_symbol["text-halo-width"]),"text-halo-blur":new Qi(k.paint_symbol["text-halo-blur"]),"text-translate":new Ki(k.paint_symbol["text-translate"]),"text-translate-anchor":new Ki(k.paint_symbol["text-translate-anchor"])})},get layout(){return hc=hc||new ns({"symbol-placement":new Ki(k.layout_symbol["symbol-placement"]),"symbol-spacing":new Ki(k.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ki(k.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Qi(k.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ki(k.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Ki(k.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Ki(k.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Ki(k.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ki(k.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ki(k.layout_symbol["icon-rotation-alignment"]),"icon-size":new Qi(k.layout_symbol["icon-size"]),"icon-text-fit":new Ki(k.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ki(k.layout_symbol["icon-text-fit-padding"]),"icon-image":new Qi(k.layout_symbol["icon-image"]),"icon-rotate":new Qi(k.layout_symbol["icon-rotate"]),"icon-padding":new Qi(k.layout_symbol["icon-padding"]),"icon-keep-upright":new Ki(k.layout_symbol["icon-keep-upright"]),"icon-offset":new Qi(k.layout_symbol["icon-offset"]),"icon-anchor":new Qi(k.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ki(k.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ki(k.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ki(k.layout_symbol["text-rotation-alignment"]),"text-field":new Qi(k.layout_symbol["text-field"]),"text-font":new Qi(k.layout_symbol["text-font"]),"text-size":new Qi(k.layout_symbol["text-size"]),"text-max-width":new Qi(k.layout_symbol["text-max-width"]),"text-line-height":new Ki(k.layout_symbol["text-line-height"]),"text-letter-spacing":new Qi(k.layout_symbol["text-letter-spacing"]),"text-justify":new Qi(k.layout_symbol["text-justify"]),"text-radial-offset":new Qi(k.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ki(k.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Qi(k.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Qi(k.layout_symbol["text-anchor"]),"text-max-angle":new Ki(k.layout_symbol["text-max-angle"]),"text-writing-mode":new Ki(k.layout_symbol["text-writing-mode"]),"text-rotate":new Qi(k.layout_symbol["text-rotate"]),"text-padding":new Ki(k.layout_symbol["text-padding"]),"text-keep-upright":new Ki(k.layout_symbol["text-keep-upright"]),"text-transform":new Qi(k.layout_symbol["text-transform"]),"text-offset":new Qi(k.layout_symbol["text-offset"]),"text-allow-overlap":new Ki(k.layout_symbol["text-allow-overlap"]),"text-overlap":new Ki(k.layout_symbol["text-overlap"]),"text-ignore-placement":new Ki(k.layout_symbol["text-ignore-placement"]),"text-optional":new Ki(k.layout_symbol["text-optional"])})}};class dc{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:z,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}ui("FormatSectionOverride",dc,{omit:["defaultValue"]});class yc extends is{constructor(e,t){super(e,fc,t)}recalculate(e,t){if(super.recalculate(e,t),"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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const r of e)t.indexOf(r)<0&&t.push(r);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,r,n){const i=this.layout.get(e).evaluate(t,{},r,n),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||en(s.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,((t,r)=>e&&r in e?String(e[r]):""))}(t.properties,i)}createBucket(e){return new cc(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of fc.paint.overridableProperties){if(!yc.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new dc(t),n=new Qr(r,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new rn("source",n):new nn("composite",n,t.value.zoomStops),this.paint._values[e]=new Wi(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,r){return!(!this.layout||t.isDataDriven()||r.isDataDriven())&&yc.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),n=fc.paint.properties[t];let i=!1;const s=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Me)s(r.value.value.sections);else if("source"===r.value.kind||"composite"===r.value.kind){const e=t=>{i||(t instanceof qe&&Re(t.value)===q?s(t.value.sections):t instanceof It?s(t.sections):t.eachChild(e))},t=r.value;t._styleExpression&&e(t._styleExpression.expression)}return i}}let mc;var gc={get paint(){return mc=mc||new ns({"background-color":new Ki(k.paint_background["background-color"]),"background-pattern":new ts(k.paint_background["background-pattern"]),"background-opacity":new Ki(k.paint_background["background-opacity"])})}};class xc extends is{constructor(e,t){super(e,gc,t)}}let vc;var bc,wc,_c,Sc,Ac,Tc,Ic,kc,Ec,Mc,Dc={get paint(){return vc=vc||new ns({"raster-opacity":new Ki(k.paint_raster["raster-opacity"]),"raster-hue-rotate":new Ki(k.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ki(k.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ki(k.paint_raster["raster-brightness-max"]),"raster-saturation":new Ki(k.paint_raster["raster-saturation"]),"raster-contrast":new Ki(k.paint_raster["raster-contrast"]),"raster-resampling":new Ki(k.paint_raster["raster-resampling"]),"raster-fade-duration":new Ki(k.paint_raster["raster-fade-duration"])})}};class Pc extends is{constructor(e,t){super(e,Dc,t)}}class Fc extends is{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}function zc(e,t){if("custom"===e.type)return new Fc(e,t);switch(e.type){case"background":return new xc(e,t);case"circle":return new xa(e,t);case"color-relief":return new La(e,t);case"fill":return new kl(e,t);case"fill-extrusion":return new Xl(e,t);case"heatmap":return new Ea(e,t);case"hillshade":return new Pa(e,t);case"line":return new au(e,t);case"raster":return new Pc(e,t);case"symbol":return new yc(e,t)}}class Bc{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Cc{constructor(e,t,r,n,i){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=r,e._y=n,this.properties=e.properties,this.id=i}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Vc{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,t,r){this._name=e,this.dataBuffer=t,"number"==typeof r?this._size=r:(this.nullabilityBuffer=r,this._size=r.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Lc extends Vc{}class Oc extends Lc{getValueFromBuffer(e){return this.dataBuffer[e]}}class Nc extends Lc{getValueFromBuffer(e){return this.dataBuffer[e]}}class Rc extends Vc{delta;constructor(e,t,r,n){super(e,t,n),this.delta=r}}class $c extends Rc{constructor(e,t,r,n){super(e,Int32Array.of(t),r,n)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class qc extends Vc{constructor(e,t,r){super(e,Int32Array.of(t),r)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Uc{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,t,r,n,i=4096){this._name=e,this._geometryVector=t,this._idVector=r,this._propertyVectors=n,this._extent=i}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((e=>[e.name,e])))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let t=0;for(;t>4,i<128)return 4294967296*n+(e>>>0);if(i=t[r.get()],r.increment(),n|=(127&i)<<3,i<128)return 4294967296*n+(e>>>0);if(i=t[r.get()],r.increment(),n|=(127&i)<<10,i<128)return 4294967296*n+(e>>>0);if(i=t[r.get()],r.increment(),n|=(127&i)<<17,i<128)return 4294967296*n+(e>>>0);if(i=t[r.get()],r.increment(),n|=(127&i)<<24,i<128)return 4294967296*n+(e>>>0);if(i=t[r.get()],r.increment(),n|=(1&i)<<31,i<128)return 4294967296*n+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(r,e,t)))))}function Hc(e,t,r,n){throw new Error("FastPFor is not implemented yet.")}function Wc(e){return e>>>1^-(1&e)}function Jc(e){return e>>1n^-(1n&e)}function Kc(e,t){let r=0n,n=0,i=t.get();for(;i=64)throw new Error("Varint too long")}return t.set(i),r}function Qc(e,t,r){const n=new Int32Array(r);let i=0;for(let r=0;r=4)for(let n=e[0];r>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const t=e.length/4*4;let r=2;if(t>=4)for(;r>>1^-(1&t))+e[r-2],e[r+1]=(n>>>1^-(1&n))+e[r-1],e[r+2]=(i>>>1^-(1&i))+e[r],e[r+3]=(s>>>1^-(1&s))+e[r+1]}for(;r!=e.length;r+=2)e[r]=(e[r]>>>1^-(1&e[r]))+e[r-2],e[r+1]=(e[r+1]>>>1^-(1&e[r+1]))+e[r-1]}function ih(e,t,r){return Math.min(r,Math.max(t,e))}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(wc||(wc={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(_c||(_c={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Sc||(Sc={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Ac||(Ac={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Tc||(Tc={}));class sh{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(e,t,r,n,i,s,o){this._physicalStreamType=e,this._logicalStreamType=t,this._logicalLevelTechnique1=r,this._logicalLevelTechnique2=n,this._physicalLevelTechnique=i,this._numValues=s,this._byteLength=o}static decode(e,t){const r=e[t.get()],n=Object.values(bc)[r>>4];let i=null;switch(n){case bc.DATA:i=new jc(Object.values(Sc)[15&r]);break;case bc.OFFSET:i=new jc(null,Object.values(Ac)[15&r]);break;case bc.LENGTH:i=new jc(null,null,Object.values(Tc)[15&r])}t.increment();const s=e[t.get()],o=Object.values(wc)[s>>5],a=Object.values(wc)[s>>2&7],l=Object.values(_c)[3&s];t.increment();const u=Xc(e,t,2);return new sh(n,i,o,a,l,u[0],u[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class oh extends sh{num_bits;coordinate_shift;constructor(e,t,r,n,i,s,o,a,l){super(e,t,r,n,i,s,o),this.num_bits=a,this.coordinate_shift=l}static decode(e,t){const r=sh.decode(e,t),n=Xc(e,t,2);return new oh(r.physicalStreamType,r.logicalStreamType,r.logicalLevelTechnique1,r.logicalLevelTechnique2,r.physicalLevelTechnique,r.numValues,r.byteLength,n[0],n[1])}static decodePartial(e,t,r){const n=Xc(t,r,2);return new oh(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class ah extends sh{_runs;_numRleValues;constructor(e,t,r,n,i,s,o,a,l){super(e,t,r,n,i,s,o),this._runs=a,this._numRleValues=l}static decode(e,t){const r=sh.decode(e,t),n=Xc(e,t,2);return new ah(r.physicalStreamType,r.logicalStreamType,r.logicalLevelTechnique1,r.logicalLevelTechnique2,r.physicalLevelTechnique,r.numValues,r.byteLength,n[0],n[1])}static decodePartial(e,t,r){const n=Xc(t,r,2);return new ah(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class lh{static decode(e,t){const r=sh.decode(e,t);return r.logicalLevelTechnique1===wc.MORTON?oh.decodePartial(r,e,t):wc.RLE!==r.logicalLevelTechnique1&&wc.RLE!==r.logicalLevelTechnique2||_c.NONE===r.physicalLevelTechnique?r:ah.decodePartial(r,e,t)}}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Ic||(Ic={}));class uh{values;_size;constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const r=Math.floor(e/8);this.values[r]=this.values[r]|(t?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}class ch{constructor(){}static decodeIntStream(e,t,r,n,i){const s=ch.decodePhysicalLevelTechnique(e,t,r);return this.decodeIntBuffer(s,r,n,i)}static decodeLengthStreamToOffsetBuffer(e,t,r){const n=ch.decodePhysicalLevelTechnique(e,t,r);return this.decodeLengthToOffsetBuffer(n,r)}static decodePhysicalLevelTechnique(e,t,r){const n=r.physicalLevelTechnique;if(n===_c.FAST_PFOR)return Hc();if(n===_c.VARINT)return Xc(e,t,r.numValues);if(n===_c.NONE){const n=t.get();t.add(r.byteLength);const i=e.subarray(n,t.get());return new Int32Array(i)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(e,t,r,n){const i=ch.decodePhysicalLevelTechnique(e,t,r);if(1===i.length){const e=i[0];return n?Wc(e):e}return n?function(e){return Wc(e[1])}(i):function(e){return e[1]}(i)}static decodeSequenceIntStream(e,t,r){return function(e){if(2==e.length){const t=Wc(e[1]);return[t,t]}return[Wc(e[2]),Wc(e[3])]}(ch.decodePhysicalLevelTechnique(e,t,r))}static decodeSequenceLongStream(e,t,r){return function(e){if(2==e.length){const t=Jc(e[1]);return[t,t]}return[Jc(e[2]),Jc(e[3])]}(Yc(e,t,r.numValues))}static decodeLongStream(e,t,r,n){const i=Yc(e,t,r.numValues);return this.decodeLongBuffer(i,r,n)}static decodeLongFloat64Stream(e,t,r,n){const i=function(e,t,r){const n=new Float64Array(t);for(let i=0;i>>1^-(1&e[0]);const t=e.length/4*4;let r=1;if(t>=4)for(;r>>1^-(1&t))+e[r-1],e[r+1]=(n>>>1^-(1&n))+e[r],e[r+2]=(i>>>1^-(1&i))+e[r+1],e[r+3]=(s>>>1^-(1&s))+e[r+2]}for(;r!=e.length;++r)e[r]=(e[r]>>>1^-(1&e[r]))+e[r-1]}(e),e);case wc.RLE:return function(e,t,r){return r?function(e,t,r){const n=new Int32Array(r);let i=0;for(let r=0;r>>1^-(1&o),n.fill(o,i,i+s),i+=s}return n}(e,t.runs,t.numRleValues):Qc(e,t.runs,t.numRleValues)}(e,t,r);case wc.MORTON:return rh(e),e;case wc.COMPONENTWISE_DELTA:return n?(function(e,t,r,n){let i=e[0]>>>1^-(1&e[0]),s=e[1]>>>1^-(1&e[1]);e[0]=ih(Math.round(i*t),r,n),e[1]=ih(Math.round(s*t),r,n);const o=e.length/16;let a=2;if(o>=4)for(;a>>1^-(1&o))+i,c=(l>>>1^-(1&l))+s;e[a]=ih(Math.round(u*t),r,n),e[a+1]=ih(Math.round(c*t),r,n);const h=e[a+2],p=e[a+3];i=(h>>>1^-(1&h))+u,s=(p>>>1^-(1&p))+c,e[a+2]=ih(Math.round(i*t),r,n),e[a+3]=ih(Math.round(s*t),r,n)}for(;a!=e.length;a+=2)i+=e[a]>>>1^-(1&e[a]),s+=e[a+1]>>>1^-(1&e[a+1]),e[a]=ih(Math.round(i*t),r,n),e[a+1]=ih(Math.round(s*t),r,n)}(e,n.scale,n.min,n.max),e):(nh(e),e);case wc.NONE:return r&&function(e){for(let t=0;t>>1^-(1&r)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeLongBuffer(e,t,r){switch(t.logicalLevelTechnique1){case wc.DELTA:return t.logicalLevelTechnique2===wc.RLE?function(e,t,r){const n=new BigInt64Array(r);let i=0,s=0n;for(let r=0;r>1n^-(1n&e[0]);const t=e.length/4*4;let r=1;if(t>=4)for(;r>1n^-(1n&t))+e[r-1],e[r+1]=(n>>1n^-(1n&n))+e[r],e[r+2]=(i>>1n^-(1n&i))+e[r+1],e[r+3]=(s>>1n^-(1n&s))+e[r+2]}for(;r!=e.length;++r)e[r]=(e[r]>>1n^-(1n&e[r]))+e[r-1]}(e),e);case wc.RLE:return function(e,t,r){return r?function(e,t,r){const n=new BigInt64Array(r);let i=0;for(let r=0;r>1n^-(1n&o),n.fill(o,i,i+s),i+=s}return n}(e,t.runs,t.numRleValues):eh(e,t.runs,t.numRleValues)}(e,t,r);case wc.NONE:return r&&function(e){for(let t=0;t>1n^-(1n&r)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(e,t,r){switch(t.logicalLevelTechnique1){case wc.DELTA:return t.logicalLevelTechnique2===wc.RLE&&(e=th(e,t.runs,t.numRleValues)),function(e){e[0]=e[0]%2==1?(e[0]+1)/-2:e[0]/2;const t=e.length/4*4;let r=1;if(t>=4)for(;r>>1^-(1&i),t[n]=t[n-1]+r}return t}(e);if(t.logicalLevelTechnique1===wc.RLE&&t.logicalLevelTechnique2===wc.NONE)return function(e,t,r){const n=new Int32Array(r+1);n[0]=0;let i=1,s=n[0];for(let r=0;r>>1^-(1&a);for(let e=i;e>>1^-(1&t[0]):0,n=1):r[0]=0;let i=1;for(;i!=r.length;++i)r[i]=e.get(i)?r[i-1]+(t[n]>>>1^-(1&t[n++])):r[i-1];return r}(n,e);case wc.RLE:return function(e,t,r,n){const i=t;return r?function(e,t,r){const n=new Int32Array(e.size());let i=0;for(let s=0;s>>1^-(1&a);for(let t=i;t>>1^-(1&e)}else r[i]=0;return r}(n,e):function(e,t){const r=new Int32Array(e.size());let n=0,i=0;for(;i!=r.length;++i)r[i]=e.get(i)?t[n++]:0;return r}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(e,t,r,n){switch(t.logicalLevelTechnique1){case wc.DELTA:return t.logicalLevelTechnique2===wc.RLE&&(e=eh(e,t.runs,t.numRleValues)),function(e,t){const r=new BigInt64Array(e.size());let n=0;e.get(0)?(r[0]=e.get(0)?t[0]>>1n^-(1n&t[0]):0n,n=1):r[0]=0n;let i=1;for(;i!=r.length;++i)r[i]=e.get(i)?r[i-1]+(t[n]>>1n^-(1n&t[n++])):r[i-1];return r}(n,e);case wc.RLE:return function(e,t,r,n){const i=t;return r?function(e,t,r){const n=new BigInt64Array(e.size());let i=0;for(let s=0;s>1n^-(1n&a);for(let t=i;t>1n^-(1n&e)}else r[i]=0n;return r}(n,e):function(e,t){const r=new BigInt64Array(e.size());let n=0,i=0;for(;i!=r.length;++i)r[i]=e.get(i)?t[n++]:0n;return r}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(e,t,r,n){const i=e.logicalLevelTechnique1;if(i===wc.RLE)return 1===e.runs?Ic.CONST:Ic.FLAT;const s=t instanceof uh?t.size():t;if(i===wc.DELTA&&e.logicalLevelTechnique2===wc.RLE){const t=e.runs,i=2;if(e.numRleValues!==s)return Ic.FLAT;if(1===t)return Ic.SEQUENCE;if(2===t){const t=n.get();let s;if(e.physicalLevelTechnique===_c.VARINT)s=Xc(r,n,4);else{const e=n.get();s=new Int32Array(r.buffer,r.byteOffset+e,4)}if(n.set(t),s[2]===i&&s[3]===i)return Ic.SEQUENCE}}return 1===e.numValues?Ic.CONST:Ic.FLAT}}class hh extends Lc{getValueFromBuffer(e){return this.dataBuffer[e]}}class ph extends Rc{constructor(e,t,r,n){super(e,BigInt64Array.of(t),r,n)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class fh{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,t,r){this._geometryOffsets=e,this._partOffsets=t,this._ringOffsets=r}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class dh{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(e,t){this._coordinateShift=e<0?Math.abs(e):0,this.tileExtent=t+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=e,this.maxBound=t}validateCoordinates(e){if(e.xthis.maxBound||e.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class yh extends dh{encode(e){this.validateCoordinates(e);const t=e.x+this._coordinateShift,r=e.y+this._coordinateShift;let n=0;for(let e=0;e>1)-this._coordinateShift}}decodeMorton(e){let t=0;for(let r=0;r>r;return t}static decode(e,t,r){return{x:yh.decodeMorton(e,t)-r,y:yh.decodeMorton(e>>1,t)-r}}static decodeMorton(e,t){let r=0;for(let n=0;n>n;return r}}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(kc||(kc={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Ec||(Ec={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(Mc||(Mc={}));class mh{createPoint(e){return[[e]]}createMultiPoint(e){return e.map((e=>[e]))}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,t){return[e,...t]}createMultiPolygon(e){return e.flat()}}function gh(e){const r=new Array(e.numGeometries);let n=1,i=1,s=1,o=0;const a=new mh;let l=0,u=0;const c=e.mortonSettings,h=e.topologyVector,p=h.geometryOffsets,f=h.partOffsets,d=h.ringOffsets,y=e.vertexOffsets,m=e.containsPolygonGeometry(),g=e.vertexBuffer;for(let h=0;h0&&r.push(r[0]),h.push(r)}e[r]=h,s&&u++}break;case kc.MULTIPOLYGON:{const c=s[u]-s[u-1];u++;const h=[];for(let e=0;e0&&r.push(r[0]),h.push(r)}}e[r]=h}}return e}[Symbol.iterator](){return null}}class Eh extends kh{_numGeometries;_geometryType;constructor(e,t,r,n,i,s){super(r,n,i,s),this._numGeometries=e,this._geometryType=t}static create(e,t,r,n,i,s){return new Eh(e,t,r,n,i,s)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class Mh extends kh{_geometryTypes;constructor(e,t,r,n,i){super(t,r,n,i),this._geometryTypes=e}static create(e,t,r,n,i){return new Mh(e,t,r,n,i)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Dh(e,t,r,n,i){const s=lh.decode(e,r);let o=null,a=null,l=null,u=null,c=null,h=null,p=null,f=null;if(ch.getVectorType(s,n,e,r)===Ic.CONST){const d=ch.decodeConstIntStream(e,r,s,!1);for(let n=0;nr?t[s++]:1);return n}function Fh(e,t,r,n){const i=new Int32Array(t[t.length-1]+1);let s=0;i[0]=s;let o=1,a=0;for(let l=0;l=12?Nh.decode(e.subarray(t,r)):function(e,t,r){let n="",i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+u>r)break;1===u?t<128&&(l=t):2===u?(s=e[i+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===u?(s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u}return n}(e,t,r)}class $h extends Vc{offsetBuffer;constructor(e,t,r,n){super(e,r,n),this.offsetBuffer=t}}class qh extends $h{textEncoder;constructor(e,t,r,n){super(e,t,r,n??t.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return Rh(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Uh extends $h{indexBuffer;textEncoder;constructor(e,t,r,n,i){super(e,r,n,i??t.length),this.indexBuffer=t,this.indexBuffer=t,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const t=this.indexBuffer[e];return Rh(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Gh extends $h{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,t,r,n,i,s,o){super(e,r,n,o),this.indexBuffer=t,this.symbolOffsetBuffer=i,this.symbolTableBuffer=s,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,t,r){const n=[],i=new Array(t.length).fill(0);for(let e=1;e1?6:4,r.type="physicalType",t.scalarType=r,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return this.mapScalarType(e)}}static columnTypeHasName(e){return e>=10}static columnTypeHasChildren(e){return 30===e}static hasStreamCount(e){if("id"===e.name)return!1;if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}static mapScalarType(e){let t=null;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const r={};r.nullable=!!(1&e),r.columnScope=0;const n={type:"physicalType"};return n.physicalType=t,r.type="scalarType",r.scalarType=n,r}}const Hh=new TextDecoder;function Wh(e,t){const r=Xc(e,t,1)[0];if(0===r)return"";const n=t.get(),i=e.subarray(n,n+r);return t.add(r),Hh.decode(i)}function Jh(e,t){const r=Xc(e,t,1)[0]>>>0,n=!!(4&r),i=!!(2&r),s=Xc(e,t,1)[0]>>>0,o={};if(1&r&&(o.nullable=!0),i){const i={};if(n?(i.type="logicalType",i.logicalType=s):(i.type="physicalType",i.physicalType=s),8&r){const r=Xc(e,t,1)[0]>>>0;i.children=new Array(r);for(let n=0;n>>0,n=Zh.decodeColumnType(r);if(!n)throw new Error(`Unsupported column type code: ${r}`);if(Zh.columnTypeHasName(r)?n.name=Wh(e,t):r>=0&&r<=3?n.name="id":4===r&&(n.name="geometry"),Zh.columnTypeHasChildren(r)){const r=Xc(e,t,1)[0]>>>0,i=n.complexType;i.children=new Array(r);for(let n=0;n>>0,s=Xc(e,t,1)[0]>>>0;n.columns=new Array(s);for(let r=0;rthis.projectPoint(e,t,r,n)))}toGeoJSON(e,t,r){const n=this.extent*Math.pow(2,r),i=this.extent*e,s=this.extent*t,o=this.loadGeometry();let a;switch(this.type){case 1:{const e=[];for(const t of o)e.push(t[0]);const t=this.projectLine(e,i,s,n);a=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};break}case 2:{const e=o.map((e=>this.projectLine(e,i,s,n)));a=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Qt(o),t=[];for(const r of e)t.push(r.map((e=>this.projectLine(e,i,s,n))));a=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};break}default:throw new Error(`unknown feature type: ${this.type}`)}const l={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(l.id=this.id),l}loadGeometry(){const e=[];for(const r of this._featureData.geometry.coordinates){const n=[];for(const e of r)n.push(new t(e.x,e.y));e.push(n)}return e}bbox(){return[0,0,0,0]}}class rp{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new tp(this.features[e],this.extent)}}class np{constructor(e){this.layers={};const t=function(e,t,r=!0){const n=new Gc(0),i=[];for(;n.get()>>0,o=n.get()+s;if(o>e.length)throw new Error(`Block overruns tile: ${o} > ${e.length}`);if(1!=Xc(e,n,1)[0]>>>0){n.set(o);continue}const a=Qh(e,n),l=a[1],u=a[0].featureTables[0];let c=null,h=null;const p=[];let f=0;for(const i of u.columns){const s=i.name;if("id"===s){let t=null;if(i.nullable){const r=lh.decode(e,n),i=n.get(),s=Lh(e,r.numValues,n);n.set(i+r.byteLength),t=new uh(s,r.numValues)}const o=lh.decode(e,n);f=o.getDecompressedCount(),c=ep(e,i,n,s,o,t??f,r)}else if("geometry"===s){const r=Xc(e,n,1)[0];if(0===f){const t=n.get();f=lh.decode(e,n).getDecompressedCount(),n.set(t)}h=Dh(e,r,n,f,t)}else{const t=Zh.hasStreamCount(i)?Xc(e,n,1)[0]:1;if(0===t&&"scalarType"===i.type)continue;const r=Xh(e,n,i,t,f,void 0);r&&(Array.isArray(r)?p.push(...r):p.push(r))}}const d=new Uc(u.name,h,c,p,l);i.push(d),n.set(o)}return i}(new Uint8Array(e));this.layers=t.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new rp(t)})),{})}}class ip{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const r=new ip;return r.extend(e(new t(this.minX,this.minY))),r.extend(e(new t(this.maxX,this.minY))),r.extend(e(new t(this.minX,this.maxY))),r.extend(e(new t(this.maxX,this.maxY))),r}static fromPoints(e){const t=new ip;for(const r of e)t.extend(r);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}const sp="_geojsonTileLayer";class op{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new I(p,16,0),this.grid3D=new I(p,16,0),this.featureIndexArray=new js,this.promoteId=t}insert(e,t,r,n,i,s){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const a=s?this.grid3D:this.grid;for(let e=0;e=0&&n[3]>=0&&a.insert(o,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Vl(new ku(this.rawTileData)).layers:new np(this.rawTileData).layers,this.sourceLayerCoder=new Bc(this.vtLayers?Object.keys(this.vtLayers).sort():[sp])),this.vtLayers}query(e,r,n,i){this.loadVTLayers();const s=e.params,o=p/e.tileSize/e.scale,a=pn(s.filter,s.globalState),l=e.queryGeometry,u=e.queryPadding*o,c=ip.fromPoints(l),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),f=ip.fromPoints(e.cameraQueryGeometry).expandBy(u),d=this.grid3D.query(f.minX,f.minY,f.maxX,f.maxY,((r,n,i,s)=>function(e,r,n,i,s){for(const t of e)if(r<=t.x&&n<=t.y&&i>=t.x&&s>=t.y)return!0;const o=[new t(r,n),new t(r,s),new t(i,s),new t(i,n)];if(e.length>2)for(const t of o)if(ia(e,t))return!0;for(let t=0;t(p||(p=Go(t)),r.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:p,zoom:this.z,transform:e.transform,pixelsToTileUnits:o,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation}))))}return y}loadMatchingFeature(e,t,r,n,i,s,o,a,l,u,c){const h=this.bucketLayerIDs[t];if(s&&!h.some((e=>s.has(e))))return;const p=this.sourceLayerCoder.decode(r),f=this.vtLayers[p].feature(n);if(i.needGeometry){const e=jo(f,!0);if(!i.filter(new $i(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new $i(this.tileID.overscaledZ),f))return;const y=this.getId(f,p);for(let t=0;t{const o=t instanceof Ji?t.get(s):null;return o&&o.evaluate?o.evaluate(r,n,i):o}))}function lp(e,t){return t-e}ui("FeatureIndex",op,{omit:["rawTileData","sourceLayerCoder"]});class up{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(e,t,r){for(const t of e){this._layerConfigs[t.id]=t;const e=this._layers[t.id]=zc(t,r);e._featureFilter=pn(e.filter,r),this.keyCache[t.id]&&delete this.keyCache[t.id]}for(const e of t)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const r={};for(let n=0;nthis._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const n=r.source||"";let i=this.familiesBySource[n];i||(i=this.familiesBySource[n]={});const s=r.sourceLayer||sp;let o=i[s];o||(o=i[s]=[]),o.push(t)}}}class cp extends t{constructor(e,t,r,n){super(e,t),this.angle=r,void 0!==n&&(this.segment=n)}clone(){return new cp(this.x,this.y,this.angle,this.segment)}}function hp(e,t,r,n,i){if(void 0===t.segment||0===r)return!0;let s=t,o=t.segment+1,a=0;for(;a>-r/2;){if(o--,o<0)return!1;a-=e[o].dist(s),s=e[o]}a+=e[o].dist(e[o+1]),o++;const l=[];let u=0;for(;an;)u-=l.shift().angleDelta;if(u>i)return!1;o++,a+=t.dist(r)}return!0}function pp(e){let t=0;for(let r=0;ru){const c=(u-l)/s,h=ft.number(n.x,i.x,c),p=ft.number(n.y,i.y,c),f=new cp(h,p,i.angleTo(n),r);return f._round(),!o||hp(e,f,a,o,t)?f:void 0}l+=s}}function mp(e,t,r,n,i,s,o,a,l){const u=fp(n,s,o),c=dp(n,i),h=c*o,p=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&x=0&&p+u<=c){const r=new cp(g,x,y,t);r._round(),n&&!hp(e,r,s,n,i)||f.push(r)}}h+=d}return a||f.length||o||(f=gp(e,h/2,r,n,i,s,o,!0,l)),f}function xp(e,t,r,n,i,s){let o=vp(e,t,r,i,0);return o=vp(o,t,n,s,1),o}function vp(e,t,r,n,i){switch(t){case 1:return function(e,t,r,n){const i=[];for(const s of e)for(const e of s){const s=0===n?e.x:e.y;s>=t&&s<=r&&i.push([e])}return i}(e,r,n,i);case 2:return wp(e,r,n,i,!1);case 3:return wp(e,r,n,i,!0)}return[]}function bp(e,r,n,i,s){const o=0===i?_p:Sp;let a=[];const l=[];for(let t=0;tr&&a.push(o(u,c,r)):h>n?p=r&&(a.push(o(u,c,r)),f=!0),p>n&&h<=n&&(a.push(o(u,c,n)),f=!0),!s&&f&&(l.push(a),a=[])}const u=e.length-1,c=0===i?e[u].x:e[u].y;return c>=r&&c<=n&&a.push(e[u]),s&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new t(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function wp(e,t,r,n,i){const s=[];for(const o of e){const e=bp(o,t,r,n,i);e.length>0&&s.push(...e)}return s}function _p(e,r,n){return new t(n,e.y+(n-e.x)/(r.x-e.x)*(r.y-e.y))}function Sp(e,r,n){return new t(e.x+(n-e.y)/(r.y-e.y)*(r.x-e.x),n)}function Ap(e,r,n,i){const s=[],o=e.image,a=o.pixelRatio,l=o.paddedRect.w-2,u=o.paddedRect.h-2;let c={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=o.stretchX||[[0,l]],p=o.stretchY||[[0,u]],f=(e,t)=>e+t[1]-t[0],d=h.reduce(f,0),y=p.reduce(f,0),m=l-d,g=u-y;let x=0,v=d,b=0,w=y,_=0,S=m,A=0,T=g;if(o.content&&i){const t=o.content,r=t[2]-t[0],n=t[3]-t[1];(o.textFitWidth||o.textFitHeight)&&(c=Ku(e)),x=Tp(h,0,t[0]),b=Tp(p,0,t[1]),v=Tp(h,t[0],t[2]),w=Tp(p,t[1],t[3]),_=t[0]-x,A=t[1]-b,S=r-v,T=n-w}const I=c.x1,k=c.y1,E=c.x2-I,M=c.y2-k,D=(e,i,s,l)=>{const u=kp(e.stretch-x,v,E,I),c=Ep(e.fixed-_,S,e.stretch,d),h=kp(i.stretch-b,w,M,k),p=Ep(i.fixed-A,T,i.stretch,y),f=kp(s.stretch-x,v,E,I),m=Ep(s.fixed-_,S,s.stretch,d),g=kp(l.stretch-b,w,M,k),D=Ep(l.fixed-A,T,l.stretch,y),P=new t(u,h),F=new t(f,h),z=new t(f,g),B=new t(u,g),C=new t(c/a,p/a),V=new t(m/a,D/a),L=r*Math.PI/180;if(L){const e=Math.sin(L),t=Math.cos(L),r=[t,-e,e,t];P._matMult(r),F._matMult(r),B._matMult(r),z._matMult(r)}const O=e.stretch+e.fixed,N=i.stretch+i.fixed;return{tl:P,tr:F,bl:B,br:z,tex:{x:o.paddedRect.x+1+O,y:o.paddedRect.y+1+N,w:s.stretch+s.fixed-O,h:l.stretch+l.fixed-N},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:C,pixelOffsetBR:V,minFontScaleX:S/a/E,minFontScaleY:T/a/M,isSDF:n}};if(i&&(o.stretchX||o.stretchY)){const e=Ip(h,m,d),t=Ip(p,g,y);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const u=(null===(h=o.image)||void 0===h?void 0:h.content)&&(o.image.textFitWidth||o.image.textFitHeight)?Ku(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};u.y1=u.y1*a-l[0],u.y2=u.y2*a+l[2],u.x1=u.x1*a-l[3],u.x2=u.x2*a+l[1];const p=o.collisionPadding;if(p&&(u.x1-=p[0]*a,u.y1-=p[1]*a,u.x2+=p[2]*a,u.y2+=p[3]*a),c){const e=new t(u.x1,u.y1),r=new t(u.x2,u.y1),n=new t(u.x1,u.y2),i=new t(u.x2,u.y2),s=c*Math.PI/180;e._rotate(s),r._rotate(s),n._rotate(s),i._rotate(s),u.x1=Math.min(e.x,r.x,n.x,i.x),u.x2=Math.max(e.x,r.x,n.x,i.x),u.y1=Math.min(e.y,r.y,n.y,i.y),u.y2=Math.max(e.y,r.y,n.y,i.y)}e.emplaceBack(r.x,r.y,u.x1,u.y1,u.x2,u.y2,n,i,s)}this.boxEndIndex=e.length}}class Dp{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=i}}function Pp(e,r=1,n=!1){const i=ip.fromPoints(e[0]),s=Math.min(i.width(),i.height());let o=s/2;const a=new Dp([],Fp),{minX:l,minY:u,maxX:c,maxY:h}=i;if(0===s)return new t(l,u);for(let t=l;tp.d||!p.d)&&(p=t,n&&console.log("found best %d after %d probes",Math.round(1e4*t.d)/1e4,f)),t.max-p.d<=r||(o=t.h/2,a.push(new zp(t.p.x-o,t.p.y-o,o,e)),a.push(new zp(t.p.x+o,t.p.y-o,o,e)),a.push(new zp(t.p.x-o,t.p.y+o,o,e)),a.push(new zp(t.p.x+o,t.p.y+o,o,e)),f+=4)}return n&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Fp(e,t){return t.max-e.max}function zp(e,r,n,i){this.p=new t(e,r),this.h=n,this.d=function(e,t){let r=!1,n=1/0;for(let i=0;ie.y!=a.y>e.y&&e.x<(a.x-i.x)*(e.y-i.y)/(a.y-i.y)+i.x&&(r=!r),n=Math.min(n,ra(e,i,a))}}return(r?1:-1)*Math.sqrt(n)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}var Bp;!function(e){e[e.center=1]="center",e[e.left=2]="left",e[e.right=3]="right",e[e.top=4]="top",e[e.bottom=5]="bottom",e[e["top-left"]=6]="top-left",e[e["top-right"]=7]="top-right",e[e["bottom-left"]=8]="bottom-left",e[e["bottom-right"]=9]="bottom-right"}(Bp||(Bp={}));const Cp=Number.POSITIVE_INFINITY;function Vp(e,t){return t[1]!==Cp?function(e,t,r){let n=0,i=0;switch(t=Math.abs(t),r=Math.abs(r),e){case"top-right":case"top-left":case"top":i=r-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-r}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,i]}(e,t[0],t[1]):function(e,t){let r=0,n=0;t<0&&(t=0);const i=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=i-7;break;case"bottom-right":case"bottom-left":n=7-i;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t}return[r,n]}(e,t[0])}function Lp(e,t,r){var n;const i=e.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},r);if(s){const e=s.values,t=[];for(let r=0;re*du));n.startsWith("top")?i[1]-=7:n.startsWith("bottom")&&(i[1]+=7),t[r+1]=i}return new Ce(t)}const o=i.get("text-variable-anchor");if(o){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(t,{},r)*du,Cp]:i.get("text-offset").evaluate(t,{},r).map((e=>e*du));const s=[];for(const e of o)s.push(e,Vp(e,n));return new Ce(s)}return null}function Op(e){e.bucket.createArrays(),e.bucket.tilePixelRatio=p/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const t=e.bucket.layers[0],r=t.layout,n=t._unevaluatedLayout._values,i={layoutIconSize:n["icon-size"].possiblyEvaluate(new $i(e.bucket.zoom+1),e.canonical),layoutTextSize:n["text-size"].possiblyEvaluate(new $i(e.bucket.zoom+1),e.canonical),textMaxSize:n["text-size"].possiblyEvaluate(new $i(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.bucket.textSizeData;i.compositeTextSizes=[n["text-size"].possiblyEvaluate(new $i(t),e.canonical),n["text-size"].possiblyEvaluate(new $i(r),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.bucket.iconSizeData;i.compositeIconSizes=[n["icon-size"].possiblyEvaluate(new $i(t),e.canonical),n["icon-size"].possiblyEvaluate(new $i(r),e.canonical)]}const s=r.get("text-line-height")*du,o="viewport"!==r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),a=r.get("text-keep-upright"),l=r.get("text-size");for(const n of e.bucket.features){const u=r.get("text-font").evaluate(n,{},e.canonical).join(","),c=l.evaluate(n,{},e.canonical),h=i.layoutTextSize.evaluate(n,{},e.canonical),p=i.layoutIconSize.evaluate(n,{},e.canonical),f={horizontal:{},vertical:void 0},d=n.text;let y,m=[0,0];if(d){const i=d.toString(),l=r.get("text-letter-spacing").evaluate(n,{},e.canonical)*du,p=Pi(i)?l:0,y=r.get("text-anchor").evaluate(n,{},e.canonical),g=Lp(t,n,e.canonical);if(!g){const t=r.get("text-radial-offset").evaluate(n,{},e.canonical);m=t?Vp(y,[t*du,Cp]):r.get("text-offset").evaluate(n,{},e.canonical).map((e=>e*du))}let x=o?"center":r.get("text-justify").evaluate(n,{},e.canonical);const v="point"===r.get("symbol-placement")?r.get("text-max-width").evaluate(n,{},e.canonical)*du:1/0,b=()=>{e.bucket.allowVerticalPlacement&&Di(i)&&(f.vertical=Uu(d,e.glyphMap,e.glyphPositions,e.imagePositions,u,v,s,y,"left",p,m,qu.vertical,!0,h,c))};if(!o&&g){const t=new Set;if("auto"===x)for(let e=0;e{l.x<0||l.x>=p||l.y<0||l.y>=p||function(e,t,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,v,b,w,_,S,A,T){const I=e.addToLineVertexArray(t,r);let k,E,M,D,P=0,F=0,z=0,B=0,C=-1,V=-1;const L={};let O=wo("");if(e.allowVerticalPlacement&&n.vertical){const e=a.layout.get("text-rotate").evaluate(w,{},A)+90;M=new Mp(l,t,u,c,h,n.vertical,p,f,d,e),o&&(D=new Mp(l,t,u,c,h,o,m,g,d,e))}if(i){const r=a.layout.get("icon-rotate").evaluate(w,{}),n="none"!==a.layout.get("icon-text-fit"),s=Ap(i,r,S,n),p=o?Ap(o,r,S,n):void 0;E=new Mp(l,t,u,c,h,i,m,g,!1,r),P=4*s.length;const f=e.iconSizeData;let d=null;"source"===f.kind?(d=[ec*a.layout.get("icon-size").evaluate(w,{})],d[0]>tc&&x(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(d=[ec*_.compositeIconSizes[0].evaluate(w,{},A),ec*_.compositeIconSizes[1].evaluate(w,{},A)],(d[0]>tc||d[1]>tc)&&x(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,d,b,v,w,qu.none,t,I.lineStartIndex,I.lineLength,-1,A),C=e.icon.placedSymbolArray.length-1,p&&(F=4*p.length,e.addSymbols(e.icon,p,d,b,v,w,qu.vertical,t,I.lineStartIndex,I.lineLength,-1,A),V=e.icon.placedSymbolArray.length-1)}const N=Object.keys(n.horizontal);for(const r of N){const i=n.horizontal[r];if(!k){O=wo(i.text);const e=a.layout.get("text-rotate").evaluate(w,{},A);k=new Mp(l,t,u,c,h,i,p,f,d,e)}const o=1===i.positionedLines.length;if(z+=$p(e,t,i,s,a,d,w,y,I,n.vertical?qu.horizontal:qu.horizontalOnly,o?N:[r],L,C,_,A),o)break}n.vertical&&(B+=$p(e,t,n.vertical,s,a,d,w,y,I,qu.vertical,["vertical"],L,V,_,A));const R=k?k.boxStartIndex:e.collisionBoxArray.length,$=k?k.boxEndIndex:e.collisionBoxArray.length,q=M?M.boxStartIndex:e.collisionBoxArray.length,U=M?M.boxEndIndex:e.collisionBoxArray.length,G=E?E.boxStartIndex:e.collisionBoxArray.length,j=E?E.boxEndIndex:e.collisionBoxArray.length,X=D?D.boxStartIndex:e.collisionBoxArray.length,Y=D?D.boxEndIndex:e.collisionBoxArray.length;let Z=-1;const H=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;Z=H(k,Z),Z=H(M,Z),Z=H(E,Z),Z=H(D,Z);const W=Z>-1?1:0;W&&(Z*=T/du),e.glyphOffsetArray.length>=cc.MAX_GLYPHS&&x("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey);const J=Lp(a,w,A),[K,Q]=function(e,t){const r=e.length,n=null==t?void 0:t.values;if((null==n?void 0:n.length)>0)for(let t=0;t=0?L.right:-1,L.center>=0?L.center:-1,L.left>=0?L.left:-1,L.vertical||-1,C,V,O,R,$,q,U,G,j,X,Y,u,z,B,P,F,W,0,p,Z,K,Q)}(e,l,t,n,i,s,F,e.layers[0],e.collisionBoxArray,r.index,r.sourceLayerIndex,e.index,b,[A,A,A,A],k,u,_,T,E,m,r,o,c,h,a)};if("line"===M)for(const s of function(e,r,n,i,s){const o=[];for(let r=0;r=i&&l.x>=i||(r.x>=i?r=new t(i,r.y+(i-r.x)/(l.x-r.x)*(l.y-r.y))._round():l.x>=i&&(l=new t(i,r.y+(i-r.x)/(l.x-r.x)*(l.y-r.y))._round()),r.y>=s&&l.y>=s||(r.y>=s?r=new t(r.x+(s-r.y)/(l.y-r.y)*(l.x-r.x),s)._round():l.y>=s&&(l=new t(r.x+(s-r.y)/(l.y-r.y)*(l.x-r.x),s)._round()),a&&r.equals(a[a.length-1])||(a=[r],o.push(a)),a.push(l)))))}}return o}(r.geometry,0,0,p,p)){const t=vl(s,z),r=mp(t,S,I,n.vertical||g,i,24,w,e.overscaling,p);for(const n of r)g&&Up(e,g.text,D,n)||B(t,n)}else if("line-center"===M){for(const e of r.geometry)if(e.length>1){const t=vl(e,z),r=yp(t,I,n.vertical||g,i,24,w);r&&B(t,r)}}else if("Polygon"===r.type)for(const e of Qt(r.geometry,0)){const t=Pp(e,16);B(vl(e[0],z,!0),new cp(t.x,t.y,0))}else if("LineString"===r.type)for(const e of r.geometry){const t=vl(e,z);B(t,new cp(t[0].x,t[0].y,0))}else if("Point"===r.type)for(const e of r.geometry)for(const t of e)B([t],new cp(t.x,t.y,0))}function $p(e,r,n,i,s,o,a,l,u,c,h,p,f,d,y){const m=function(e,r,n,i,s,o,a,l){const u=i.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=[];for(const e of r.positionedLines)for(const i of e.positionedGlyphs){if(!i.rect)continue;const o=i.rect||{};let h=4,p=!0,f=1,d=0;const y=(s||l)&&i.vertical,m=i.metrics.advance*i.scale/2;if(l&&r.verticalizable&&(d=e.lineOffset/2-(i.imageName?-(du-i.metrics.width*i.scale)/2:(i.scale-1)*du)),i.imageName){const e=a[i.imageName];p=e.sdf,f=e.pixelRatio,h=1/f}const g=s?[i.x+m,i.y]:[0,0];let x=s?[0,0]:[i.x+m+n[0],i.y+n[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=i.metrics.isDoubleResolution?2:1,w=(i.metrics.left-h)*i.scale-m+x[0],_=(-i.metrics.top-h)*i.scale+x[1],S=w+o.w/b*i.scale/f,A=_+o.h/b*i.scale/f,T=new t(w,_),I=new t(S,_),k=new t(w,A),E=new t(S,A);if(y){const e=new t(-m,m- -17),r=-Math.PI/2,n=12-m,s=new t(22-n,-(i.imageName?n:0)),o=new t(...v);T._rotateAround(r,e)._add(s)._add(o),I._rotateAround(r,e)._add(s)._add(o),k._rotateAround(r,e)._add(s)._add(o),E._rotateAround(r,e)._add(s)._add(o)}if(u){const e=Math.sin(u),t=Math.cos(u),r=[t,-e,e,t];T._matMult(r),I._matMult(r),k._matMult(r),E._matMult(r)}const M=new t(0,0),D=new t(0,0);c.push({tl:T,tr:I,bl:k,br:E,tex:o,writingMode:r.writingMode,glyphOffset:g,sectionIndex:i.sectionIndex,isSDF:p,pixelOffsetTL:M,pixelOffsetBR:D,minFontScaleX:0,minFontScaleY:0})}return c}(0,n,l,s,o,a,i,e.allowVerticalPlacement),g=e.textSizeData;let v=null;"source"===g.kind?(v=[ec*s.layout.get("text-size").evaluate(a,{})],v[0]>tc&&x(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===g.kind&&(v=[ec*d.compositeTextSizes[0].evaluate(a,{},y),ec*d.compositeTextSizes[1].evaluate(a,{},y)],(v[0]>tc||v[1]>tc)&&x(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,m,v,l,o,a,c,r,u.lineStartIndex,u.lineLength,f,y);for(const t of h)p[t]=e.text.placedSymbolArray.length-1;return 4*m.length}function qp(e){for(const t in e)return e[t];return null}function Up(e,t,r,n){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Yp(function(e,t){const r=((e-t)%360+360)%360+t;return r===t?180:r}(this.lng,-180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,n=e.lat*t,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Xp*Math.acos(Math.min(i,1))}static convert(e){if(e instanceof Yp)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Yp(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Yp(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Zp=2*Math.PI*Xp;function Hp(e){return Zp*Math.cos(e*Math.PI/180)}function Wp(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}class Jp{constructor(e,t,r=0){this.x=+e,this.y=+t,this.z=+r}static fromLngLat(e,t=0){const r=Yp.convert(e);return new Jp((180+r.lng)/360,(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r.lat*Math.PI/360)))/360,function(e,t){return e/Hp(t)}(t,r.lat))}toLngLat(){return new Yp(360*this.x-180,Wp(this.y))}toAltitude(){return function(e,t){return e*Hp(Wp(t))}(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Zp*(e=Wp(this.y),1/Math.cos(e*Math.PI/180));var e}}class Kp{constructor(e,t,r){if(!function(e,t,r){return!(e<0||e>25||r<0||r>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,r))throw new Error(`x=${t}, y=${r}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=r,this.key=tf(0,e,e,t,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,r){const n=function(e,t,r){var n=jp(256*e,256*(t=Math.pow(2,r)-t-1),r),i=jp(256*(e+1),256*(t+1),r);return n[0]+","+n[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),i=function(e,t,r){let n,i="";for(let s=e;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,i).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const r=Math.pow(2,this.z);return new t((e.x*r-this.x)*p,(e.y*r-this.y)*p)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Qp{constructor(e,t){this.wrap=e,this.canonical=t,this.key=tf(e,t.z,t.z,t.x,t.y)}}class ef{constructor(e,t,r,n,i){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${r}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Kp(r,+n,+i),this.key=tf(t,e,r,n,i)}clone(){return new ef(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new ef(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ef(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?tf(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):tf(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new ef(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new ef(t,this.wrap,t,r,n),new ef(t,this.wrap,t,r+1,n),new ef(t,this.wrap,t,r,n+1),new ef(t,this.wrap,t,r+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id))))}}const c=y(l.glyphDependencies,(e=>Object.keys(e).map(Number)));this.inFlightDependencies.forEach((e=>null==e?void 0:e.abort())),this.inFlightDependencies=[];let h=Promise.resolve({});if(Object.keys(c).length){const e=new AbortController;this.inFlightDependencies.push(e),h=i.sendAsync({type:"GG",data:{stacks:c,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const p=Object.keys(l.iconDependencies);let f=Promise.resolve({});if(p.length){const e=new AbortController;this.inFlightDependencies.push(e),f=i.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},e)}const d=Object.keys(l.patternDependencies);let m=Promise.resolve({});if(d.length){const e=new AbortController;this.inFlightDependencies.push(e),m=i.sendAsync({type:"GI",data:{icons:d,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const g=l.dashDependencies;let v=Promise.resolve({});if(Object.keys(g).length){const e=new AbortController;this.inFlightDependencies.push(e),v=i.sendAsync({type:"GDA",data:{dashes:g}},e)}const[b,w,_,S]=yield Promise.all([h,f,m,v]),A=new Gp(b),T=new $u(w,_);for(const e in a){const t=a[e];t instanceof cc?(nf(t.layers,this.zoom,n),Op({bucket:t,glyphMap:b,glyphPositions:A.positions,imageMap:w,imagePositions:T.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:l.subdivisionGranularity})):t.hasDependencies&&(t instanceof Sl||t instanceof Rl||t instanceof tu)&&(nf(t.layers,this.zoom,n),t.addFeatures(l,this.tileID.canonical,T.patternPositions,S))}return this.status="done",{buckets:Object.values(a).filter((e=>!e.isEmpty())),featureIndex:o,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:A.image,imageAtlas:T,dashPositions:S,glyphMap:this.returnDependencies?b:null,iconMap:this.returnDependencies?w:null,glyphPositions:this.returnDependencies?A.positions:null}}))}}function nf(e,t,r){const n=new $i(t);for(const t of e)t.recalculate(n,r)}class sf{constructor(e){this.maxEntries=e,this.map=new Map}get(e){const t=this.map.get(e);return void 0!==t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}}var of,af,lf;!function(e){e.create="create",e.load="load",e.fullLoad="fullLoad"}(of||(of={}));class uf{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}}class cf extends Pl{constructor(e,t){super(new ku,0,t,[],[]),this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},"id"in e&&("string"==typeof e.id?this.id=parseInt(e.id,10):"number"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],r=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of r){const r=[];for(const e of n)r.push(new t(e[0],e[1]));e.push(r)}return e}}class hf extends Bl{constructor(e,t){super(new ku),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new cf(this.features[e],this.extent)}}function pf(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const r={keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n>31}function gf(e,t){const r=e.loadGeometry(),n=e.type;let i=0,s=0;for(const o of r){let r=1;1===n&&(r=o.length),t.writeVarint(yf(1,r));const a=3===n?o.length-1:o.length;for(let e=0;ee.map((e=>new t(e.x,e.y)))))}}class bf extends Bl{constructor(e,t,r){super(new ku),this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=r}feature(e){return this._myFeatures[e]}}class wf{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function _f(e){let t=function(e){const t=new ku;return function(e,t){for(const r in e.layers)t.writeMessage(3,pf,e.layers[r])}(e,t),t.finish()}(e);return 0===t.byteOffset&&t.byteLength===t.buffer.byteLength||(t=new Uint8Array(t)),{vectorTile:e,rawData:t.buffer}}function Sf(e,t,r){const{extent:n}=e,i=Math.pow(2,r.z-t.z),s=(r.x-t.x*i)*n,o=(r.y-t.y*i)*n,a=[];for(let t=0;tai(d(e,{type:"arrayBuffer"}),t))(t.request,r);try{return{vectorTile:"mlt"!==t.encoding?new Vl(new ku(e.data)):new np(e.data),rawData:e.data,cacheControl:e.cacheControl,expires:e.expires}}catch(r){const n=new Uint8Array(e.data);let i=`Unable to parse the tile at ${t.request.url}, `;throw i+=31===n[0]&&139===n[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${r.message}`,new Error(i)}}))}loadTile(t){return e(this,void 0,void 0,(function*(){const{uid:e,overzoomParameters:r}=t;r&&(t.request=r.overzoomRequest);const n=!!(t&&t.request&&t.request.collectResourceTiming)&&new uf(t.request),i=new rf(t);this.loading[e]=i;const s=new AbortController;i.abort=s;try{const o=yield this.loadVectorTile(t,s);if(delete this.loading[e],!o)return null;if(r){const e=this._getOverzoomTile(t,o.vectorTile);o.rawData=e.rawData,o.vectorTile=e.vectorTile}const a=o.rawData,l={};o.expires&&(l.expires=o.expires),o.cacheControl&&(l.cacheControl=o.cacheControl);const u={};if(n){const e=n.finish();e&&(u.resourceTiming=JSON.parse(JSON.stringify(e)))}i.vectorTile=o.vectorTile;const c=i.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[e]=i,this.fetching[e]={rawTileData:a,cacheControl:l,resourceTiming:u};try{const e=yield c;return d({rawTileData:a.slice(0),encoding:t.encoding},e,l,u)}finally{delete this.fetching[e]}}catch(t){throw delete this.loading[e],i.status="done",this.loaded[e]=i,t}}))}_getOverzoomTile(e,t){const{tileID:r,source:n,overzoomParameters:i}=e,{maxZoomTileID:s}=i,o=`${s.key}_${r.key}`,a=this.overzoomedTileResultCache.get(o);if(a)return a;const l=new wf,u=this.layerIndex.familiesBySource[n];for(const e in u){const n=t.layers[e];if(!n)continue;const i=Sf(n,s,r.canonical);i.length>0&&l.addLayer(i)}const c=_f(l);return this.overzoomedTileResultCache.set(o,c),c}reloadTile(t){return e(this,void 0,void 0,(function*(){const e=t.uid;if(!this.loaded||!this.loaded[e])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[e];if(r.showCollisionBoxes=t.showCollisionBoxes,"parsing"===r.status){const n=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let i;if(this.fetching[e]){const{rawTileData:r,cacheControl:s,resourceTiming:o}=this.fetching[e];delete this.fetching[e],i=d({rawTileData:r.slice(0),encoding:t.encoding},n,s,o)}else i=n;return i}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)}))}abortTile(t){return e(this,void 0,void 0,(function*(){const e=this.loading,r=t.uid;e&&e[r]&&e[r].abort&&(e[r].abort.abort(),delete e[r])}))}removeTile(t){return e(this,void 0,void 0,(function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]}))}}class Tf{constructor(){this.loaded={}}loadTile(t){return e(this,void 0,void 0,(function*(){const{uid:r,encoding:n,rawImageData:i,redFactor:s,greenFactor:o,blueFactor:u,baseShift:c}=t,h=i.width+2,p=i.height+2,f=w(i)?new Ia({width:h,height:p},yield function(t,r,n,i,s){return e(this,void 0,void 0,(function*(){if(function(){if(null==l&&(l=!1,null==a&&(a="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),a)){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let r=0;r=Math.abs(a)?r-l+a:a-l+r,r=l}r+n>=0!=!!t&&e.reverse()}return lf=1,af=function t(r,n){var i,s=r&&r.type;if("FeatureCollection"===s)for(i=0;i>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=Ef[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new Mf(o,s,i,e)}constructor(e,t=64,r=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const i=Ef.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Df(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:o}=this,a=[0,i.length-1,0],l=[];for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=o){for(let o=h;o<=c;o++){const a=s[2*o],u=s[2*o+1];a>=e&&a<=r&&u>=t&&u<=n&&l.push(i[o])}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=e&&f<=r&&d>=t&&d<=n&&l.push(i[p]),(0===u?e<=f:t<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?r>=f:n>=d)&&(a.push(p+1),a.push(c),a.push(1-u))}return l}within(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,o=[0,n.length-1,0],a=[],l=r*r;for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)Bf(i[2*r],i[2*r+1],e,t)<=l&&a.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Bf(f,d,e,t)<=l&&a.push(n[p]),(0===u?e-r<=f:t-r<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?e+r>=f:t+r>=d)&&(o.push(p+1),o.push(c),o.push(1-u))}return a}}function Df(e,t,r,n,i,s){if(i-n<=r)return;const o=n+i>>1;Pf(e,t,o,n,i,s),Df(e,t,r,n,o-1,1-s),Df(e,t,r,o+1,i,1-s)}function Pf(e,t,r,n,i,s){for(;i>n;){if(i-n>600){const o=i-n+1,a=r-n+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(a-o/2<0?-1:1);Pf(e,t,r,Math.max(n,Math.floor(r-a*u/o+c)),Math.min(i,Math.floor(r+(o-a)*u/o+c)),s)}const o=t[2*r+s];let a=n,l=i;for(Ff(e,t,n,r),t[2*i+s]>o&&Ff(e,t,n,i);ao;)l--}t[2*n+s]===o?Ff(e,t,n,l):(l++,Ff(e,t,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1)}}function Ff(e,t,r,n){zf(e,r,n),zf(t,2*r,2*n),zf(t,2*r+1,2*n+1)}function zf(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function Bf(e,t,r,n){const i=e-r,s=t-n;return i*i+s*s}const Cf={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Vf=Math.fround||(Lf=new Float32Array(1),e=>(Lf[0]=+e,Lf[0]));var Lf;class Of{constructor(e){this.options=Object.assign(Object.create(Cf),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:r,maxZoom:n}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const s=[];for(let t=0;t=r;e--){const r=+Date.now();o=this.trees[e]=this._createTree(this._cluster(o,e)),t&&console.log("z%d: %d clusters in %dms",e,o.numItems,+Date.now()-r)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,i=180;else if(r>i){const e=this.getClusters([r,n,180,s],t),o=this.getClusters([-180,n,i,s],t);return e.concat(o)}const o=this.trees[this._limitZoom(t)],a=o.range($f(r),qf(s),$f(i),qf(n)),l=o.data,u=[];for(const e of a){const t=this.stride*e;u.push(l[t+5]>1?Nf(l,t,this.clusterProps):this.points[l[t+3]])}return u}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),n="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(n);const s=i.data;if(t*this.stride>=s.length)throw new Error(n);const o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=i.within(s[t*this.stride],s[t*this.stride+1],o),l=[];for(const t of a){const r=t*this.stride;s[r+4]===e&&l.push(s[r+5]>1?Nf(s,r,this.clusterProps):this.points[s[r+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,r){const n=[];return this._appendLeaves(n,e,t=t||10,r=r||0,0),n}getTile(e,t,r){const n=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:s,radius:o}=this.options,a=o/s,l=(r-a)/i,u=(r+1+a)/i,c={features:[]};return this._addTileFeatures(n.range((t-a)/i,l,(t+1+a)/i,u),n.data,t,r,i,c),0===t&&this._addTileFeatures(n.range(1-a/i,l,1,u),n.data,i,r,i,c),t===i-1&&this._addTileFeatures(n.range(0,l,a/i,u),n.data,-1,r,i,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id}return t}_appendLeaves(e,t,r,n,i){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?i+s.point_count<=n?i+=s.point_count:i=this._appendLeaves(e,s.cluster_id,r,n,i):i1;let l,u,c;if(a)l=Rf(t,e,this.clusterProps),u=t[e],c=t[e+1];else{const r=this.points[t[e+3]];l=r.properties;const[n,i]=r.geometry.coordinates;u=$f(n),c=qf(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-r)),Math.round(this.options.extent*(c*i-n))]],tags:l};let p;p=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==p&&(h.id=p),s.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:r,extent:n,reduce:i,minPoints:s}=this.options,o=r/(n*Math.pow(2,t)),a=e.data,l=[],u=this.stride;for(let r=0;rt&&(f+=a[r+5])}if(f>p&&f>=s){let e,s=n*p,o=c*p,d=-1;const y=(r/u<<5)+(t+1)+this.points.length;for(const n of h){const l=n*u;if(a[l+2]<=t)continue;a[l+2]=t;const c=a[l+5];s+=a[l]*c,o+=a[l+1]*c,a[l+4]=y,i&&(e||(e=this._map(a,r,!0),d=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(a,l)))}a[r+4]=y,l.push(s/f,o/f,1/0,y,-1,f),i&&l.push(d)}else{for(let e=0;e1)for(const e of h){const r=e*u;if(!(a[r+2]<=t)){a[r+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,r){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return r?Object.assign({},n):n}const n=this.points[e[t+3]].properties,i=this.options.map(n);return r&&i===n?Object.assign({},i):i}}function Nf(e,t,r){return{type:"Feature",id:e[t+3],properties:Rf(e,t,r),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),Uf(e[t+1])]}};var n}function Rf(e,t,r){const n=e[t+5],i=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,s=e[t+6],o=-1===s?{}:Object.assign({},r[s]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:i})}function $f(e){return e/360+.5}function qf(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function Uf(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Gf(e,t,r,n){let i=n;const s=t+(r-t>>1);let o,a=r-t;const l=e[t],u=e[t+1],c=e[r],h=e[r+1];for(let n=t+3;ni)o=n,i=t;else if(t===i){const e=Math.abs(n-s);en&&(o-t>3&&Gf(e,t,o,n),e[o+2]=i,r-o>3&&Gf(e,o,r,n))}function jf(e,t,r,n,i,s){let o=i-r,a=s-n;if(0!==o||0!==a){const l=((e-r)*o+(t-n)*a)/(o*o+a*a);l>1?(r=i,n=s):l>0&&(r+=o*l,n+=a*l)}return o=e-r,a=t-n,o*o+a*a}function Xf(e,t,r,n){const i={id:null==e?null:e,type:t,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)Yf(i,r);else if("Polygon"===t)Yf(i,r[0]);else if("MultiLineString"===t)for(const e of r)Yf(i,e);else if("MultiPolygon"===t)for(const e of r)Yf(i,e[0]);return i}function Yf(e,t){for(let r=0;r0&&(o+=n?(i*l-a*s)/2:Math.sqrt(Math.pow(a-i,2)+Math.pow(l-s,2))),i=a,s=l}const a=t.length-3;t[2]=1,Gf(t,0,a,r),t[a+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function Jf(e,t,r,n){for(let i=0;i1?1:r}function ed(e,t,r,n,i,s,o,a){if(n/=t,s>=(r/=t)&&o=n)return null;const l=[];for(const t of e){const e=t.geometry;let s=t.type;const o=0===i?t.minX:t.minY,u=0===i?t.maxX:t.maxY;if(o>=r&&u=n)continue;let c=[];if("Point"===s||"MultiPoint"===s)td(e,c,r,n,i);else if("LineString"===s)rd(e,c,r,n,i,!1,a.lineMetrics);else if("MultiLineString"===s)id(e,c,r,n,i,!1);else if("Polygon"===s)id(e,c,r,n,i,!0);else if("MultiPolygon"===s)for(const t of e){const e=[];id(t,e,r,n,i,!0),e.length&&c.push(e)}if(c.length){if(a.lineMetrics&&"LineString"===s){for(const e of c)l.push(Xf(t.id,s,e,t.tags));continue}"LineString"!==s&&"MultiLineString"!==s||(1===c.length?(s="LineString",c=c[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===c.length?"Point":"MultiPoint"),l.push(Xf(t.id,s,c,t.tags))}}return l.length?l:null}function td(e,t,r,n,i){for(let s=0;s=r&&o<=n&&sd(t,e[s],e[s+1],e[s+2])}}function rd(e,t,r,n,i,s,o){let a=nd(e);const l=0===i?od:ad;let u,c,h=e.start;for(let p=0;pr&&(c=l(a,f,d,m,g,r),o&&(a.start=h+u*c)):x>n?v=r&&(c=l(a,f,d,m,g,r),b=!0),v>n&&x<=n&&(c=l(a,f,d,m,g,n),b=!0),!s&&b&&(o&&(a.end=h+u*c),t.push(a),a=nd(e)),o&&(h+=u)}let p=e.length-3;const f=e[p],d=e[p+1],y=0===i?f:d;y>=r&&y<=n&&sd(a,f,d,e[p+2]),p=a.length-3,s&&p>=3&&(a[p]!==a[0]||a[p+1]!==a[1])&&sd(a,a[0],a[1],a[2]),a.length&&t.push(a)}function nd(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function id(e,t,r,n,i,s){for(const o of e)rd(o,t,r,n,i,s,!1)}function sd(e,t,r,n){e.push(t,r,n)}function od(e,t,r,n,i,s){const o=(s-t)/(n-t);return sd(e,s,r+(i-r)*o,1),o}function ad(e,t,r,n,i,s){const o=(s-r)/(i-r);return sd(e,t+(n-t)*o,s,1),o}function ld(e,t){const r=[];for(let n=0;n0&&t.size<(i?o:n))return void(r.numPoints+=t.length/3);const a=[];for(let e=0;eo)&&(r.numSimplified++,a.push(t[e],t[e+1])),r.numPoints++;i&&function(e,t){let r=0;for(let t=0,n=e.length,i=n-2;t0===t)for(let t=0,r=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let n=function(e,t){const r=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),p=this.tiles[h]=pd(e,t,r,n,l),this.tileCoords.push({z:t,x:r,y:n}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,n,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(p.source=e,null==i){if(t===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===i)continue;if(null!=i){const e=i-t;if(r!==s>>e||n!==o>>e)continue}}if(p.source=null,0===e.length)continue;u>1&&console.time("clipping");const f=.5*l.buffer/l.extent,d=.5-f,y=.5+f,m=1+f;let g=null,x=null,v=null,b=null,w=ed(e,c,r-f,r+y,0,p.minX,p.maxX,l),_=ed(e,c,r+d,r+m,0,p.minX,p.maxX,l);e=null,w&&(g=ed(w,c,n-f,n+y,1,p.minY,p.maxY,l),x=ed(w,c,n+d,n+m,1,p.minY,p.maxY,l),w=null),_&&(v=ed(_,c,n-f,n+y,1,p.minY,p.maxY,l),b=ed(_,c,n+d,n+m,1,p.minY,p.maxY,l),_=null),u>1&&console.timeEnd("clipping"),a.push(g||[],t+1,2*r,2*n),a.push(x||[],t+1,2*r,2*n+1),a.push(v||[],t+1,2*r+1,2*n),a.push(b||[],t+1,2*r+1,2*n+1)}}getTile(e,t,r){e=+e,t=+t,r=+r;const n=this.options,{extent:i,debug:s}=n;if(e<0||e>24)return null;const o=1<1&&console.log("drilling down to z%d-%d-%d",e,t,r);let l,u=e,c=t,h=r;for(;!l&&u>0;)u--,c>>=1,h>>=1,l=this.tiles[gd(u,c,h)];return l&&l.source?(s>1&&(console.log("found parent tile z%d-%d-%d",u,c,h),console.time("drilling down")),this.splitTile(l.source,u,c,h,e,t,r),s>1&&console.timeEnd("drilling down"),this.tiles[a]?cd(this.tiles[a],i):null):null}}function gd(e,t,r){return 32*((1<ai(d(e,{type:"json"}),t))(t,n);return this._dataUpdateable=vd(e.data,r)?bd(e.data,r):void 0,e.data}))}_loadGeoJSONFromObject(e,t){return this._dataUpdateable=vd(e,t)?bd(e,t):void 0,e}_loadGeoJSONFromDiff(e,t,r){if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${r}`);!function(e,t,r){var n,i;if(t.removeAll)e.clear();else if(t.remove)for(const r of t.remove)e.delete(r);if(t.add)for(const n of t.add){const t=xd(n,r);null!=t&&e.set(t,n)}if(t.update)for(const r of t.update){let t=e.get(r.id);if(!t)continue;const s=!!r.newGeometry,o=r.removeAllProperties||(null===(n=r.removeProperties)||void 0===n?void 0:n.length)>0||(null===(i=r.addOrUpdateProperties)||void 0===i?void 0:i.length)>0;if((s||o)&&(t=Object.assign({},t),e.set(r.id,t),s&&(t.geometry=r.newGeometry),o)){if(t.properties=r.removeAllProperties?{}:Object.assign({},t.properties||{}),r.removeProperties)for(const e of r.removeProperties)delete t.properties[e];if(r.addOrUpdateProperties)for(const{key:e,value:n}of r.addOrUpdateProperties)t.properties[e]=n}}}(this._dataUpdateable,e,t);const n=Array.from(this._dataUpdateable.values());return this._toFeatureCollection(n)}_filterGeoJSON(e,t){const r=tn(t,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const n=e.features.filter((e=>r.value.evaluate({zoom:0},e)));return this._toFeatureCollection(n)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(t){return e(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function _d(e,t){return t.cluster?new Of(function({superclusterOptions:e,clusterProperties:t}){if(!t||!e)return e;const r={},n={},i={accumulated:null,zoom:0},s={properties:null},o=Object.keys(t);for(const e of o){const[i,s]=t[e],o=tn(s),a=tn("string"==typeof i?[i,["accumulated"],["get",e]]:i);r[e]=o.value,n[e]=a.value}return e.map=e=>{s.properties=e;const t={};for(const e of o)t[e]=r[e].evaluate(i,s);return t},e.reduce=(e,t)=>{s.properties=t;for(const t of o)i.accumulated=e[t],e[t]=n[t].evaluate(i,s)},e}(t)).load(e.features):function(e,t){return new md(e,t)}(e,t.geojsonVtOptions)}class Sd{constructor(t){this.self=t,this.actor=new gi(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=ri,this.self.removeProtocol=ni,this.self.registerRTLTextPlugin=e=>{Ri.setMethods(e)},this.actor.registerMessageHandler("LDT",((e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t))),this.actor.registerMessageHandler("RDT",((t,r)=>e(this,void 0,void 0,(function*(){this._getDEMWorkerSource(t,r.source).removeTile(r)})))),this.actor.registerMessageHandler("GCEZ",((t,r)=>e(this,void 0,void 0,(function*(){return this._getWorkerSource(t,r.type,r.source).getClusterExpansionZoom(r)})))),this.actor.registerMessageHandler("GCC",((t,r)=>e(this,void 0,void 0,(function*(){return this._getWorkerSource(t,r.type,r.source).getClusterChildren(r)})))),this.actor.registerMessageHandler("GCL",((t,r)=>e(this,void 0,void 0,(function*(){return this._getWorkerSource(t,r.type,r.source).getClusterLeaves(r)})))),this.actor.registerMessageHandler("LD",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t))),this.actor.registerMessageHandler("GD",((e,t)=>this._getWorkerSource(e,t.type,t.source).getData())),this.actor.registerMessageHandler("LT",((e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t))),this.actor.registerMessageHandler("RT",((e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t))),this.actor.registerMessageHandler("AT",((e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t))),this.actor.registerMessageHandler("RMT",((e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t))),this.actor.registerMessageHandler("RS",((t,r)=>e(this,void 0,void 0,(function*(){if(!this.workerSources[t]||!this.workerSources[t][r.type]||!this.workerSources[t][r.type][r.source])return;const e=this.workerSources[t][r.type][r.source];delete this.workerSources[t][r.type][r.source],void 0!==e.removeSource&&e.removeSource(r)})))),this.actor.registerMessageHandler("RM",(t=>e(this,void 0,void 0,(function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})))),this.actor.registerMessageHandler("SR",((t,r)=>e(this,void 0,void 0,(function*(){this.referrer=r})))),this.actor.registerMessageHandler("SRPS",((e,t)=>this._syncRTLPluginState(e,t))),this.actor.registerMessageHandler("IS",((t,r)=>e(this,void 0,void 0,(function*(){this.self.importScripts(r)})))),this.actor.registerMessageHandler("SI",((e,t)=>this._setImages(e,t))),this.actor.registerMessageHandler("UL",((t,r)=>e(this,void 0,void 0,(function*(){this._getLayerIndex(t).update(r.layers,r.removedIds,this._getGlobalState(t))})))),this.actor.registerMessageHandler("UGS",((t,r)=>e(this,void 0,void 0,(function*(){const e=this._getGlobalState(t);for(const t in r)e[t]=r[t]})))),this.actor.registerMessageHandler("SL",((t,r)=>e(this,void 0,void 0,(function*(){this._getLayerIndex(t).replace(r,this._getGlobalState(t))}))))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,r){return e(this,void 0,void 0,(function*(){this.availableImages[t]=r;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=r}}))}_syncRTLPluginState(t,r){return e(this,void 0,void 0,(function*(){return yield Ri.syncState(r,this.self.importScripts)}))}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new up),t}_getWorkerSource(e,t,r){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][r]){const n={sendAsync:(t,r)=>(t.targetMapId=e,this.actor.sendAsync(t,r))};switch(t){case"vector":this.workerSources[e][t][r]=new Af(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][r]=new wd(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][r]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][r]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new Tf),this.demWorkerSources[e][t]}}return b(self)&&(self.worker=new Sd(self)),Sd}(); //# sourceMappingURL=maplibre-gl-csp-worker.js.map