/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.7.0/LICENSE.txt */ var maplibregl=function(){"use strict";function t(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))}function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var r=n;function n(t,e){this.x=t,this.y=e}n.prototype={clone:function(){return new n(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(t){return t instanceof n?t:Array.isArray(t)?new n(t[0],t[1]):t};var i=e(r),s=o;function o(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n}let a,l;function u(t,e,r){return Math.min(r,Math.max(e,t))}function c(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}function h(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function p(t){return Array.isArray(t)?t.map(p):"object"==typeof t&&t?h(t,p):t}o.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?o=r:a=r,r=.5*(a-o)+o;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},new(e(s))(.25,.1,.25,1);const f={};function d(t){f[t]||("undefined"!=typeof console&&console.warn(t),f[t]=!0)}function y(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function m(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}function g(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}let x,v;class b{constructor(t,e,r){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(let t=0;t=u[l+0]&&n>=u[l+1])?(o[h]=!0,s.push(i[h])):o[h]=!1}}}}_forEachCell(t,e,r,n,i,s,o,a){const l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),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,t,e,r,n,u,s,o,a))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t":{},">=":{},"<":{},"<=":{},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:"enum",default:"mercator",values:{mercator:{},globe:{}}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","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"]},"property-type":"cross-faded"},"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:"number",default:335,minimum:0,maximum:359,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:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",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"}},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 _=["type","source","source-layer","minzoom","maxzoom","filter","layout"];class S{constructor(t,e,r,n){this.message=(t?`${t}: `:"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function k(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class A extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class I{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r}concat(t){return new I(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const M={kind:"null"},z={kind:"number"},P={kind:"string"},C={kind:"boolean"},B={kind:"color"},V={kind:"object"},T={kind:"value"},E={kind:"collator"},F={kind:"formatted"},D={kind:"padding"},$={kind:"resolvedImage"},L={kind:"variableAnchorOffsetCollection"};function O(t,e){return{kind:"array",itemType:t,N:e}}function R(t){if("array"===t.kind){const e=R(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const j=[M,z,P,C,B,F,V,O(T),D,$,L];function q(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!q(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of j)if(!q(t,e))return null}return`Expected ${R(t)} but found ${R(e)} instead.`}function U(t,e){return e.some((e=>e.kind===t.kind))}function N(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function Z(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const G=.96422,X=.82521,H=4/29,Y=6/29,J=3*Y*Y,K=Y*Y*Y,W=Math.PI/180,Q=180/Math.PI;function tt(t){return(t%=360)<0&&(t+=360),t}function et([t,e,r,n]){let i,s;const o=nt((.2225045*(t=rt(t))+.7168786*(e=rt(e))+.0606169*(r=rt(r)))/1);t===e&&e===r?i=s=o:(i=nt((.4360747*t+.3850649*e+.1430804*r)/G),s=nt((.0139322*t+.0971045*e+.7141733*r)/X));const a=116*o-16;return[a<0?0:a,500*(i-o),200*(o-s),n]}function rt(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function nt(t){return t>K?Math.pow(t,1/3):t/J+H}function it([t,e,r,n]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,o=isNaN(r)?i:i-r/200;return i=1*ot(i),s=G*ot(s),o=X*ot(o),[st(3.1338561*s-1.6168667*i-.4906146*o),st(-.9787684*s+1.9161415*i+.033454*o),st(.0719453*s-.2289914*i+1.4052427*o),n]}function st(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ot(t){return t>Y?t*t*t:J*(t-H)}function at(t){return parseInt(t.padEnd(2,t),16)/255}function lt(t,e){return ut(e?t/100:t,0,1)}function ut(t,e,r){return Math.min(Math.max(e,t),r)}function ct(t){return!t.some(Number.isNaN)}const ht={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]};class pt{constructor(t,e,r,n=1,i=!0){this.r=t,this.g=e,this.b=r,this.a=n,i||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]))}static parse(t){if(t instanceof pt)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=ht[t];if(e){const[t,r,n]=e;return[t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return[at(t.slice(r,r+=e)),at(t.slice(r,r+=e)),at(t.slice(r,r+=e)),at(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,i,s,o,a,l,u,c,h,p]=e,f=[i||" ",a||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,o,u].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[ut(+r/e,0,1),ut(+s/e,0,1),ut(+l/e,0,1),h?lt(+h,p):1];if(ct(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,i,s,o,a,l,u]=r,c=[n||" ",s||" ",a].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,ut(+i,0,100),ut(+o,0,100),l?lt(+l,u):1];if(ct(t))return function([t,e,r,n]){function i(n){const i=(n+t/30)%12,s=e*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=tt(t),e/=100,r/=100,[i(0),i(8),i(4),n]}(t)}}}(t);return e?new pt(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,i=n||1/0;return this.overwriteGetter("rgb",[t/i,e/i,r/i,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,i]=et(t),s=Math.sqrt(r*r+n*n);return[Math.round(1e4*s)?tt(Math.atan2(n,r)*Q):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",et(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return`rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}}pt.black=new pt(0,0,0,1),pt.white=new pt(1,1,1,1),pt.transparent=new pt(0,0,0,0),pt.red=new pt(1,0,0,1);class ft{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class dt{constructor(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i}}class yt{constructor(t){this.sections=t}static fromString(t){return new yt([new dt(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof yt?t:yt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class mt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof mt)return t;if("number"==typeof t)return new mt([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new mt(t)}}toString(){return JSON.stringify(this.values)}}const gt=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class xt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof xt)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function wt(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof pt||t instanceof ft||t instanceof yt||t instanceof mt||t instanceof xt||t instanceof vt)return!0;if(Array.isArray(t)){for(const e of t)if(!wt(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!wt(t[e]))return!1;return!0}return!1}function _t(t){if(null===t)return M;if("string"==typeof t)return P;if("boolean"==typeof t)return C;if("number"==typeof t)return z;if(t instanceof pt)return B;if(t instanceof ft)return E;if(t instanceof yt)return F;if(t instanceof mt)return D;if(t instanceof xt)return L;if(t instanceof vt)return $;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=_t(e);if(r){if(r===t)continue;r=T;break}r=t}return O(r||T,e)}return V}function St(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof pt||t instanceof yt||t instanceof mt||t instanceof xt||t instanceof vt?t.toString():JSON.stringify(t)}class kt{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!wt(t[1]))return e.error("invalid value");const r=t[1];let n=_t(r);const i=e.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new kt(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class At{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const It={string:P,number:z,boolean:C,object:V};class Mt{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in It)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=It[r],n++}else i=T;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++}r=O(i,s)}else{if(!It[i])throw new Error(`Types doesn't contain name = ${i}`);r=It[i]}const s=[];for(;nt.outputDefined()))}}const zt={"to-boolean":C,"to-color":B,"to-number":z,"to-string":P};class Pt{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0];if(!zt[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!==t.length)return e.error("Expected one argument.");const n=zt[r],i=[];for(let r=1;r4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:bt(e[0],e[1],e[2],e[3]),!r))return new pt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new At(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const r of this.args){e=r.evaluate(t);const n=mt.parse(e);if(n)return n}throw new At(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const r of this.args){e=r.evaluate(t);const n=xt.parse(e);if(n)return n}throw new At(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new At(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return yt.fromString(St(this.args[0].evaluate(t)));case"resolvedImage":return vt.fromString(St(this.args[0].evaluate(t)));default:return St(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ct=["Unknown","Point","LineString","Polygon"];class Bt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},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?Ct[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(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=pt.parse(t)),e}}class Vt{constructor(t,e,r=[],n,i=new I,s=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=i,this.errors=s,this.expectedType=n,this._isConstant=e}parse(t,e,r,n,i={}){return e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return"assert"===r?new Mt(e,[t]):"coerce"===r?new Pt(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[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(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,i=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind)if("padding"!==t.kind||"value"!==i.kind&&"number"!==i.kind&&"array"!==i.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==i.kind&&"array"!==i.kind){if(this.checkSubtype(t,i))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert")}if(!(n instanceof kt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Bt;try{n=new kt(n.type,n.evaluate(t))}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Vt(this.registry,this._isConstant,n,e||null,i,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new A(r,t))}checkSubtype(t,e){const r=q(t,e);return r&&this.error(r),r}}class Tt{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new At(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new At(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class Dt{constructor(t,e){this.type=C,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,T),n=e.parse(t[2],2,T);return r&&n?U(r.type,[C,P,z,M,T])?new Dt(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${R(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!N(e,["boolean","string","number","null"]))throw new At(`Expected first argument to be of type boolean, string, number or null, but found ${R(_t(e))} instead.`);if(!N(r,["string","array"]))throw new At(`Expected second argument to be of type array or string, but found ${R(_t(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class $t{constructor(t,e,r){this.type=z,this.needle=t,this.haystack=e,this.fromIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,T),n=e.parse(t[2],2,T);if(!r||!n)return null;if(!U(r.type,[C,P,z,M,T]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${R(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,z);return i?new $t(r,n,i):null}return new $t(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!N(e,["boolean","string","number","null"]))throw new At(`Expected first argument to be of type boolean, string, number or null, but found ${R(_t(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),N(r,["string"])){const t=r.indexOf(e,n);return-1===t?-1:[...r.slice(0,t)].length}if(N(r,["array"]))return r.indexOf(e,n);throw new At(`Expected second argument to be of type array or string, but found ${R(_t(r))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Lt{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.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 t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,_t(t)))return null}else r=_t(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=s.length}const c=e.parse(l,o,n);if(!c)return null;n=n||c.type,s.push(c)}const o=e.parse(t[1],1,T);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(r,o.type)?null:new Lt(r,n,o,i,s,a):null}evaluate(t){const e=this.input.evaluate(t);return(_t(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class Ot{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}}class Rt{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,T),n=e.parse(t[2],2,z);if(!r||!n)return null;if(!U(r.type,[O(T),P,T]))return e.error(`Expected first argument to be of type array or string, but found ${R(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,z);return i?new Rt(r.type,r,n,i):null}return new Rt(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),N(e,["string"]))return[...e].slice(r,n).join("");if(N(e,["array"]))return e.slice(r,n);throw new At(`Expected first argument to be of type array or string, but found ${R(_t(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function jt(t,e){const r=t.length-1;let n,i,s=0,o=r,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),n=t[a],i=t[a+1],n<=e){if(a===r||ee))throw new At("Input is not a number.");o=a-1}return 0}class qt{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,z);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const u=e.parse(o,l,i);if(!u)return null;i=i||u.type,n.push([s,u])}return new qt(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[jt(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Ut(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Nt=Zt;function Zt(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n}Zt.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?o=r:a=r,r=.5*(a-o)+o;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var Gt=Ut(Nt);function Xt(t,e,r){return t+r*(e-t)}function Ht(t,e,r){return t.map(((t,n)=>Xt(t,e[n],r)))}const Yt={number:Xt,color:function(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,i,s,o]=Ht(t.rgb,e.rgb,r);return new pt(n,i,s,o,!1)}case"hcl":{const[n,i,s,o]=t.hcl,[a,l,u,c]=e.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 t=a-n;a>n&&t>180?t-=360:a180&&(t+=360),h=n+r*t}const[f,d,y,m]=function([t,e,r,n]){return t=isNaN(t)?0:t*W,it([r,Math.cos(t)*e,Math.sin(t)*e,n])}([h,null!=p?p:Xt(i,l,r),Xt(s,u,r),Xt(o,c,r)]);return new pt(f,d,y,m,!1)}case"lab":{const[n,i,s,o]=it(Ht(t.lab,e.lab,r));return new pt(n,i,s,o,!1)}}},array:Ht,padding:function(t,e,r){return new mt(Ht(t.values,e.values,r))},variableAnchorOffsetCollection:function(t,e,r){const n=t.values,i=e.values;if(n.length!==i.length)throw new At(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const s=[];for(let t=0;t"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,z),!i)return null;const o=[];let a=null;"interpolate-hcl"===r||"interpolate-lab"===r?a=B:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,a);if(!u)return null;a=a||u.type,o.push([r,u])}return Z(a,z)||Z(a,B)||Z(a,D)||Z(a,L)||Z(a,O(z))?new Jt(a,r,n,i,o):e.error(`Type ${R(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=jt(e,n),o=Jt.interpolationFactor(this.interpolation,n,e[s],e[s+1]),a=r[s].evaluate(t),l=r[s+1].evaluate(t);switch(this.operator){case"interpolate":return Yt[this.type.kind](a,l,o);case"interpolate-hcl":return Yt.color(a,l,o,"hcl");case"interpolate-lab":return Yt.color(a,l,o,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Kt(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}class Wt{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t)}if(!r)throw new Error("No output type");const s=n&&i.some((t=>q(n,t.type)));return new Wt(s?T:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args)if(n++,r=i.evaluate(t),r&&r instanceof vt&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Qt(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function te(t,e,r,n){return 0===n.compare(e,r)}function ee(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=C,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let s=e.parse(t[1],1,T);if(!s)return null;if(!Qt(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${R(s.type)}'.`);let o=e.parse(t[2],2,T);if(!o)return null;if(!Qt(r,o.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${R(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${R(s.type)}' and '${R(o.type)}'.`);n&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Mt(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Mt(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,E),!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 e=_t(s),r=_t(o);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new At(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=_t(s),r=_t(o);if("string"!==t.kind||"string"!==r.kind)return e(i,s,o)}return this.collator?r(i,s,o,this.collator.evaluate(i)):e(i,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const re=ee("==",(function(t,e,r){return e===r}),te),ne=ee("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return!te(0,e,r,n)})),ie=ee("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),oe=ee("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),ae=ee(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class le{constructor(t,e,r){this.type=E,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,C);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,C);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,P),!s)?null:new le(n,i,s)}evaluate(t){return new ft(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class ue{constructor(t,e,r,n,i){this.type=P,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=i}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,z);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parse(n.locale,1,P),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,P),!s))return null;let o=null;if(n["min-fraction-digits"]&&(o=e.parse(n["min-fraction-digits"],1,z),!o))return null;let a=null;return n["max-fraction-digits"]&&(a=e.parse(n["max-fraction-digits"],1,z),!a)?null:new ue(r,i,s,o,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class ce{constructor(t){this.type=F,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,z),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,O(P)),!r))return null;let o=null;if(s["text-color"]&&(o=e.parse(s["text-color"],1,B),!o))return null;const a=n[n.length-1];a.scale=t,a.font=r,a.textColor=o}else{const s=e.parse(t[r],1,T);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null})}}return new ce(n)}evaluate(t){return new yt(this.sections.map((e=>{const r=e.content.evaluate(t);return _t(r)===$?new dt("",r,null,null,null):new dt(St(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}}class he{constructor(t){this.type=$,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,P);return r?new he(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=vt.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}}class pe{constructor(t){this.type=z,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${R(r.type)} instead.`):new pe(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new At(`Expected value to be of type string or array, but found ${R(_t(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const fe=8192;function de(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(r*i*fe),Math.round(n*i*fe)]}function ye(t,e){const r=Math.pow(2,e.z);return[(i=(t[0]/fe+e.x)/r,360*i-180),(n=(t[1]/fe+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i}function me(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function ge(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function xe(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],o=t[1]-r[1];return n*o-s*i==0&&n*s<=0&&i*o<=0}function ve(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Ae(t,e,r,n)||!Ae(r,n,t,e));var i,s}function be(t,e,r){for(const n of r)for(let r=0;r(i=t)[1]!=(o=a[e+1])[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(n=!n)}var i,s,o;return n}function _e(t,e){for(const r of e)if(we(t,r))return!0;return!1}function Se(t,e){for(const r of t)if(!we(r,e))return!1;for(let r=0;r0&&a<0||o<0&&a>0}function Ie(t,e,r){const n=[];for(let i=0;ir[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i}me(e,t)}function Pe(t,e,r,n){const i=Math.pow(2,n.z)*fe,s=[n.x*fe,n.y*fe],o=[];for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];ze(n,e,r,i),o.push(n)}return o}function Ce(t,e,r,n){const i=Math.pow(2,n.z)*fe,s=[n.x*fe,n.y*fe],o=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];me(e,r),t.push(r)}o.push(t)}if(e[2]-e[0]<=i/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const n of t)ze(n,e,r,i)}var a;return o}class Be{constructor(t,e){this.type=C,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(wt(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const r of e.features){const{type:e,coordinates:n}=r.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n)}if(t.length)return new Be(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Be(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Be(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Ie(e.coordinates,n,i),o=Pe(t.geometry(),r,n,i);if(!ge(r,n))return!1;for(const t of o)if(!we(t,s))return!1}if("MultiPolygon"===e.type){const s=Me(e.coordinates,n,i),o=Pe(t.geometry(),r,n,i);if(!ge(r,n))return!1;for(const t of o)if(!_e(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=Ie(e.coordinates,n,i),o=Ce(t.geometry(),r,n,i);if(!ge(r,n))return!1;for(const t of o)if(!Se(t,s))return!1}if("MultiPolygon"===e.type){const s=Me(e.coordinates,n,i),o=Ce(t.geometry(),r,n,i);if(!ge(r,n))return!1;for(const t of o)if(!ke(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Ve=class{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i}e[t]=n}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=i}};function Te(t,e,r,n,i){Ee(t,e,r,n||t.length-1,i||De)}function Ee(t,e,r,n,i){for(;n>r;){if(n-r>600){var s=n-r+1,o=e-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);Ee(t,e,Math.max(r,Math.floor(e-o*l/s+u)),Math.min(n,Math.floor(e+(s-o)*l/s+u)),i)}var c=t[e],h=r,p=n;for(Fe(t,r,e),i(t[n],c)>0&&Fe(t,r,n);h0;)p--}0===i(t[r],c)?Fe(t,r,p):Fe(t,++p,n),p<=e&&(r=p+1),e<=p&&(n=p-1)}}function Fe(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function De(t,e){return te?1:0}function $e(t,e){if(t.length<=1)return[t];const r=[];let n,i;for(const e of t){const t=Oe(e);0!==t&&(e.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&r.push(n),n=[e]):n.push(e))}if(n&&r.push(n),e>1)for(let t=0;t1?(l=t[a+1][0],u=t[a+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=this.wrap(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f180;)t-=360;return t}}function Ne(t,e){return e[0]-t[0]}function Ze(t){return t[1]-t[0]+1}function Ge(t,e){return t[1]>=t[0]&&t[1]t[1])return[null,null];const r=Ze(t);if(e){if(2===r)return[t,null];const e=Math.floor(r/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===r)return[t,null];const n=Math.floor(r/2)-1;return[[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function He(t,e){if(!Ge(e,t.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)me(r,t[n]);return r}function Ye(t){const e=[1/0,1/0,-1/0,-1/0];for(const r of t)for(const t of r)me(e,t);return e}function Je(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Ke(t,e,r){if(!Je(t)||!Je(e))return NaN;let n=0,i=0;return t[2]e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(ge(i,s)){if(ir(t,e))return 0}else if(ir(e,t))return 0;let o=1/0;for(const n of t)for(let t=0,i=n.length,s=i-1;t0;){const i=o.pop();if(i[0]>=s)continue;const l=i[1],u=e?50:100;if(Ze(l)<=u){if(!Ge(l,t.length))return NaN;if(e){const e=nr(t,l,r,n);if(isNaN(e)||0===e)return e;s=Math.min(s,e)}else for(let e=l[0];e<=l[1];++e){const i=rr(t[e],r,n);if(s=Math.min(s,i),0===s)return 0}}else{const r=Xe(l,e);or(o,s,n,t,a,r[0]),or(o,s,n,t,a,r[1])}}return s}function ur(t,e,r,n,i,s=1/0){let o=Math.min(s,i.distance(t[0],r[0]));if(0===o)return o;const a=new Ve([[0,[0,t.length-1],[0,r.length-1]]],Ne);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],u=s[2],c=e?50:100,h=n?50:100;if(Ze(l)<=c&&Ze(u)<=h){if(!Ge(l,t.length)&&Ge(u,r.length))return NaN;let s;if(e&&n)s=tr(t,l,r,u,i),o=Math.min(o,s);else if(e&&!n){const e=t.slice(l[0],l[1]+1);for(let t=u[0];t<=u[1];++t)if(s=We(r[t],e,i),o=Math.min(o,s),0===o)return o}else if(!e&&n){const e=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(s=We(t[r],e,i),o=Math.min(o,s),0===o)return o}else s=er(t,l,r,u,i),o=Math.min(o,s)}else{const s=Xe(l,e),c=Xe(u,n);ar(a,o,i,t,r,s[0],c[0]),ar(a,o,i,t,r,s[0],c[1]),ar(a,o,i,t,r,s[1],c[0]),ar(a,o,i,t,r,s[1],c[1])}}return o}function cr(t){return"MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class hr{constructor(t,e){this.type=z,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(wt(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new hr(e,e.features.map((t=>cr(t.geometry))).flat());if("Feature"===e.type)return new hr(e,cr(e.geometry));if("type"in e&&"coordinates"in e)return new hr(e,cr(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>ye([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Ue(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,ur(n,!1,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,ur(n,!1,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,lr(n,!1,t.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=t.geometry(),n=r.flat().map((e=>ye([e.x,e.y],t.canonical)));if(0===r.length)return NaN;const i=new Ue(n[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,ur(n,!0,[t.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,ur(n,!0,t.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,lr(n,!0,t.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const r=t.geometry();if(0===r.length||0===r[0].length)return NaN;const n=$e(r,0).map((e=>e.map((e=>e.map((e=>ye([e.x,e.y],t.canonical))))))),i=new Ue(n[0][0][0][1]);let s=1/0;for(const t of e)for(const e of n){switch(t.type){case"Point":s=Math.min(s,lr([t.coordinates],!1,e,i,s));break;case"LineString":s=Math.min(s,lr(t.coordinates,!0,e,i,s));break;case"Polygon":s=Math.min(s,sr(e,t.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const pr={"==":re,"!=":ne,">":se,"<":ie,">=":ae,"<=":oe,array:Mt,at:Ft,boolean:Mt,case:Ot,coalesce:Wt,collator:le,format:ce,image:he,in:Dt,"index-of":$t,interpolate:Jt,"interpolate-hcl":Jt,"interpolate-lab":Jt,length:pe,let:Tt,literal:kt,match:Lt,number:Mt,"number-format":ue,object:Mt,slice:Rt,step:qt,string:Mt,"to-boolean":Pt,"to-color":Pt,"to-number":Pt,"to-string":Pt,var:Et,within:Be,distance:hr};class fr{constructor(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const r=t[0],n=fr.definitions[r];if(!n)return e.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((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[n,s]of o){a=new Vt(e.registry,xr,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(R).join(", ")})`:`(${R(e.type)}...)`;var e})).join(" | "),n=[];for(let r=1;r{r=e?r&&xr(t):r&&t instanceof kt})),!!r&&vr(t)&&wr(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function vr(t){if(t instanceof fr){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Be)return!1;if(t instanceof hr)return!1;let e=!0;return t.eachChild((t=>{e&&!vr(t)&&(e=!1)})),e}function br(t){if(t instanceof fr&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!br(t)&&(e=!1)})),e}function wr(t,e){if(t instanceof fr&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild((t=>{r&&!wr(t,e)&&(r=!1)})),r}function _r(t){return{result:"success",value:t}}function Sr(t){return{result:"error",value:t}}function kr(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Ar(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Ir(t){return!!t.expression&&t.expression.interpolated}function Mr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function zr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Pr(t){return t}function Cr(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(Ir(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?pt.parse:mt.parse;(t=k({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(o=t.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${t.colorSpace}"`);var o;let a,l,u;if("exponential"===s)a=Er;else if("interval"===s)a=Tr;else if("categorical"===s){a=Vr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0]}else{if("identity"!==s)throw new Error(`Unknown function type "${s}"`);a=Fr}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Er({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:Jt.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>a(t,e,r,l,u)}}return{kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Br(t.default,e.default):a(t,e,i,l,u)}}}function Br(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Vr(t,e,r,n,i){return Br(typeof r===i?n[r]:void 0,t.default,e.default)}function Tr(t,e,r){if("number"!==Mr(r))return Br(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=jt(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Er(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Mr(r))return Br(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=jt(t.stops.map((t=>t[0])),r),o=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1],u=Yt[e.type]||Pr;return"function"==typeof a.evaluate?{evaluate(...e){const r=a.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return u(r,n,o,t.colorSpace)}}:u(a,l,o,t.colorSpace)}function Fr(t,e,r){switch(e.type){case"color":r=pt.parse(r);break;case"formatted":r=yt.fromString(r.toString());break;case"resolvedImage":r=vt.fromString(r.toString());break;case"padding":r=mt.parse(r);break;default:Mr(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0)}return Br(r,t.default,e.default)}fr.register(pr,{error:[{kind:"error"},[P],(t,[e])=>{throw new At(e.evaluate(t))}],typeof:[P,[T],(t,[e])=>R(_t(e.evaluate(t)))],"to-rgba":[O(z,4),[B],(t,[e])=>{const[r,n,i,s]=e.evaluate(t).rgb;return[255*r,255*n,255*i,s]}],rgb:[B,[z,z,z],dr],rgba:[B,[z,z,z,z],dr],has:{type:C,overloads:[[[P],(t,[e])=>yr(e.evaluate(t),t.properties())],[[P,V],(t,[e,r])=>yr(e.evaluate(t),r.evaluate(t))]]},get:{type:T,overloads:[[[P],(t,[e])=>mr(e.evaluate(t),t.properties())],[[P,V],(t,[e,r])=>mr(e.evaluate(t),r.evaluate(t))]]},"feature-state":[T,[P],(t,[e])=>mr(e.evaluate(t),t.featureState||{})],properties:[V,[],t=>t.properties()],"geometry-type":[P,[],t=>t.geometryType()],id:[T,[],t=>t.id()],zoom:[z,[],t=>t.globals.zoom],"heatmap-density":[z,[],t=>t.globals.heatmapDensity||0],"line-progress":[z,[],t=>t.globals.lineProgress||0],accumulated:[T,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[z,gr(z),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[z,gr(z),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:z,overloads:[[[z,z],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[z],(t,[e])=>-e.evaluate(t)]]},"/":[z,[z,z],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[z,[z,z],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[z,[],()=>Math.LN2],pi:[z,[],()=>Math.PI],e:[z,[],()=>Math.E],"^":[z,[z,z],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[z,[z],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[z,[z],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[z,[z],(t,[e])=>Math.log(e.evaluate(t))],log2:[z,[z],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[z,[z],(t,[e])=>Math.sin(e.evaluate(t))],cos:[z,[z],(t,[e])=>Math.cos(e.evaluate(t))],tan:[z,[z],(t,[e])=>Math.tan(e.evaluate(t))],asin:[z,[z],(t,[e])=>Math.asin(e.evaluate(t))],acos:[z,[z],(t,[e])=>Math.acos(e.evaluate(t))],atan:[z,[z],(t,[e])=>Math.atan(e.evaluate(t))],min:[z,gr(z),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[z,gr(z),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[z,[z],(t,[e])=>Math.abs(e.evaluate(t))],round:[z,[z],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[z,[z],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[z,[z],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[C,[P,T],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[C,[T],(t,[e])=>t.id()===e.value],"filter-type-==":[C,[P],(t,[e])=>t.geometryType()===e.value],"filter-<":[C,[P,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[C,[P,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[C,[T],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[C,[P,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[C,[T],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[C,[P,T],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[C,[T],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[C,[T],(t,[e])=>e.value in t.properties()],"filter-has-id":[C,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[C,[O(P)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[C,[O(T)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[C,[P,O(T)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[C,[P,O(T)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:C,overloads:[[[C,C],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[gr(C),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:C,overloads:[[[C,C],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[gr(C),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[C,[C],(t,[e])=>!e.evaluate(t)],"is-supported-script":[C,[P],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[P,[P],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[P,[P],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[P,gr(T),(t,e)=>e.map((e=>St(e.evaluate(t)))).join("")],"resolved-locale":[P,[E],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Dr{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new Bt,this._defaultValue=e?"color"===(r=e).type&&zr(r.default)?new pt(0,0,0,0):"color"===r.type?pt.parse(r.default)||null:"padding"===r.type?mt.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?xt.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,s){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new At(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function $r(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in pr}function Lr(t,e){const r=new Vt(pr,xr,[],e?function(t){const e={color:B,string:P,number:z,enum:P,boolean:C,formatted:F,padding:D,resolvedImage:$,variableAnchorOffsetCollection:L};return"array"===t.type?O(e[t.value]||T,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?_r(new Dr(n,e)):Sr(r.errors)}class Or{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!br(e.expression)}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class Rr{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!br(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?Jt.interpolationFactor(this.interpolationType,t,e,r):0}}function jr(t,e){const r=Lr(t,e);if("error"===r.result)return r;const n=r.value.expression,i=vr(n);if(!i&&!kr(e))return Sr([new A("","data expressions not supported")]);const s=wr(n,["zoom"]);if(!s&&!Ar(e))return Sr([new A("","zoom expressions not supported")]);const o=Ur(n);return o||s?o instanceof A?Sr([o]):o instanceof Jt&&!Ir(e)?Sr([new A("",'"interpolate" expressions cannot be used with this property')]):_r(o?new Rr(i?"camera":"composite",r.value,o.labels,o instanceof Jt?o.interpolation:void 0):new Or(i?"constant":"source",r.value)):Sr([new A("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class qr{constructor(t,e){this._parameters=t,this._specification=e,k(this,Cr(this._parameters,this._specification))}static deserialize(t){return new qr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Ur(t){let e=null;if(t instanceof Tt)e=Ur(t.result);else if(t instanceof Wt){for(const r of t.args)if(e=Ur(r),e)break}else(t instanceof qt||t instanceof Jt)&&t.input instanceof fr&&"zoom"===t.input.name&&(e=t);return e instanceof A||t.eachChild((t=>{const r=Ur(t);r instanceof A?e=r:!e&&r?e=new A("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new A("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Nr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Nr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const Zr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Gr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};Nr(t)||(t=Yr(t));const e=Lr(t,Zr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:Hr(t)}}function Xr(t,e){return te?1:0}function Hr(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?Jr(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Yr))):"all"===e?["all"].concat(t.slice(1).map(Yr)):"none"===e?["all"].concat(t.slice(1).map(Yr).map(Qr)):"in"===e?Kr(t[1],t.slice(2)):"!in"===e?Qr(Kr(t[1],t.slice(2))):"has"===e?Wr(t[1]):"!has"!==e||Qr(Wr(t[1]));var r}function Jr(t,e,r){switch(t){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,t,e]}}function Kr(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(Xr)]]:["filter-in-small",t,["literal",e]]}}function Wr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Qr(t){return["!",t]}function tn(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${tn(r)},`;return`${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new S(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function un(t){const e=t.valueSpec,r=nn(t.value.type);let n,i,s,o={};const a="categorical"!==r&&void 0===t.value.property,l=!a,u="array"===Mr(t.value.stops)&&"array"===Mr(t.value.stops[0])&&"object"===Mr(t.value.stops[0][0]),c=on({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return[new S(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(an({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Mr(n)&&0===n.length&&e.push(new S(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===r&&a&&c.push(new S(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||c.push(new S(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!Ir(t.valueSpec)&&c.push(new S(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!kr(t.valueSpec)?c.push(new S(t.key,t.value,"property functions not supported")):a&&!Ar(t.valueSpec)&&c.push(new S(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||c.push(new S(t.key,t.value,'"property" property is required')),c;function h(t){let r=[];const n=t.value,a=t.key;if("array"!==Mr(n))return[new S(a,n,`array expected, ${Mr(n)} found`)];if(2!==n.length)return[new S(a,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==Mr(n[0]))return[new S(a,n,`object expected, ${Mr(n[0])} found`)];if(void 0===n[0].zoom)return[new S(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new S(a,n,"object stop key must have value")];if(s&&s>nn(n[0].zoom))return[new S(a,n[0].zoom,"stop zoom values must appear in ascending order")];nn(n[0].zoom)!==s&&(s=nn(n[0].zoom),i=void 0,o={}),r=r.concat(on({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:ln,value:p}}))}else r=r.concat(p({key:`${a}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return $r(sn(n[1]))?r.concat([new S(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const a=Mr(t.value),l=nn(t.value),u=null!==t.value?t.value:s;if(n){if(a!==n)return[new S(t.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 S(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==r){let n=`number expected, ${a} found`;return kr(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new S(t.key,u,n)]}return"categorical"!==r||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===a&&void 0!==i&&lnew S(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new S(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!br(r))return[new S(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!br(r))return[new S(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!wr(r,["zoom","feature-state"]))return[new S(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!vr(r))return[new S(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function hn(t){const e=t.key,r=t.value,n=t.valueSpec,i=[];return Array.isArray(n.values)?-1===n.values.indexOf(nn(r))&&i.push(new S(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(nn(r))&&i.push(new S(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),i}function pn(t){return Nr(sn(t.value))?cn(k({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):fn(t)}function fn(t){const e=t.value,r=t.key;if("array"!==Mr(e))return[new S(r,e,`array expected, ${Mr(e)} found`)];const n=t.styleSpec;let i,s=[];if(e.length<1)return[new S(r,e,"filter array must have at least 1 element")];switch(s=s.concat(hn({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),nn(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===nn(e[1])&&s.push(new S(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new S(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=Mr(e[1]),"string"!==i&&s.push(new S(`${r}[1]`,e[1],`string expected, ${i} found`)));for(let o=2;o{t in r&&e.push(new S(n,r[t],`"${t}" is prohibited for ref layers`))})),i.layers.forEach((e=>{nn(e.id)===a&&(t=e)})),t?t.ref?e.push(new S(n,r.ref,"ref cannot reference another ref layer")):o=nn(t.type):e.push(new S(n,r.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(r.source){const t=i.sources&&i.sources[r.source],s=t&&nn(t.type);t?"vector"===s&&"raster"===o?e.push(new S(n,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o?e.push(new S(n,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?e.push(new S(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==o?e.push(new S(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==o||!r.paint||!r.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new S(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new S(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new S(n,r.source,`source "${r.source}" not found`))}else e.push(new S(n,r,'missing required property "source"'));return e=e.concat(on({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:pn,layout:t=>on({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>mn(k({layerType:o},t))}}),paint:t=>on({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>yn(k({layerType:o},t))}})}})),e}function xn(t){const e=t.value,r=t.key,n=Mr(e);return"string"!==n?[new S(r,e,`string expected, ${n} found`)]:[]}const vn={promoteId:function({key:t,value:e}){if("string"===Mr(e))return xn({key:t,value:e});{const r=[];for(const n in e)r.push(...xn({key:`${t}.${n}`,value:e[n]}));return r}}};function bn(t){const e=t.value,r=t.key,n=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return[new S(r,e,'"type" is required')];const o=nn(e.type);let a;switch(o){case"vector":case"raster":return a=on({key:r,value:e,valueSpec:n[`source_${o.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:vn,validateSpec:s}),a;case"raster-dem":return a=function(t){var e;const r=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,i=t.styleSpec,s=i.source_raster_dem,o=t.style;let a=[];const l=Mr(n);if(void 0===n)return a;if("object"!==l)return a.push(new S("source_raster_dem",n,`object expected, ${l} found`)),a;const u="custom"===nn(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],h=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!u&&c.includes(e)?a.push(new S(e,n[e],`In "${r}": "${e}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):s[e]?a=a.concat(t.validateSpec({key:e,value:n[e],valueSpec:s[e],validateSpec:t.validateSpec,style:o,styleSpec:i})):a.push(new S(e,n[e],`unknown property "${e}"`));return a}({sourceName:r,value:e,style:t.style,styleSpec:n,validateSpec:s}),a;case"geojson":if(a=on({key:r,value:e,valueSpec:n.source_geojson,style:i,styleSpec:n,validateSpec:s,objectElementValidators:vn}),e.cluster)for(const t in e.clusterProperties){const[n,i]=e.clusterProperties[t],o="string"==typeof n?[n,["accumulated"],["get",t]]:n;a.push(...cn({key:`${r}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),a.push(...cn({key:`${r}.${t}.reduce`,value:o,validateSpec:s,expressionContext:"cluster-reduce"}))}return a;case"video":return on({key:r,value:e,valueSpec:n.source_video,style:i,validateSpec:s,styleSpec:n});case"image":return on({key:r,value:e,valueSpec:n.source_image,style:i,validateSpec:s,styleSpec:n});case"canvas":return[new S(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return hn({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:n})}}function wn(t){const e=t.value,r=t.styleSpec,n=r.light,i=t.style;let s=[];const o=Mr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new S("light",e,`object expected, ${o} found`)]),s;for(const o in e){const a=o.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:r.transition,validateSpec:t.validateSpec,style:i,styleSpec:r}):n[o]?t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new S(o,e[o],`unknown property "${o}"`)])}return s}function _n(t){const e=t.value,r=t.styleSpec,n=r.sky,i=t.style,s=Mr(e);if(void 0===e)return[];if("object"!==s)return[new S("sky",e,`object expected, ${s} found`)];let o=[];for(const s in e)o=o.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new S(s,e[s],`unknown property "${s}"`)]);return o}function Sn(t){const e=t.value,r=t.styleSpec,n=r.terrain,i=t.style;let s=[];const o=Mr(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new S("terrain",e,`object expected, ${o} found`)]),s;for(const o in e)s=s.concat(n[o]?t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:i,styleSpec:r}):[new S(o,e[o],`unknown property "${o}"`)]);return s}function kn(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const i=[],s=[];for(const o in r)r[o].id&&i.includes(r[o].id)&&e.push(new S(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)&&e.push(new S(n,r,`all the sprites' URLs must be unique, but ${r[o].url} is duplicated`)),s.push(r[o].url),e=e.concat(on({key:`${n}[${o}]`,value:r[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return xn({key:n,value:r})}const An={"*":()=>[],array:an,boolean:function(t){const e=t.value,r=t.key,n=Mr(e);return"boolean"!==n?[new S(r,e,`boolean expected, ${n} found`)]:[]},number:ln,color:function(t){const e=t.key,r=t.value,n=Mr(r);return"string"!==n?[new S(e,r,`color expected, ${n} found`)]:pt.parse(String(r))?[]:[new S(e,r,`color expected, "${r}" found`)]},constants:rn,enum:hn,filter:pn,function:un,layer:gn,object:on,source:bn,light:wn,sky:_n,terrain:Sn,projection:function(t){const e=t.value,r=t.styleSpec,n=r.projection,i=t.style,s=Mr(e);if(void 0===e)return[];if("object"!==s)return[new S("projection",e,`object expected, ${s} found`)];let o=[];for(const s in e)o=o.concat(n[s]?t.validateSpec({key:s,value:e[s],valueSpec:n[s],style:i,styleSpec:r}):[new S(s,e[s],`unknown property "${s}"`)]);return o},string:xn,formatted:function(t){return 0===xn(t).length?[]:cn(t)},resolvedImage:function(t){return 0===xn(t).length?[]:cn(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Mr(r)){if(r.length<1||r.length>4)return[new S(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(r=r.concat(rn({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:In}))),Cn(r)}function Pn(t){return function(e){return t({...e,validateSpec:In})}}function Cn(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Bn(t){return function(...e){return Cn(t.apply(this,e))}}zn.source=Bn(Pn(bn)),zn.sprite=Bn(Pn(kn)),zn.glyphs=Bn(Pn(Mn)),zn.light=Bn(Pn(wn)),zn.sky=Bn(Pn(_n)),zn.terrain=Bn(Pn(Sn)),zn.layer=Bn(Pn(gn)),zn.filter=Bn(Pn(pn)),zn.paintProperty=Bn(Pn(yn)),zn.layoutProperty=Bn(Pn(mn));const Vn="AbortError";function Tn(){return new Error(Vn)}const En={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function Fn(t,e){En.REGISTERED_PROTOCOLS[t]=e}function Dn(t){delete En.REGISTERED_PROTOCOLS[t]}const $n="global-dispatcher";class Ln extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n}}const On=()=>m(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,Rn=function(e,r){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=En.REGISTERED_PROTOCOLS[(n=e.url).substring(0,n.indexOf("://"))];if(t)return t(e,r);if(m(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:$n},r)}var n;if(!(t=>/^file:/.test(t)||/^file:/.test(On())&&!/^\w+:/.test(t))(e.url)){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,r){return t(this,void 0,void 0,(function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:On(),signal:r.signal});"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");const n=yield fetch(t);if(!n.ok){const t=yield n.blob();throw new Ln(n.status,n.statusText,e.url,t)}let i;i="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const s=yield i;if(r.signal.aborted)throw Tn();return{data:s,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}))}(e,r);if(m(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:$n},r)}return function(t,e){return new Promise(((r,n)=>{var i;const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",(null===(i=t.headers)||void 0===i?void 0:i.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{n(new Error(s.statusText))},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response)}catch(t){return void n(t)}r({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")})}else{const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});n(new Ln(s.status,s.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{s.abort(),n(Tn())})),s.send(t.body)}))}(e,r)},jn={};function qn(t,e,r={}){if(jn[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),jn[t]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}qn("Object",Object),qn("TransferableGridIndex",b),qn("Color",pt),qn("Error",Error),qn("AJAXError",Ln),qn("ResolvedImage",vt),qn("StylePropertyFunction",qr),qn("StyleExpression",Dr,{omit:["_evaluator"]}),qn("ZoomDependentExpression",Rr),qn("ZoomConstantExpression",Or),qn("CompoundExpression",fr,{omit:["_evaluate"]});for(const t in pr)pr[t]._classRegistryKey||qn(`Expression_${t}`,pr[t]);function Un(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Nn(t){return t.$name||t.constructor._classRegistryKey}function Zn(t){return!function(t){if(null===t||"object"!=typeof t)return!1;const e=Nn(t);return!(!e||"Object"===e)}(t)&&(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof Error||Un(t)||g(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function Gn(t,e){if(Zn(t))return(Un(t)||g(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const n of t)r.push(Gn(n,e));return r}if("object"!=typeof t)throw new Error("can't serialize object of type "+typeof t);const r=Nn(t);if(!r)throw new Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!jn[r])throw new Error(`${r} is not registered.`);const{klass:n}=jn[r],i=n.serialize?n.serialize(t,e):{};if(n.serialize){if(e&&i===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const n in t){if(!t.hasOwnProperty(n))continue;if(jn[r].omit.indexOf(n)>=0)continue;const s=t[n];i[n]=jn[r].shallow.indexOf(n)>=0?s:Gn(s,e)}t instanceof Error&&(i.message=t.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}function Xn(t){if(Zn(t))return t;if(Array.isArray(t))return t.map(Xn);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=Nn(t)||"Object";if(!jn[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=jn[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const r of Object.keys(t)){if("$name"===r)continue;const i=t[r];n[r]=jn[e].shallow.indexOf(r)>=0?i:Xn(i)}return n}class Hn{constructor(t){this._methodToThrottle=t,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=()=>{}}}class Yn{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Hn((()=>this.process())),this.subscription=function(t,e,r,n){return t.addEventListener(e,r,!1),{unsubscribe:()=>{t.removeEventListener(e,r,!1)}}}(this.target,"message",(t=>this.receive(t))),this.globalScope=m(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}sendAsync(t,e){return new Promise(((r,n)=>{const i=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[i]={resolve:r,reject:n},e&&e.signal.addEventListener("abort",(()=>{delete this.resolveRejects[i];const e={id:i,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e)}),{once:!0});const s=[],o=Object.assign(Object.assign({},t),{id:i,sourceMapId:this.mapId,origin:location.origin,data:Gn(t.data,s)});this.target.postMessage(o,{transfer:s})}))}receive(t){const e=t.data,r=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&"resource://android"!==e.origin&&"resource://android"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[r];const t=this.abortControllers[r];return delete this.abortControllers[r],void(t&&t.abort())}if(m(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e)}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(e,r){return t(this,void 0,void 0,(function*(){if(""===r.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(r.error?t.reject(Xn(r.error)):t.resolve(Xn(r.data)))}if(!this.messageHandlers[r.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${r.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=Xn(r.data),n=new AbortController;this.abortControllers[e]=n;try{const i=yield this.messageHandlers[r.type](r.sourceMapId,t,n);this.completeTask(e,null,i)}catch(t){this.completeTask(e,t)}}))}completeTask(t,e,r){const n=[];delete this.abortControllers[t];const i={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?Gn(e):null,data:Gn(r,n)};this.target.postMessage(i,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}}function Jn(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e))}function Kn(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}class Wn{constructor(t,e={}){c(this,e),this.type=t}}class Qn extends Wn{constructor(t,e={}){super("error",c({error:t},e))}}class ti{on(t,e){return this._listeners=this._listeners||{},Jn(t,e,this._listeners),this}off(t,e){return Kn(t,e,this._listeners),Kn(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Jn(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Wn(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)Kn(r,e,this._oneTimeListeners),e.call(this,t);const i=this._eventedParent;i&&(c(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(t))}else t instanceof Qn&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}const ei=zn,ri=ei.paintProperty,ni=ei.layoutProperty;class ii{constructor(){this.first=!0}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=128&&t<=255,"Hangul Jamo":t=>t>=4352&&t<=4607,Khmer:t=>t>=6016&&t<=6143,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Katakana:t=>t>=12448&&t<=12543,Kanbun:t=>t>=12688&&t<=12703,"CJK Strokes":t=>t>=12736&&t<=12783,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"Private Use Area":t=>t>=57344&&t<=63743,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function oi(t){for(const e of t)if(pi(e.charCodeAt(0)))return!0;return!1}function ai(t){for(const e of t)if(!ci(e.charCodeAt(0)))return!1;return!0}function li(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const ui=li(["Arab","Dupl","Mong","Ougr","Syrc"]);function ci(t){return!ui.test(String.fromCodePoint(t))}const hi=li(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function pi(t){return!(746!==t&&747!==t&&(t<4352||!(si["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||si["CJK Compatibility"](t)||si["CJK Strokes"](t)||!(!si["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||si["Enclosed CJK Letters and Months"](t)||si["Ideographic Description Characters"](t)||si.Kanbun(t)||si.Katakana(t)&&12540!==t||!(!si["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!si["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||si["Vertical Forms"](t)||si["Yijing Hexagram Symbols"](t)||/\p{sc=Cans}/u.test(String.fromCodePoint(t))||/\p{sc=Hang}/u.test(String.fromCodePoint(t))||hi.test(String.fromCodePoint(t)))))}function fi(t){return!(pi(t)||function(t){return!!(si["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||si["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||si["Letterlike Symbols"](t)||si["Number Forms"](t)||si["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||si["Control Pictures"](t)&&9251!==t||si["Optical Character Recognition"](t)||si["Enclosed Alphanumerics"](t)||si["Geometric Shapes"](t)||si["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||si["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||si["CJK Symbols and Punctuation"](t)||si.Katakana(t)||si["Private Use Area"](t)||si["CJK Compatibility Forms"](t)||si["Small Form Variants"](t)||si["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}const di=li(["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 yi(t){return di.test(String.fromCodePoint(t))}function mi(t,e){return!(!e&&yi(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||si.Khmer(t))}function gi(t){for(const e of t)if(yi(e.charCodeAt(0)))return!0;return!1}const xi=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class vi{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ii,this.transition={})}isSupportedScript(t){return function(t,e){for(const r of t)if(!mi(r.charCodeAt(0),e))return!1;return!0}(t,"loaded"===xi.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class bi{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(zr(t))return new qr(t,e);if($r(t)){const r=jr(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return"color"===e.type&&"string"==typeof t?r=pt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(r=xt.parse(t)):r=mt.parse(t),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class wi{constructor(t){this.property=t,this.value=new bi(t,void 0)}transitioned(t,e){return new Si(this.property,this.value,e,c({},t.transition,this.transition),t.now)}untransitioned(){return new Si(this.property,this.value,null,{},0)}}class _i{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return p(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new wi(this._values[t].property)),this._values[t].value=new bi(this._values[t].property,null===e?void 0:p(e))}getTransition(t){return p(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new wi(this._values[t].property)),this._values[t].transition=p(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const r=new ki(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new ki(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Si{constructor(t,e,r,n,i){this.property=t,this.value=e,this.begin=i+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r)}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,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 e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(o))}}return i}}class ki{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,r){const n=new Mi(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Ai{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return void 0!==this._values[t].value}getValue(t){return p(this._values[t].value)}setValue(t,e){this._values[t]=new bi(this._values[t].property,null===e?void 0:p(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r)}return t}possiblyEvaluate(t,e,r){const n=new Mi(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}}class Ii{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n)}}class Mi{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class zi{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,r){const n=Yt[this.specification.type];return n?n(t,e,r):t}}class Pi{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,r,n){return new Ii(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},r,n)}:t.expression,e)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Ii(this,{kind:"constant",value:void 0},t.parameters);const n=Yt[this.specification.type];if(n){const i=n(t.value.value,e.value.value,r);return new Ii(this,{kind:"constant",value:i},t.parameters)}return t}evaluate(t,e,r,n,i,s){return"constant"===t.kind?t.value:t.evaluate(e,r,n,i,s)}}class Ci extends Pi{possiblyEvaluate(t,e,r,n){if(void 0===t.value)return new Ii(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n),s="resolvedImage"===t.property.specification.type&&"string"!=typeof i?i.name:i,o=this._calculate(s,s,s,e);return new Ii(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const r=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Ii(this,{kind:"constant",value:r},e)}return new Ii(this,t.expression,e)}evaluate(t,e,r,n,i,s){if("source"===t.kind){const o=t.evaluate(e,r,n,i,s);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},r,n),t.evaluate({zoom:Math.floor(e.zoom)},r,n),t.evaluate({zoom:Math.floor(e.zoom)+1},r,n),e):t.value}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Bi{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const i=t.expression.evaluate(e,null,{},r,n);return this._calculate(i,i,i,e)}return this._calculate(t.expression.evaluate(new vi(Math.floor(e.zoom-1),e)),t.expression.evaluate(new vi(Math.floor(e.zoom),e)),t.expression.evaluate(new vi(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Vi{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){return!!t.expression.evaluate(e,null,{},r,n)}interpolate(){return!1}}class Ti{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new bi(r,void 0),i=this.defaultTransitionablePropertyValues[e]=new wi(r);this.defaultTransitioningPropertyValues[e]=i.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}}}qn("DataDrivenProperty",Pi),qn("DataConstantProperty",zi),qn("CrossFadedDataDrivenProperty",Ci),qn("CrossFadedProperty",Bi),qn("ColorRampProperty",Vi);const Ei="-transition";class Fi extends ti{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Ai(e.layout)),e.paint)){this._transitionablePaint=new _i(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Mi(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(ni,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(Ei)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(ri,`layers.${this.id}.paint.${t}`,t,e,r))return!1;if(t.endsWith(Ei))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],i=r.value.isDataDriven(),s=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||i||n||this._handleOverridablePaintPropertyUpdate(t,s,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={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&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),function(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,r,n,i={}){return(!i||!1!==i.validate)&&function(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new Qn(new Error(n.message))),r=!0;return r}(this,t.call(ei,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:w,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Ii&&kr(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Di={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class $i{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Li{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Oi(t,e=1){let r=0,n=0;return{members:t.map((t=>{const i=Di[t.type].BYTES_PER_ELEMENT,s=r=Ri(r,Math.max(e,i)),o=t.components||1;return n=Math.max(n,i),r+=i*o,{name:t.name,type:t.type,components:o,offset:s}})),size:Ri(r,Math.max(n,e)),alignment:e}}function Ri(t,e){return Math.ceil(t/e)*e}class ji extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}ji.prototype.bytesPerElement=4,qn("StructArrayLayout2i4",ji);class qi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}qi.prototype.bytesPerElement=6,qn("StructArrayLayout3i6",qi);class Ui extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Ui.prototype.bytesPerElement=8,qn("StructArrayLayout4i8",Ui);class Ni extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,o){const a=6*t;return this.int16[a+0]=e,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,t}}Ni.prototype.bytesPerElement=12,qn("StructArrayLayout2i4i12",Ni);class Zi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,o){const a=4*t,l=8*t;return this.int16[a+0]=e,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,t}}Zi.prototype.bytesPerElement=8,qn("StructArrayLayout2i4ub8",Zi);class Gi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Gi.prototype.bytesPerElement=8,qn("StructArrayLayout2f8",Gi);class Xi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,o,a,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,i,s,o,a,l,u)}emplace(t,e,r,n,i,s,o,a,l,u,c){const h=10*t;return this.uint16[h+0]=e,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,t}}Xi.prototype.bytesPerElement=20,qn("StructArrayLayout10ui20",Xi);class Hi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s,o,a,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,o,a,l,u,c,h)}emplace(t,e,r,n,i,s,o,a,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,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,t}}Hi.prototype.bytesPerElement=24,qn("StructArrayLayout4i4ui4i24",Hi);class Yi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Yi.prototype.bytesPerElement=12,qn("StructArrayLayout3f12",Yi);class Ji extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Ji.prototype.bytesPerElement=4,qn("StructArrayLayout1ul4",Ji);class Ki extends Li{_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(t,e,r,n,i,s,o,a,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,s,o,a,l)}emplace(t,e,r,n,i,s,o,a,l,u){const c=10*t,h=5*t;return this.int16[c+0]=e,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,t}}Ki.prototype.bytesPerElement=20,qn("StructArrayLayout6i1ul2ui20",Ki);class Wi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,o){const a=6*t;return this.int16[a+0]=e,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,t}}Wi.prototype.bytesPerElement=12,qn("StructArrayLayout2i2i2i12",Wi);class Qi extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=r,this.float32[o+2]=n,this.int16[a+6]=i,this.int16[a+7]=s,t}}Qi.prototype.bytesPerElement=16,qn("StructArrayLayout2f1f2i16",Qi);class ts extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,o){const a=16*t,l=4*t,u=8*t;return this.uint8[a+0]=e,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,t}}ts.prototype.bytesPerElement=16,qn("StructArrayLayout2ub2f2i16",ts);class es extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}es.prototype.bytesPerElement=6,qn("StructArrayLayout3ui6",es);class rs extends Li{_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(t,e,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,t,e,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m)}emplace(t,e,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g){const x=24*t,v=12*t,b=48*t;return this.int16[x+0]=e,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,t}}rs.prototype.bytesPerElement=48,qn("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",rs);class ns extends Li{_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(t,e,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,A,I,M){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,A,I,M)}emplace(t,e,r,n,i,s,o,a,l,u,c,h,p,f,d,y,m,g,x,v,b,w,_,S,k,A,I,M,z){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=r,this.int16[P+2]=n,this.int16[P+3]=i,this.int16[P+4]=s,this.int16[P+5]=o,this.int16[P+6]=a,this.int16[P+7]=l,this.uint16[P+8]=u,this.uint16[P+9]=c,this.uint16[P+10]=h,this.uint16[P+11]=p,this.uint16[P+12]=f,this.uint16[P+13]=d,this.uint16[P+14]=y,this.uint16[P+15]=m,this.uint16[P+16]=g,this.uint16[P+17]=x,this.uint16[P+18]=v,this.uint16[P+19]=b,this.uint16[P+20]=w,this.uint16[P+21]=_,this.uint16[P+22]=S,this.uint32[C+12]=k,this.float32[C+13]=A,this.float32[C+14]=I,this.uint16[P+30]=M,this.uint16[P+31]=z,t}}ns.prototype.bytesPerElement=64,qn("StructArrayLayout8i15ui1ul2f2ui64",ns);class is extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}is.prototype.bytesPerElement=4,qn("StructArrayLayout1f4",is);class ss extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[6*t+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}ss.prototype.bytesPerElement=12,qn("StructArrayLayout1ui2f12",ss);class os extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.uint32[2*t+0]=e,this.uint16[i+2]=r,this.uint16[i+3]=n,t}}os.prototype.bytesPerElement=8,qn("StructArrayLayout1ul2ui8",os);class as extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}as.prototype.bytesPerElement=4,qn("StructArrayLayout2ui4",as);class ls extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}ls.prototype.bytesPerElement=2,qn("StructArrayLayout1ui2",ls);class us extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}us.prototype.bytesPerElement=16,qn("StructArrayLayout4f16",us);class cs extends $i{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 i(this.anchorPointX,this.anchorPointY)}}cs.prototype.size=20;class hs extends Ki{get(t){return new cs(this,t)}}qn("CollisionBoxArray",hs);class ps extends $i{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(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}ps.prototype.size=48;class fs extends rs{get(t){return new ps(this,t)}}qn("PlacedSymbolArray",fs);class ds extends $i{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(t){this._structArray.uint32[this._pos4+12]=t}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]}}ds.prototype.size=64;class ys extends ns{get(t){return new ds(this,t)}}qn("SymbolInstanceArray",ys);class ms extends is{getoffsetX(t){return this.float32[1*t+0]}}qn("GlyphOffsetArray",ms);class gs extends qi{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}qn("SymbolLineVertexArray",gs);class xs extends $i{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]}}xs.prototype.size=12;class vs extends ss{get(t){return new xs(this,t)}}qn("TextAnchorOffsetArray",vs);class bs extends $i{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]}}bs.prototype.size=8;class ws extends os{get(t){return new bs(this,t)}}qn("FeatureIndexArray",ws);class _s extends ji{}class Ss extends ji{}class ks extends ji{}class As extends Ni{}class Is extends Zi{}class Ms extends Gi{}class zs extends Xi{}class Ps extends Hi{}class Cs extends Yi{}class Bs extends Ji{}class Vs extends Wi{}class Ts extends ts{}class Es extends es{}class Fs extends as{}const Ds=Oi([{name:"a_pos",components:2,type:"Int16"}],4),{members:$s}=Ds;class Ls{constructor(t=[]){this.segments=t}prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>Ls.MAX_VERTEX_ARRAY_LENGTH&&d(`Max vertices per segment is ${Ls.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>Ls.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,r,n){return new Ls([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Os(t,e){return 256*(t=u(Math.floor(t),0,255))+u(Math.floor(e),0,255)}Ls.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,qn("SegmentVector",Ls);const Rs=Oi([{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"}]);var js={exports:{}},qs={exports:{}};qs.exports=function(t,e){var r,n,i,s,o,a,l,u;for(n=t.length-(r=3&t.length),i=e,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&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return i^=t.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};var Us=qs.exports,Ns={exports:{}};Ns.exports=function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.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&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var Zs=Us,Gs=Ns.exports;js.exports=Zs,js.exports.murmur3=Zs,js.exports.murmur2=Gs;var Xs=e(js.exports);class Hs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,r,n){this.ids.push(Ys(t)),this.positions.push(e,r,n)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=Ys(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1}const i=[];for(;this.ids[r]===e;)i.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return i}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Js(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new Hs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Ys(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Xs(String(t))}function Js(t,e,r,n){for(;r>1];let s=r-1,o=n+1;for(;;){do{s++}while(t[s]i);if(s>=o)break;Ks(t,s,o),Ks(e,3*s,3*o),Ks(e,3*s+1,3*o+1),Ks(e,3*s+2,3*o+2)}o-r`u_${t}`)),this.type=r}setUniform(t,e,r){t.set(r.constantOr(this.value))}getBinding(t,e,r){return"color"===this.type?new eo(t,e):new Qs(t,e)}}class io{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,r,n){const i="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;i&&t.set(i)}getBinding(t,e,r){return"u_pattern"===r.substr(0,9)?new to(t,e):new Qs(t,e)}}class so{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,r,n,i){const s=this.paintVertexArray.length,o=this.expression.evaluate(new vi(0),e,{},n,[],i);this.paintVertexArray.resize(t),this._setPaintValue(s,t,o)}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,i)}_setPaintValue(t,e,r){if("color"===this.type){const n=ro(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new s}populatePaintArray(t,e,r,n,i){const s=this.expression.evaluate(new vi(this.zoom),e,{},n,[],i),o=this.expression.evaluate(new vi(this.zoom+1),e,{},n,[],i),a=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(a,t,s,o)}updatePaintArray(t,e,r,n){const i=this.expression.evaluate({zoom:this.zoom},r,n),s=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,i,s)}_setPaintValue(t,e,r,n){if("color"===this.type){const i=ro(r),s=ro(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof so||r instanceof oo)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new lo(n,e,r);this.needsUpload=!1,this._featureMap=new Hs,this._bufferOffset=0}populatePaintArrays(t,e,r,n,i,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,r,n){for(const i of r)this.needsUpload=this.programConfigurations[i.id].updatePaintArrays(t,this._featureMap,e,i,n)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function co(t,e){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-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"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function ho(t,e,r){const n={color:{source:Gi,composite:us},number:{source:is,composite:Gi}},i=function(t){return{"line-pattern":{source:zs,composite:zs},"fill-pattern":{source:zs,composite:zs},"fill-extrusion-pattern":{source:zs,composite:zs}}[t]}(t);return i&&i[r]||n[e][r]}qn("ConstantBinder",no),qn("CrossFadedConstantBinder",io),qn("SourceExpressionBinder",so),qn("CrossFadedCompositeBinder",ao),qn("CompositeExpressionBinder",oo),qn("ProgramConfiguration",lo,{omit:["_buffers"]}),qn("ProgramConfigurationSet",uo);const po=8192,fo=Math.pow(2,14)-1,yo=-fo-1;function mo(t){const e=po/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||sr.y+1)&&d("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function go(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?mo(t):[]}}function xo(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2)}class vo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Ss,this.indexArray=new Es,this.segments=new Ls,this.programConfigurations=new uo(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){const n=this.layers[0],i=[];let s=null,o=!1;"circle"===n.type&&(s=n.layout.get("circle-sort-key"),o=!s.isConstant());for(const{feature:e,id:n,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=go(e,t);if(!this.layers[0]._featureFilter.filter(new vi(this.zoom),u,r))continue;const c=o?s.evaluate(u,{},r):void 0,h={id:n,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?u.geometry:mo(e),patterns:{},sortKey:c};i.push(h)}o&&i.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of i){const{geometry:i,index:s,sourceLayerIndex:o}=n,a=t[s].feature;this.addFeature(n,i,s,r),e.featureIndex.insert(a,i,s,o,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$s),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,r,n){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=po||n<0||n>=po)continue;const i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),s=i.vertexLength;xo(this.layoutVertexArray,r,n,-1,-1),xo(this.layoutVertexArray,r,n,1,-1),xo(this.layoutVertexArray,r,n,1,1),xo(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+3,s+2),i.vertexLength+=4,i.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n)}}function bo(t,e){for(let r=0;r1){if(ko(t,e))return!0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function zo(t,e){let r,n,i,s=!1;for(let o=0;oe.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s)}return s}function Po(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(r=!r)}return r}function Co(t,e,r){const n=r[0],i=r[2];if(t.xi.x&&e.x>i.x||t.yi.y&&e.y>i.y)return!1;const s=y(t,e,r[0]);return s!==y(t,e,r[1])||s!==y(t,e,r[2])||s!==y(t,e,r[3])}function Bo(t,e,r){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function Vo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function To(t,e,r,n,s){if(!e[0]&&!e[1])return t;const o=i.convert(e)._mult(s);"viewport"===r&&o._rotate(-n);const a=[];for(let e=0;eqo(t,e)))}(l,a),p=c?u*o:u;for(const t of n)for(const e of t){const t=c?e:qo(e,a);let r=p;const n=Ro([],[e.x,e.y,0,1],a);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/s.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=s.cameraToCenterDistance/n[3]),wo(h,t,r))return!0}return!1}}function qo(t,e){const r=Ro([],[t.x,t.y,0,1],e);return new i(r[0]/r[3],r[1]/r[3])}class Uo extends vo{}let No;qn("HeatmapBucket",Uo,{omit:["layers"]});var Zo={get paint(){return No=No||new Ti({"heatmap-radius":new Pi(w.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Pi(w.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new zi(w.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Vi(w.paint_heatmap["heatmap-color"]),"heatmap-opacity":new zi(w.paint_heatmap["heatmap-opacity"])})}};function Go(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError(`mismatched image size. expected: ${i.length} but got: ${e*r*n}`)}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function Xo(t,{width:e,height:r},n){if(e===t.width&&r===t.height)return;const i=Go({},{width:e,height:r},n);Ho(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,r)},n),t.width=e,t.height=r,t.data=i.data}function Ho(t,e,r,n,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=e.data;if(o===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=s;const o=t.expression.evaluate(e);i.data[r+n+0]=Math.floor(255*o.r/o.a),i.data[r+n+1]=Math.floor(255*o.g/o.a),i.data[r+n+2]=Math.floor(255*o.b/o.a),i.data[r+n+3]=Math.floor(255*o.a)};if(t.clips)for(let e=0,i=0;e80*r){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i)}u=Math.max(e-a,n-l),u=0!==u?32767/u:0}return aa(s,o,r,a,l,u,0),o}function sa(t,e,r,n,i){let s;if(i===function(t,e,r,n){let i=0;for(let s=e,o=r-n;s0)for(let i=e;i=e;i-=n)s=Ia(i/n|0,t[i],t[i+1],s);return s&&ba(s,s.next)&&(Ma(s),s=s.next),s}function oa(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!ba(n,n.next)&&0!==va(n.prev,n,n.next))n=n.next;else{if(Ma(n),n=e=n.prev,n===n.next)break;r=!0}}while(r||n!==e);return e}function aa(t,e,r,n,i,s,o){if(!t)return;!o&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=ya(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let o=i,a=0;for(let t=0;t0||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:t=n,n.prevZ=s,s=n;i=o}s.nextZ=null,r*=2}while(e>1)}(i)}(t,n,i,s);let a=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?ua(t,n,i,s):la(t))e.push(l.i,t.i,u.i),Ma(t),t=u.next,a=u.next;else if((t=u)===a){o?1===o?aa(t=ca(oa(t),e),e,r,n,i,s,2):2===o&&ha(t,e,r,n,i,s):aa(oa(t),e,r,n,i,s,1);break}}}function la(t){const e=t.prev,r=t,n=t.next;if(va(e,r,n)>=0)return!1;const i=e.x,s=r.x,o=n.x,a=e.y,l=r.y,u=n.y,c=is?i>o?i:o:s>o?s:o,f=a>l?a>u?a:u:l>u?l:u;let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&ga(i,a,s,l,o,u,d.x,d.y)&&va(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function ua(t,e,r,n){const i=t.prev,s=t,o=t.next;if(va(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=al?a>u?a:u:l>u?l:u,m=c>h?c>p?c:p:h>p?h:p,g=ya(f,d,e,r,n),x=ya(y,m,e,r,n);let v=t.prevZ,b=t.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&&ga(a,c,l,h,u,p,v.x,v.y)&&va(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&&ga(a,c,l,h,u,p,b.x,b.y)&&va(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&&ga(a,c,l,h,u,p,v.x,v.y)&&va(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&&ga(a,c,l,h,u,p,b.x,b.y)&&va(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ca(t,e){let r=t;do{const n=r.prev,i=r.next.next;!ba(n,i)&&wa(n,r,r.next,i)&&ka(n,i)&&ka(i,n)&&(e.push(n.i,r.i,i.i),Ma(r),Ma(r.next),r=t=i),r=r.next}while(r!==t);return oa(r)}function ha(t,e,r,n,i,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&xa(o,t)){let a=Aa(o,t);return o=oa(o,o.next),a=oa(a,a.next),aa(o,e,r,n,i,s,0),void aa(a,e,r,n,i,s,0)}t=t.next}o=o.next}while(o!==t)}function pa(t,e){return t.x-e.x}function fa(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,o=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>o&&(o=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&ga(is.x||r.x===s.x&&da(s,r)))&&(s=r,c=e)}r=r.next}while(r!==a);return s}(t,e);if(!r)return e;const n=Aa(r,t);return oa(n,n.next),oa(r,r.next)}function da(t,e){return va(t.prev,t,e.prev)<0&&va(e.next,t,t.next)<0}function ya(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ma(t){let e=t,r=t;do{(e.x=(t-o)*(s-a)&&(t-o)*(n-a)>=(r-o)*(e-a)&&(r-o)*(s-a)>=(i-o)*(n-a)}function xa(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&wa(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(ka(t,e)&&ka(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.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!==t);return n}(t,e)&&(va(t.prev,t,e.prev)||va(t,e.prev,e))||ba(t,e)&&va(t.prev,t,t.next)>0&&va(e.prev,e,e.next)>0)}function va(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function ba(t,e){return t.x===e.x&&t.y===e.y}function wa(t,e,r,n){const i=Sa(va(t,e,r)),s=Sa(va(t,e,n)),o=Sa(va(r,n,t)),a=Sa(va(r,n,e));return i!==s&&o!==a||!(0!==i||!_a(t,r,e))||!(0!==s||!_a(t,n,e))||!(0!==o||!_a(r,t,n))||!(0!==a||!_a(r,e,n))}function _a(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Sa(t){return t>0?1:t<0?-1:0}function ka(t,e){return va(t.prev,t,t.next)<0?va(t,e,t.next)>=0&&va(t,t.prev,e)>=0:va(t,e,t.prev)<0||va(t,t.next,e)<0}function Aa(t,e){const r=za(t.i,t.x,t.y),n=za(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function Ia(t,e,r,n){const i=za(t,e,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 Ma(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function za(t,e,r){return{i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Pa(t,e,r){const n=r.patternDependencies;let i=!1;for(const r of e){const e=r.paint.get(`${t}-pattern`);e.isConstant()||(i=!0);const s=e.constantOr(null);s&&(i=!0,n[s.to]=!0,n[s.from]=!0)}return i}function Ca(t,e,r,n,i){const s=i.patternDependencies;for(const o of e){const e=o.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:n-1},r,{},i.availableImages),a=e.evaluate({zoom:n},r,{},i.availableImages),l=e.evaluate({zoom:n+1},r,{},i.availableImages);t=t&&t.name?t.name:t,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,s[t]=!0,s[a]=!0,s[l]=!0,r.patterns[o.id]={min:t,mid:a,max:l}}}return r}class Ba{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new ks,this.indexArray=new Es,this.indexArray2=new Fs,this.programConfigurations=new uo(t.layers,t.zoom),this.segments=new Ls,this.segments2=new Ls,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Pa("fill",this.layers,e);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 t){const t=this.layers[0]._featureFilter.needGeometry,c=go(o,t);if(!this.layers[0]._featureFilter.filter(new vi(this.zoom),c,r))continue;const h=i?n.evaluate(c,{},r,e.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:mo(o),patterns:{},sortKey:h};s.push(p)}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:o}=n;if(this.hasPattern){const t=Ca("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,i,s,r,{});e.featureIndex.insert(t[s].feature,i,s,o,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,na),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,r,n,i){for(const t of $e(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t>3}if(i--,1===n||2===n)s+=t.readSVarint(),o+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new Ra(s,o));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},qa.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,o=1/0,a=-1/0,l=1/0,u=-1/0;t.pos>3}if(n--,1===r||2===r)(i+=t.readSVarint())a&&(a=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,a,u]},qa.prototype.toGeoJSON=function(t,e,r){var n,i,s=this.extent*Math.pow(2,r),o=this.extent*t,a=this.extent*e,l=this.loadGeometry(),u=qa.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}Xa.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Za(this._pbf,e,this.extent,this._keys,this._values)};var Ya=Ga;function Ja(t,e,r){if(3===t){var n=new Ya(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}Oa.VectorTile=function(t,e){this.layers=t.readFields(Ja,{},e)},Oa.VectorTileFeature=ja,Oa.VectorTileLayer=Ga;const Ka=Oa.VectorTileFeature.types,Wa=Math.pow(2,13);function Qa(t,e,r,n,i,s,o,a){t.emplaceBack(e,r,2*Math.floor(n*Wa)+o,i*Wa*2,s*Wa*2,Math.round(a))}class tl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new As,this.centroidVertexArray=new _s,this.indexArray=new Es,this.programConfigurations=new uo(t.layers,t.zoom),this.segments=new Ls,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.features=[],this.hasPattern=Pa("fill-extrusion",this.layers,e);for(const{feature:n,id:i,index:s,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,a=go(n,t);if(!this.layers[0]._featureFilter.filter(new vi(this.zoom),a,r))continue;const l={id:i,sourceLayerIndex:o,index:s,geometry:t?a.geometry:mo(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Ca("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,s,r,{}),e.featureIndex.insert(n,l.geometry,s,o,this.index,!0)}}addFeatures(t,e,r){for(const t of this.features){const{geometry:n}=t;this.addFeature(t,n,t.index,e,r)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,La),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,$a.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,r,n,i){for(const r of $e(e,500)){const e={x:0,y:0,vertexCount:0};let n=0;for(const t of r)n+=t.length;let i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of r){if(0===t.length)continue;if(rl(t))continue;let r=0;for(let n=0;n=1){const o=t[n-1];if(!el(s,o)){i.vertexLength+4>Ls.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(o)._perp()._unit(),n=o.dist(s);r+n>32768&&(r=0),Qa(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,r),Qa(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,r),e.x+=2*s.x,e.y+=2*s.y,e.vertexCount+=2,r+=n,Qa(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,0,r),Qa(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,1,r),e.x+=2*o.x,e.y+=2*o.y,e.vertexCount+=2;const a=i.vertexLength;this.indexArray.emplaceBack(a,a+2,a+1),this.indexArray.emplaceBack(a+1,a+2,a+3),i.vertexLength+=4,i.primitiveLength+=2}}}}if(i.vertexLength+n>Ls.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==Ka[t.type])continue;const s=[],o=[],a=i.vertexLength;for(const t of r)if(0!==t.length){t!==r[0]&&o.push(s.length/2);for(let r=0;rpo)||t.y===e.y&&(t.y<0||t.y>po)}function rl(t){return t.every((t=>t.x<0))||t.every((t=>t.x>po))||t.every((t=>t.y<0))||t.every((t=>t.y>po))}let nl;qn("FillExtrusionBucket",tl,{omit:["layers","features"]});var il={get paint(){return nl=nl||new Ti({"fill-extrusion-opacity":new zi(w["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Pi(w["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new zi(w["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new zi(w["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ci(w["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Pi(w["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Pi(w["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new zi(w["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class sl extends Fi{constructor(t){super(t,il)}createBucket(t){return new tl(t)}queryRadius(){return Vo(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,r,n,s,o,a,l){const u=To(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,a),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),p=function(t,e,r,n){const s=[];for(const r of t){const t=[r.x,r.y,0,1];Ro(t,t,e),s.push(new i(t[0]/t[3],t[1]/t[3]))}return s}(u,l),f=function(t,e,r,n){const s=[],o=[],a=n[8]*e,l=n[9]*e,u=n[10]*e,c=n[11]*e,h=n[8]*r,p=n[9]*r,f=n[10]*r,d=n[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x,o=s.y,y=n[0]*e+n[4]*o+n[12],m=n[1]*e+n[5]*o+n[13],g=n[2]*e+n[6]*o+n[14],x=n[3]*e+n[7]*o+n[15],v=g+u,b=x+c,w=y+h,_=m+p,S=g+f,k=x+d,A=new i((y+a)/b,(m+l)/b);A.z=v/b,t.push(A);const I=new i(w/k,_/k);I.z=S/k,r.push(I)}s.push(t),o.push(r)}return[s,o]}(n,h,c,l);return function(t,e,r){let n=1/0;_o(r,e)&&(n=al(r,e[0]));for(let i=0;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Is,this.layoutVertexArray2=new Ms,this.indexArray=new Es,this.programConfigurations=new uo(t.layers,t.zoom),this.segments=new Ls,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Pa("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),i=!n.isConstant(),s=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=go(e,t);if(!this.layers[0]._featureFilter.filter(new vi(this.zoom),u,r))continue;const c=i?n.evaluate(u,{},r):void 0,h={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?u.geometry:mo(e),patterns:{},sortKey:c};s.push(h)}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:o}=n;if(this.hasPattern){const t=Ca("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,i,s,r,{});e.featureIndex.insert(t[s].feature,i,s,o,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,hl)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ul),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i){const s=this.layers[0].layout,o=s.get("line-join").evaluate(t,{}),a=s.get("line-cap"),l=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,a,l,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,n)}addLine(t,e,r,n,i,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l0;if(w&&e>l){const t=h.dist(p);if(t>2*u){const e=h.sub(h.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,d,0,0,c),p=e}}const S=p&&f;let k=S?r:o?"butt":n;if(S&&"round"===k&&(vi&&(k="bevel"),"bevel"===k&&(v>2&&(k="flipbevel"),v100)m=y.mult(-1);else{const t=v*d.add(y).mag()/d.sub(y).mag();m._perp()._mult(t*(_?-1:1))}this.addCurrentVertex(h,m,0,0,c),this.addCurrentVertex(h,m.mult(-1),0,0,c)}else if("bevel"===k||"fakeround"===k){const t=-Math.sqrt(v*v-1),e=_?t:0,r=_?0:t;if(p&&this.addCurrentVertex(h,d,e,r,c),"fakeround"===k){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*u){const e=h.add(f.sub(h)._mult(u/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,y,0,0,c),h=e}}}}addCurrentVertex(t,e,r,n,i,s=!1){const o=e.y*n-e.x,a=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,o,a,s,!0,-n,i),this.distance>dl/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,i,s))}addHalfVertex({x:t,y:e},r,n,i,s,o,a){const l=.5*(this.lineClips?this.scaledDistance*(dl-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<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,this.e2,u),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(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let ml,gl;qn("LineBucket",yl,{omit:["layers","patternFeatures"]});var xl={get paint(){return gl=gl||new Ti({"line-opacity":new Pi(w.paint_line["line-opacity"]),"line-color":new Pi(w.paint_line["line-color"]),"line-translate":new zi(w.paint_line["line-translate"]),"line-translate-anchor":new zi(w.paint_line["line-translate-anchor"]),"line-width":new Pi(w.paint_line["line-width"]),"line-gap-width":new Pi(w.paint_line["line-gap-width"]),"line-offset":new Pi(w.paint_line["line-offset"]),"line-blur":new Pi(w.paint_line["line-blur"]),"line-dasharray":new Bi(w.paint_line["line-dasharray"]),"line-pattern":new Ci(w.paint_line["line-pattern"]),"line-gradient":new Vi(w.paint_line["line-gradient"])})},get layout(){return ml=ml||new Ti({"line-cap":new zi(w.layout_line["line-cap"]),"line-join":new Pi(w.layout_line["line-join"]),"line-miter-limit":new zi(w.layout_line["line-miter-limit"]),"line-round-limit":new zi(w.layout_line["line-round-limit"]),"line-sort-key":new Pi(w.layout_line["line-sort-key"])})}};class vl extends Pi{possiblyEvaluate(t,e){return e=new vi(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=c({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let bl;class wl extends Fi{constructor(t){super(t,xl),this.gradientVersion=0,bl||(bl=new vl(xl.paint.properties["line-width"].specification),bl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof qt,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=bl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new yl(t)}queryRadius(t){const e=t,r=_l(Bo("line-width",this,e),Bo("line-gap-width",this,e)),n=Bo("line-offset",this,e);return r/2+Math.abs(n)+Vo(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,s,o,a){const l=To(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,a),u=a/2*_l(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),c=this.paint.get("line-offset").evaluate(e,r);return c&&(n=function(t,e){const r=[];for(let n=0;n=3)for(let e=0;e0?e+2*t:t}const Sl=Oi([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),kl=Oi([{name:"a_projected_pos",components:3,type:"Float32"}],4);Oi([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Al=Oi([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Oi([{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 Il=Oi([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function Ml(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),xi.applyArabicShaping&&(t=xi.applyArabicShaping(t)),t}(t.text,e,r)})),t}Oi([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4),Oi([{name:"triangle",components:3,type:"Uint16"}]),Oi([{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"}]),Oi([{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"}]),Oi([{type:"Float32",name:"offsetX"}]),Oi([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Oi([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const zl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Pl=24,Cl=Tl,Bl=function(t,e,r,n,i){var s,o,a=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+t[e+h],h+=p,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=u}return(f?-1:1)*o*Math.pow(2,s-n)},Vl=function(t,e,r,n,i,s){var o,a,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(a=0,o=c):o+h>=1?(a=(e*l-1)*Math.pow(2,i),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+f]=255&a,f+=d,a/=256,i-=8);for(o=o<0;t[r+f]=255&o,f+=d,o/=256,u-=8);t[r+f-d]|=128*y};function Tl(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Tl.Varint=0,Tl.Fixed64=1,Tl.Bytes=2,Tl.Fixed32=5;var El=4294967296,Fl=1/El,Dl="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function $l(t){return t.type===Tl.Bytes?t.readVarint()+t.pos:t.pos+1}function Ll(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Ol(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i]}function Rl(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Kl(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Tl.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Yl(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Kl(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Yl(this.buf,this.pos)+Yl(this.buf,this.pos+4)*El;return this.pos+=8,t},readSFixed64:function(){var t=Yl(this.buf,this.pos)+Kl(this.buf,this.pos+4)*El;return this.pos+=8,t},readFloat:function(){var t=Bl(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Bl(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return Ll(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return Ll(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return Ll(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return Ll(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return Ll(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return Ll(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Dl?function(t,e,r){return Dl.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(o=t[i+2],128==(192&(s=t[i+1]))&&128==(192&o)&&((u=(15&l)<<12|(63&s)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(o=t[i+2],a=t[i+3],128==(192&(s=t[i+1]))&&128==(192&o)&&128==(192&a)&&((u=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==Tl.Bytes)return t.push(this.readVarint(e));var r=$l(this);for(t=t||[];this.pos127;);else if(e===Tl.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Tl.Fixed32)this.pos+=4;else{if(e!==Tl.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7)}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Ol(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Vl(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Vl(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&Ol(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,Tl.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Rl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,jl,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Nl,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,ql,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Ul,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Zl,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Gl,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Xl,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Hl,e)},writeBytesField:function(t,e){this.writeTag(t,Tl.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Tl.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Tl.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Tl.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Tl.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Tl.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Tl.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Tl.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Tl.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Tl.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Wl=e(Cl);const Ql=3;function tu(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&uu[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const r=new au;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(ou.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function lu(t,e,r,n,i,s,o,a,l,u,c,h,p,f,d){const y=au.fromFeature(t,i);let m;h===iu.vertical&&y.verticalizePunctuation();const{processBidirectionalText:g,processStyledBidirectionalText:x}=xi;if(g&&1===y.sections.length){m=[];const t=g(y.toString(),gu(y,u,s,e,n,f));for(const e of t){const t=new au;t.text=e,t.sections=y.sections;for(let r=0;r0&&s>w&&(w=s)}else{const t=r[d.fontStack],n=t&&t[m];if(n&&n.rect)_=n.rect,v=n.metrics;else{const t=e[d.fontStack],r=t&&t[m];if(!r)continue;v=r.metrics}g=(i-d.scale)*Pl}A?(t.verticalizable=!0,b.push({glyph:m,imageName:S,x:p,y:f+g,vertical:A,scale:d.scale,fontStack:d.fontStack,sectionIndex:y,metrics:v,rect:_}),p+=k*d.scale+u):(b.push({glyph:m,imageName:S,x:p,y:f+g,vertical:A,scale:d.scale,fontStack:d.fontStack,sectionIndex:y,metrics:v,rect:_}),p+=v.advance*d.scale+u)}0!==b.length&&(d=Math.max(p-u,d),vu(b,0,b.length-1,m,w)),p=0;const _=s*i+w;v.lineOffset=Math.max(w,a),f+=_,y=Math.max(_,y),++g}var x;const v=f-su,{horizontalAlign:b,verticalAlign:w}=xu(o);(function(t,e,r,n,i,s,o,a,l){const u=(e-r)*i;let c=0;c=s!==o?-a*n-su:(-n*l+.5)*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=u,t.y+=c})(t.positionedLines,m,b,w,d,y,s,v,i.length),t.top+=-w*v,t.bottom=t.top+v,t.left+=-b*d,t.right=t.left+d}(b,e,r,n,m,o,a,l,h,u,p,d),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(v)&&b}const uu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},cu={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},hu={40:!0};function pu(t,e,r,n,i,s){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Pl/s+i:0}{const n=r[e.fontStack],s=n&&n[t];return s?s.metrics.advance*e.scale+i:0}}function fu(t,e,r,n){const i=Math.pow(t-e,2);return n?t=0;let u=0;for(let r=0;ru){const t=Math.ceil(s/u);i*=t/o,o=t}return{x1:n,y1:i,x2:n+s,y2:i+o}}function _u(t,e,r,n,i,s){const o=t.image;let a;if(o.content){const t=o.content,e=o.pixelRatio||1;a=[t[0]/e,t[1]/e,o.displaySize[0]-t[2]/e,o.displaySize[1]-t[3]/e]}const l=e.left*s,u=e.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=e.top*s,y=e.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}}const Su=255,ku=128,Au=Su*ku;function Iu(t,e){const{expression:r}=e;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new vi(t+1))};if("source"===r.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;it.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Oo([]),this.placementViewportMatrix=Oo([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Iu(this.zoom,e["text-size"]),this.iconSizeData=Iu(this.zoom,e["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.canOverlap="never"!==Mu(r,"text-overlap","text-allow-overlap")||"never"!==Mu(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((t=>iu[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Tu(new uo(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Tu(new uo(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new ms,this.lineVertexArray=new gs,this.symbolInstances=new ys,this.textAnchorOffsets=new vs}calculateGlyphDependencies(t,e,r,n,i){for(let s=0;s0)&&("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=e.iconDependencies,p=e.glyphDependencies,f=e.availableImages,d=new vi(this.zoom);for(const{feature:e,id:o,index:a,sourceLayerIndex:y}of t){const t=n._featureFilter.needGeometry,m=go(e,t);if(!n._featureFilter.filter(d,m,r))continue;let g,x;if(t||(m.geometry=mo(e)),l){const t=n.getValueAndResolveTokens("text-field",m,r,f),e=yt.factory(t),i=this.hasRTLText=this.hasRTLText||Vu(e);(!i||"unavailable"===xi.getRTLTextPluginStatus()||i&&xi.isParsed())&&(g=Ml(e,n,m))}if(u){const t=n.getValueAndResolveTokens("icon-image",m,r,f);x=t instanceof vt?t:vt.fromString(t)}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:e.properties,type:zu[e.type],sortKey:v}),x&&(h[x.name]=!0),g){const t=s.evaluate(m,{},r).join(","),e="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(iu.vertical)>=0;for(const r of g.sections)if(r.image)h[r.image.name]=!0;else{const n=oi(g.toString()),i=r.fontStack||t,s=p[i]=p[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n)}}}"line"===i.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++}function o(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function a(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const i={};for(let n=t.segment+1;n=0;r--)i[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Du,$u;qn("SymbolBucket",Fu,{omit:["layers","collisionBoxArray","features","compareText"]}),Fu.MAX_GLYPHS=65535,Fu.addDynamicAttributes=Bu;var Lu={get paint(){return $u=$u||new Ti({"icon-opacity":new Pi(w.paint_symbol["icon-opacity"]),"icon-color":new Pi(w.paint_symbol["icon-color"]),"icon-halo-color":new Pi(w.paint_symbol["icon-halo-color"]),"icon-halo-width":new Pi(w.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Pi(w.paint_symbol["icon-halo-blur"]),"icon-translate":new zi(w.paint_symbol["icon-translate"]),"icon-translate-anchor":new zi(w.paint_symbol["icon-translate-anchor"]),"text-opacity":new Pi(w.paint_symbol["text-opacity"]),"text-color":new Pi(w.paint_symbol["text-color"],{runtimeType:B,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Pi(w.paint_symbol["text-halo-color"]),"text-halo-width":new Pi(w.paint_symbol["text-halo-width"]),"text-halo-blur":new Pi(w.paint_symbol["text-halo-blur"]),"text-translate":new zi(w.paint_symbol["text-translate"]),"text-translate-anchor":new zi(w.paint_symbol["text-translate-anchor"])})},get layout(){return Du=Du||new Ti({"symbol-placement":new zi(w.layout_symbol["symbol-placement"]),"symbol-spacing":new zi(w.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new zi(w.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Pi(w.layout_symbol["symbol-sort-key"]),"symbol-z-order":new zi(w.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new zi(w.layout_symbol["icon-allow-overlap"]),"icon-overlap":new zi(w.layout_symbol["icon-overlap"]),"icon-ignore-placement":new zi(w.layout_symbol["icon-ignore-placement"]),"icon-optional":new zi(w.layout_symbol["icon-optional"]),"icon-rotation-alignment":new zi(w.layout_symbol["icon-rotation-alignment"]),"icon-size":new Pi(w.layout_symbol["icon-size"]),"icon-text-fit":new zi(w.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new zi(w.layout_symbol["icon-text-fit-padding"]),"icon-image":new Pi(w.layout_symbol["icon-image"]),"icon-rotate":new Pi(w.layout_symbol["icon-rotate"]),"icon-padding":new Pi(w.layout_symbol["icon-padding"]),"icon-keep-upright":new zi(w.layout_symbol["icon-keep-upright"]),"icon-offset":new Pi(w.layout_symbol["icon-offset"]),"icon-anchor":new Pi(w.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new zi(w.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new zi(w.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new zi(w.layout_symbol["text-rotation-alignment"]),"text-field":new Pi(w.layout_symbol["text-field"]),"text-font":new Pi(w.layout_symbol["text-font"]),"text-size":new Pi(w.layout_symbol["text-size"]),"text-max-width":new Pi(w.layout_symbol["text-max-width"]),"text-line-height":new zi(w.layout_symbol["text-line-height"]),"text-letter-spacing":new Pi(w.layout_symbol["text-letter-spacing"]),"text-justify":new Pi(w.layout_symbol["text-justify"]),"text-radial-offset":new Pi(w.layout_symbol["text-radial-offset"]),"text-variable-anchor":new zi(w.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Pi(w.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Pi(w.layout_symbol["text-anchor"]),"text-max-angle":new zi(w.layout_symbol["text-max-angle"]),"text-writing-mode":new zi(w.layout_symbol["text-writing-mode"]),"text-rotate":new Pi(w.layout_symbol["text-rotate"]),"text-padding":new zi(w.layout_symbol["text-padding"]),"text-keep-upright":new zi(w.layout_symbol["text-keep-upright"]),"text-transform":new Pi(w.layout_symbol["text-transform"]),"text-offset":new Pi(w.layout_symbol["text-offset"]),"text-allow-overlap":new zi(w.layout_symbol["text-allow-overlap"]),"text-overlap":new zi(w.layout_symbol["text-overlap"]),"text-ignore-placement":new zi(w.layout_symbol["text-ignore-placement"]),"text-optional":new zi(w.layout_symbol["text-optional"])})}};class Ou{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:M,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}qn("FormatSectionOverride",Ou,{omit:["defaultValue"]});class Ru extends Fi{constructor(t){super(t,Lu)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="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 t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||$r(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>t&&r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Fu(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Lu.paint.overridableProperties){if(!Ru.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new Ou(e),n=new Dr(r,e.property.specification);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Or("source",n):new Rr("composite",n,e.value.zoomStops),this.paint._values[t]=new Ii(e.property,i,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven())&&Ru.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Lu.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof yt)s(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof kt&&_t(e.value)===F?s(e.value.sections):e instanceof ce?s(e.sections):e.eachChild(t))},e=r.value;e._styleExpression&&t(e._styleExpression.expression)}return i}}let ju;var qu={get paint(){return ju=ju||new Ti({"background-color":new zi(w.paint_background["background-color"]),"background-pattern":new Bi(w.paint_background["background-pattern"]),"background-opacity":new zi(w.paint_background["background-opacity"])})}};class Uu extends Fi{constructor(t){super(t,qu)}}let Nu;var Zu={get paint(){return Nu=Nu||new Ti({"raster-opacity":new zi(w.paint_raster["raster-opacity"]),"raster-hue-rotate":new zi(w.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new zi(w.paint_raster["raster-brightness-min"]),"raster-brightness-max":new zi(w.paint_raster["raster-brightness-max"]),"raster-saturation":new zi(w.paint_raster["raster-saturation"]),"raster-contrast":new zi(w.paint_raster["raster-contrast"]),"raster-resampling":new zi(w.paint_raster["raster-resampling"]),"raster-fade-duration":new zi(w.paint_raster["raster-fade-duration"])})}};class Gu extends Fi{constructor(t){super(t,Zu)}}class Xu extends Fi{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}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 Hu(t){if("custom"===t.type)return new Xu(t);switch(t.type){case"background":return new Uu(t);case"circle":return new jo(t);case"fill":return new Fa(t);case"fill-extrusion":return new sl(t);case"heatmap":return new Wo(t);case"hillshade":return new ea(t);case"line":return new wl(t);case"raster":return new Gu(t);case"symbol":return new Ru(t)}}class Yu{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(t,e){for(const e of t){this._layerConfigs[e.id]=e;const t=this._layers[e.id]=Hu(e);t._featureFilter=Gr(t.filter),this.keyCache[e.id]&&delete this.keyCache[e.id]}for(const t of e)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=function(t,e){const r={};for(let n=0;nthis._layers[t.id])),r=e[0];if("none"===r.visibility)continue;const n=r.source||"";let i=this.familiesBySource[n];i||(i=this.familiesBySource[n]={});const s=r.sourceLayer||"_geojsonTileLayer";let o=i[s];o||(o=i[s]=[]),o.push(e)}}}class Ju{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Ku{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.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(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Wu{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new b(po,16,0),this.grid3D=new b(po,16,0),this.featureIndexArray=new ws,this.promoteId=e}insert(t,e,r,n,i,s){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i);const a=s?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&a.insert(o,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Oa.VectorTile(new Wl(this.rawTileData)).layers,this.sourceLayerCoder=new Ju(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,n){this.loadVTLayers();const s=t.params||{},o=po/t.tileSize/t.scale,a=Gr(s.filter),l=t.queryGeometry,u=t.queryPadding*o,c=tc(l),h=this.grid.query(c.minX-u,c.minY-u,c.maxX+u,c.maxY+u),p=tc(t.cameraQueryGeometry),f=this.grid3D.query(p.minX-u,p.minY-u,p.maxX+u,p.maxY+u,((e,r,n,s)=>function(t,e,r,n,s){for(const i of t)if(e<=i.x&&r<=i.y&&n>=i.x&&s>=i.y)return!0;const o=[new i(e,r),new i(e,s),new i(n,s),new i(n,r)];if(t.length>2)for(const e of o)if(Po(t,e))return!0;for(let e=0;e(p||(p=mo(e)),r.queryIntersectsFeature(l,e,n,p,this.z,t.transform,o,t.pixelPosMatrix))))}return d}loadMatchingFeature(t,e,r,n,i,s,o,a,l,u,h){const p=this.bucketLayerIDs[e];if(s&&!function(t,e){for(let r=0;r=0)return!0;return!1}(s,p))return;const f=this.sourceLayerCoder.decode(r),d=this.vtLayers[f].feature(n);if(i.needGeometry){const t=go(d,!0);if(!i.filter(new vi(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new vi(this.tileID.overscaledZ),d))return;const y=this.getId(d,f);for(let e=0;e{const o=e instanceof Mi?e.get(s):null;return o&&o.evaluate?o.evaluate(r,n,i):o}))}function tc(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return{minX:e,minY:r,maxX:n,maxY:i}}function ec(t,e){return e-t}qn("FeatureIndex",Wu,{omit:["rawTileData","sourceLayerCoder"]});class rc extends i{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n)}clone(){return new rc(this.x,this.y,this.angle,this.segment)}}function nc(t,e,r,n,i){if(void 0===e.segment||0===r)return!0;let s=e,o=e.segment+1,a=0;for(;a>-r/2;){if(o--,o<0)return!1;a-=t[o].dist(s),s=t[o]}a+=t[o].dist(t[o+1]),o++;const l=[];let u=0;for(;an;)u-=l.shift().angleDelta;if(u>i)return!1;o++,a+=e.dist(r)}return!0}function ic(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=Yt.number(n.x,i.x,c),p=Yt.number(n.y,i.y,c),f=new rc(h,p,i.angleTo(n),r);return f._round(),!o||nc(t,f,a,o,e)?f:void 0}l+=s}}function lc(t,e,r,n,i,s,o,a,l){const u=sc(n,s,o),c=oc(n,i),h=c*o,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new rc(g,x,y,e);r._round(),n&&!nc(t,r,s,n,i)||f.push(r)}}h+=d}return a||f.length||o||(f=uc(t,h/2,r,n,i,s,o,!0,l)),f}qn("Anchor",rc);const cc=eu;function hc(t,e,r,n){const s=[],o=t.image,a=o.pixelRatio,l=o.paddedRect.w-2*cc,u=o.paddedRect.h-2*cc;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const h=o.stretchX||[[0,l]],p=o.stretchY||[[0,u]],f=(t,e)=>t+e[1]-e[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,k=0,A=g;if(o.content&&n){const e=o.content,r=e[2]-e[0],n=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(c=wu(t)),x=pc(h,0,e[0]),b=pc(p,0,e[1]),v=pc(h,e[0],e[2]),w=pc(p,e[1],e[3]),_=e[0]-x,k=e[1]-b,S=r-v,A=n-w}const I=c.x1,M=c.y1,z=c.x2-I,P=c.y2-M,C=(t,n,s,l)=>{const u=dc(t.stretch-x,v,z,I),c=yc(t.fixed-_,S,t.stretch,d),h=dc(n.stretch-b,w,P,M),p=yc(n.fixed-k,A,n.stretch,y),f=dc(s.stretch-x,v,z,I),m=yc(s.fixed-_,S,s.stretch,d),g=dc(l.stretch-b,w,P,M),C=yc(l.fixed-k,A,l.stretch,y),B=new i(u,h),V=new i(f,h),T=new i(f,g),E=new i(u,g),F=new i(c/a,p/a),D=new i(m/a,C/a),$=e*Math.PI/180;if($){const t=Math.sin($),e=Math.cos($),r=[e,-t,t,e];B._matMult(r),V._matMult(r),E._matMult(r),T._matMult(r)}const L=t.stretch+t.fixed,O=n.stretch+n.fixed;return{tl:B,tr:V,bl:E,br:T,tex:{x:o.paddedRect.x+cc+L,y:o.paddedRect.y+cc+O,w:s.stretch+s.fixed-L,h:l.stretch+l.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:D,minFontScaleX:S/a/z,minFontScaleY:A/a/P,isSDF:r}};if(n&&(o.stretchX||o.stretchY)){const t=fc(h,m,d),e=fc(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)?wu(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 t=new i(u.x1,u.y1),e=new i(u.x2,u.y1),r=new i(u.x1,u.y2),n=new i(u.x2,u.y2),s=c*Math.PI/180;t._rotate(s),e._rotate(s),r._rotate(s),n._rotate(s),u.x1=Math.min(t.x,e.x,r.x,n.x),u.x2=Math.max(t.x,e.x,r.x,n.x),u.y1=Math.min(t.y,e.y,r.y,n.y),u.y2=Math.max(t.y,e.y,r.y,n.y)}t.emplaceBack(e.x,e.y,u.x1,u.y1,u.x2,u.y2,r,n,s)}this.boxEndIndex=t.length}}class gc{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i}e[t]=n}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n}e[t]=i}}function xc(t,e=1,r=!1){let n=1/0,s=1/0,o=-1/0,a=-1/0;const l=t[0];for(let t=0;to)&&(o=e.x),(!t||e.y>a)&&(a=e.y)}const u=Math.min(o-n,a-s);let c=u/2;const h=new gc([],vc);if(0===u)return new i(n,s);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new bc(n.p.x-c,n.p.y-c,c,t)),h.push(new bc(n.p.x+c,n.p.y-c,c,t)),h.push(new bc(n.p.x-c,n.p.y+c,c,t)),h.push(new bc(n.p.x+c,n.p.y+c,c,t)),f+=4)}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function vc(t,e){return e.max-t.max}function bc(t,e,r,n){this.p=new i(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=a.y>t.y&&t.x<(a.x-i.x)*(t.y-i.y)/(a.y-i.y)+i.x&&(r=!r),n=Math.min(n,Mo(t,i,a))}}return(r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}var wc;!function(t){t[t.center=1]="center",t[t.left=2]="left",t[t.right=3]="right",t[t.top=4]="top",t[t.bottom=5]="bottom",t[t["top-left"]=6]="top-left",t[t["top-right"]=7]="top-right",t[t["bottom-left"]=8]="bottom-left",t[t["bottom-right"]=9]="bottom-right"}(wc||(wc={}));const _c=7,Sc=Number.POSITIVE_INFINITY;function kc(t,e){return e[1]!==Sc?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-_c;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+_c}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}return[n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=i-_c;break;case"bottom-right":case"bottom-left":n=-i+_c;break;case"bottom":n=-e+_c;break;case"top":n=e-_c}switch(t){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=e;break;case"right":r=-e}return[r,n]}(t,e[0])}function Ac(t,e,r){var n;const i=t.layout,s=null===(n=i.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},r);if(s){const t=s.values,e=[];for(let r=0;rt*Pl));n.startsWith("top")?i[1]-=_c:n.startsWith("bottom")&&(i[1]+=_c),e[r+1]=i}return new xt(e)}const o=i.get("text-variable-anchor");if(o){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[i.get("text-radial-offset").evaluate(e,{},r)*Pl,Sc]:i.get("text-offset").evaluate(e,{},r).map((t=>t*Pl));const s=[];for(const t of o)s.push(t,kc(t,n));return new xt(s)}return null}function Ic(t){t.bucket.createArrays(),t.bucket.tilePixelRatio=po/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;const e=t.bucket.layers[0],r=e.layout,n=e._unevaluatedLayout._values,i={layoutIconSize:n["icon-size"].possiblyEvaluate(new vi(t.bucket.zoom+1),t.canonical),layoutTextSize:n["text-size"].possiblyEvaluate(new vi(t.bucket.zoom+1),t.canonical),textMaxSize:n["text-size"].possiblyEvaluate(new vi(18))};if("composite"===t.bucket.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.bucket.textSizeData;i.compositeTextSizes=[n["text-size"].possiblyEvaluate(new vi(e),t.canonical),n["text-size"].possiblyEvaluate(new vi(r),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.bucket.iconSizeData;i.compositeIconSizes=[n["icon-size"].possiblyEvaluate(new vi(e),t.canonical),n["icon-size"].possiblyEvaluate(new vi(r),t.canonical)]}const s=r.get("text-line-height")*Pl,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 t.bucket.features){const u=r.get("text-font").evaluate(n,{},t.canonical).join(","),c=l.evaluate(n,{},t.canonical),h=i.layoutTextSize.evaluate(n,{},t.canonical),p=i.layoutIconSize.evaluate(n,{},t.canonical),f={horizontal:{},vertical:void 0},y=n.text;let m,g=[0,0];if(y){const i=y.toString(),l=r.get("text-letter-spacing").evaluate(n,{},t.canonical)*Pl,p=ai(i)?l:0,d=r.get("text-anchor").evaluate(n,{},t.canonical),m=Ac(e,n,t.canonical);if(!m){const e=r.get("text-radial-offset").evaluate(n,{},t.canonical);g=e?kc(d,[e*Pl,Sc]):r.get("text-offset").evaluate(n,{},t.canonical).map((t=>t*Pl))}let x=o?"center":r.get("text-justify").evaluate(n,{},t.canonical);const v="point"===r.get("symbol-placement")?r.get("text-max-width").evaluate(n,{},t.canonical)*Pl:1/0,b=()=>{t.bucket.allowVerticalPlacement&&oi(i)&&(f.vertical=lu(y,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,d,"left",p,g,iu.vertical,!0,h,c))};if(!o&&m){const e=new Set;if("auto"===x)for(let t=0;t{l.x<0||l.x>=po||l.y<0||l.y>=po||function(t,e,r,n,i,s,o,a,l,u,c,h,p,f,y,m,g,x,v,b,w,_,S,k,A){const I=t.addToLineVertexArray(e,r);let M,z,P,C,B=0,V=0,T=0,E=0,F=-1,D=-1;const $={};let L=Xs("");if(t.allowVerticalPlacement&&n.vertical){const t=a.layout.get("text-rotate").evaluate(w,{},k)+90;P=new mc(l,e,u,c,h,n.vertical,p,f,y,t),o&&(C=new mc(l,e,u,c,h,o,g,x,y,t))}if(i){const r=a.layout.get("icon-rotate").evaluate(w,{}),n="none"!==a.layout.get("icon-text-fit"),s=hc(i,r,S,n),p=o?hc(o,r,S,n):void 0;z=new mc(l,e,u,c,h,i,g,x,!1,r),B=4*s.length;const f=t.iconSizeData;let y=null;"source"===f.kind?(y=[ku*a.layout.get("icon-size").evaluate(w,{})],y[0]>Au&&d(`${t.layerIds[0]}: Value for "icon-size" is >= ${Su}. Reduce your "icon-size".`)):"composite"===f.kind&&(y=[ku*_.compositeIconSizes[0].evaluate(w,{},k),ku*_.compositeIconSizes[1].evaluate(w,{},k)],(y[0]>Au||y[1]>Au)&&d(`${t.layerIds[0]}: Value for "icon-size" is >= ${Su}. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,y,b,v,w,iu.none,e,I.lineStartIndex,I.lineLength,-1,k),F=t.icon.placedSymbolArray.length-1,p&&(V=4*p.length,t.addSymbols(t.icon,p,y,b,v,w,iu.vertical,e,I.lineStartIndex,I.lineLength,-1,k),D=t.icon.placedSymbolArray.length-1)}const O=Object.keys(n.horizontal);for(const r of O){const i=n.horizontal[r];if(!M){L=Xs(i.text);const t=a.layout.get("text-rotate").evaluate(w,{},k);M=new mc(l,e,u,c,h,i,p,f,y,t)}const o=1===i.positionedLines.length;if(T+=Pc(t,e,i,s,a,y,w,m,I,n.vertical?iu.horizontal:iu.horizontalOnly,o?O:[r],$,F,_,k),o)break}n.vertical&&(E+=Pc(t,e,n.vertical,s,a,y,w,m,I,iu.vertical,["vertical"],$,D,_,k));const R=M?M.boxStartIndex:t.collisionBoxArray.length,j=M?M.boxEndIndex:t.collisionBoxArray.length,q=P?P.boxStartIndex:t.collisionBoxArray.length,U=P?P.boxEndIndex:t.collisionBoxArray.length,N=z?z.boxStartIndex:t.collisionBoxArray.length,Z=z?z.boxEndIndex:t.collisionBoxArray.length,G=C?C.boxStartIndex:t.collisionBoxArray.length,X=C?C.boxEndIndex:t.collisionBoxArray.length;let H=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(M,H),H=Y(P,H),H=Y(z,H),H=Y(C,H);const J=H>-1?1:0;J&&(H*=A/Pl),t.glyphOffsetArray.length>=Fu.MAX_GLYPHS&&d("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,w.sortKey);const K=Ac(a,w,k),[W,Q]=function(t,e){const r=t.length,n=null==e?void 0:e.values;if((null==n?void 0:n.length)>0)for(let e=0;e=0?$.right:-1,$.center>=0?$.center:-1,$.left>=0?$.left:-1,$.vertical||-1,F,D,L,R,j,q,U,N,Z,G,X,u,T,E,B,V,J,0,p,H,W,Q)}(t,l,i,r,n,s,C,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,x,[_,_,_,_],A,u,b,S,I,y,e,o,c,h,a)};if("line"===M)for(const s of function(t,e,r,n,s){const o=[];for(let e=0;e=n&&l.x>=n||(e.x>=n?e=new i(n,e.y+(n-e.x)/(l.x-e.x)*(l.y-e.y))._round():l.x>=n&&(l=new i(n,e.y+(n-e.x)/(l.x-e.x)*(l.y-e.y))._round()),e.y>=s&&l.y>=s||(e.y>=s?e=new i(e.x+(s-e.y)/(l.y-e.y)*(l.x-e.x),s)._round():l.y>=s&&(l=new i(e.x+(s-e.y)/(l.y-e.y)*(l.x-e.x),s)._round()),a&&e.equals(a[a.length-1])||(a=[e],o.push(a)),a.push(l)))))}}return o}(e.geometry,0,0,po,po)){const e=lc(s,w,k,r.vertical||m,n,24,v,t.overscaling,po);for(const r of e)m&&Bc(t,m.text,z,r)||B(s,r)}else if("line-center"===M){for(const t of e.geometry)if(t.length>1){const e=ac(t,k,r.vertical||m,n,24,v);e&&B(t,e)}}else if("Polygon"===e.type)for(const t of $e(e.geometry,0)){const e=xc(t,16);B(t[0],new rc(e.x,e.y,0))}else if("LineString"===e.type)for(const t of e.geometry)B(t,new rc(t[0].x,t[0].y,0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)B([e],new rc(e.x,e.y,0))}function Pc(t,e,r,n,s,o,a,l,u,c,h,p,f,y,m){const g=function(t,e,r,n,s,o,a,l){const u=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const n of t.positionedGlyphs){if(!n.rect)continue;const o=n.rect||{};let h=Ql+1,p=!0,f=1,d=0;const y=(s||l)&&n.vertical,m=n.metrics.advance*n.scale/2;if(l&&e.verticalizable&&(d=t.lineOffset/2-(n.imageName?-(Pl-n.metrics.width*n.scale)/2:(n.scale-1)*Pl)),n.imageName){const t=a[n.imageName];p=t.sdf,f=t.pixelRatio,h=eu/f}const g=s?[n.x+m,n.y]:[0,0];let x=s?[0,0]:[n.x+m+r[0],n.y+r[1]-d],v=[0,0];y&&(v=x,x=[0,0]);const b=n.metrics.isDoubleResolution?2:1,w=(n.metrics.left-h)*n.scale-m+x[0],_=(-n.metrics.top-h)*n.scale+x[1],S=w+o.w/b*n.scale/f,k=_+o.h/b*n.scale/f,A=new i(w,_),I=new i(S,_),M=new i(w,k),z=new i(S,k);if(y){const t=new i(-m,m-su),e=-Math.PI/2,r=Pl/2-m,s=new i(5-su-r,-(n.imageName?r:0)),o=new i(...v);A._rotateAround(e,t)._add(s)._add(o),I._rotateAround(e,t)._add(s)._add(o),M._rotateAround(e,t)._add(s)._add(o),z._rotateAround(e,t)._add(s)._add(o)}if(u){const t=Math.sin(u),e=Math.cos(u),r=[e,-t,t,e];A._matMult(r),I._matMult(r),M._matMult(r),z._matMult(r)}const P=new i(0,0),C=new i(0,0);c.push({tl:A,tr:I,bl:M,br:z,tex:o,writingMode:e.writingMode,glyphOffset:g,sectionIndex:n.sectionIndex,isSDF:p,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0})}return c}(0,r,l,s,o,a,n,t.allowVerticalPlacement),x=t.textSizeData;let v=null;"source"===x.kind?(v=[ku*s.layout.get("text-size").evaluate(a,{})],v[0]>Au&&d(`${t.layerIds[0]}: Value for "text-size" is >= ${Su}. Reduce your "text-size".`)):"composite"===x.kind&&(v=[ku*y.compositeTextSizes[0].evaluate(a,{},m),ku*y.compositeTextSizes[1].evaluate(a,{},m)],(v[0]>Au||v[1]>Au)&&d(`${t.layerIds[0]}: Value for "text-size" is >= ${Su}. Reduce your "text-size".`)),t.addSymbols(t.text,g,v,l,o,a,c,e,u.lineStartIndex,u.lineLength,f,m);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*g.length}function Cc(t){for(const e in t)return t[e];return null}function Bc(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fc(function(t,e,r){const n=((t-e)%360+360)%360+e;return n===e?180:n}(this.lng,-180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Ec*Math.acos(Math.min(i,1))}static convert(t){if(t instanceof Fc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Fc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Fc(Number("lng"in t?t.lng:t.lon),Number(t.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 Dc=2*Math.PI*Ec;function $c(t){return Dc*Math.cos(t*Math.PI/180)}function Lc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class Oc{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r}static fromLngLat(t,e=0){const r=Fc.convert(t);return new Oc((180+r.lng)/360,(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r.lat*Math.PI/360)))/360,function(t,e){return t/$c(e)}(e,r.lat))}toLngLat(){return new Fc(360*this.x-180,Lc(this.y))}toAltitude(){return this.z*$c(Lc(this.y))}meterInMercatorCoordinateUnits(){return 1/Dc*(t=Lc(this.y),1/Math.cos(t*Math.PI/180));var t}}class Rc{constructor(t,e,r){if(!function(t,e,r){return!(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,r))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=Uc(0,t,t,e,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(s=this.y,o=this.z,a=Tc(256*(i=this.x),256*(s=Math.pow(2,o)-s-1),o),l=Tc(256*(i+1),256*(s+1),o),a[0]+","+a[1]+","+l[0]+","+l[1]);var i,s,o,a,l;const u=function(t,e,r){let n,i="";for(let s=t;s>0;s--)n=1<1?"@2x":"").replace(/{quadkey}/g,u).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new i((t.x*e-this.x)*po,(t.y*e-this.y)*po)}toString(){return`${this.z}/${this.x}/${this.y}`}}class jc{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Uc(t,e.z,e.z,e.x,e.y)}}class qc{constructor(t,e,r,n,i){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Rc(r,+n,+i),this.key=Uc(e,t,r,n,i)}clone(){return new qc(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new qc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new qc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?Uc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Uc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new qc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new qc(e,this.wrap,e,r,n),new qc(e,this.wrap,e,r+1,n),new qc(e,this.wrap,e,r,n+1),new qc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=e.maxzoom||"none"!==e.visibility&&(Zc(t,this.zoom,n),(o[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:u,sourceID:this.source})).populate(c,a,this.tileID.canonical),s.bucketLayerIDs.push(t.map((t=>t.id))))}}const u=h(a.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.abort())),this.inFlightDependencies=[];let c=Promise.resolve({});if(Object.keys(u).length){const t=new AbortController;this.inFlightDependencies.push(t),c=i.sendAsync({type:"GG",data:{stacks:u,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const p=Object.keys(a.iconDependencies);let f=Promise.resolve({});if(p.length){const t=new AbortController;this.inFlightDependencies.push(t),f=i.sendAsync({type:"GI",data:{icons:p,source:this.source,tileID:this.tileID,type:"icons"}},t)}const y=Object.keys(a.patternDependencies);let m=Promise.resolve({});if(y.length){const t=new AbortController;this.inFlightDependencies.push(t),m=i.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const[g,x,v]=yield Promise.all([c,f,m]),b=new Vc(g),w=new nu(x,v);for(const t in o){const e=o[t];e instanceof Fu?(Zc(e.layers,this.zoom,n),Ic({bucket:e,glyphMap:g,glyphPositions:b.positions,imageMap:x,imagePositions:w.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):e.hasPattern&&(e instanceof yl||e instanceof Ba||e instanceof tl)&&(Zc(e.layers,this.zoom,n),e.addFeatures(a,this.tileID.canonical,w.patternPositions))}return this.status="done",{buckets:Object.values(o).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:w,glyphMap:this.returnDependencies?g:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function Zc(t,e,r){const n=new vi(e);for(const e of t)e.recalculate(n,r)}var Gc;!function(t){t.create="create",t.load="load",t.fullLoad="fullLoad"}(Gc||(Gc={}));class Xc{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}}class Hc{constructor(t,e,r){this.actor=t,this.layerIndex=e,this.availableImages=r,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(e,r){return t(this,void 0,void 0,(function*(){const t=yield((t,e)=>Rn(c(t,{type:"arrayBuffer"}),e))(e.request,r);try{return{vectorTile:new Oa.VectorTile(new Wl(t.data)),rawData:t.data,cacheControl:t.cacheControl,expires:t.expires}}catch(r){const n=new Uint8Array(t.data);let i=`Unable to parse the tile at ${e.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(e){return t(this,void 0,void 0,(function*(){const t=e.uid,r=!!(e&&e.request&&e.request.collectResourceTiming)&&new Xc(e.request),n=new Nc(e);this.loading[t]=n;const i=new AbortController;n.abort=i;try{const s=yield this.loadVectorTile(e,i);if(delete this.loading[t],!s)return null;const o=s.rawData,a={};s.expires&&(a.expires=s.expires),s.cacheControl&&(a.cacheControl=s.cacheControl);const l={};if(r){const t=r.finish();t&&(l.resourceTiming=JSON.parse(JSON.stringify(t)))}n.vectorTile=s.vectorTile;const u=n.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[t]=n,this.fetching[t]={rawTileData:o,cacheControl:a,resourceTiming:l};try{const t=yield u;return c({rawTileData:o.slice(0)},t,a,l)}finally{delete this.fetching[t]}}catch(e){throw delete this.loading[t],n.status="done",this.loaded[t]=n,e}}))}reloadTile(e){return t(this,void 0,void 0,(function*(){const t=e.uid;if(!this.loaded||!this.loaded[t])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[t];if(r.showCollisionBoxes=e.showCollisionBoxes,"parsing"===r.status){const e=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor);let n;if(this.fetching[t]){const{rawTileData:r,cacheControl:i,resourceTiming:s}=this.fetching[t];delete this.fetching[t],n=c({rawTileData:r.slice(0)},e,i,s)}else n=e;return n}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor)}))}abortTile(e){return t(this,void 0,void 0,(function*(){const t=this.loading,r=e.uid;t&&t[r]&&t[r].abort&&(t[r].abort.abort(),delete t[r])}))}removeTile(e){return t(this,void 0,void 0,(function*(){this.loaded&&this.loaded[e.uid]&&delete this.loaded[e.uid]}))}}class Yc{constructor(t,e,r,n=1,i=1,s=1,o=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r))return void d(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const a=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),r){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=n,this.greenFactor=i,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;tthis.max&&(this.max=r),r=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}unpack(t,e,r){return t*this.redFactor+e*this.greenFactor+r*this.blueFactor-this.baseShift}getPixels(){return new Jo({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,o=r*this.dim+this.dim;switch(e){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=-e*this.dim,l=-r*this.dim;for(let e=s;e=Math.abs(a)?r-l+a:a-l+r,r=l}r+n>=0!=!!e&&t.reverse()}var Qc=e((function t(e,r){var n,i=e&&e.type;if("FeatureCollection"===i)for(n=0;n>31}function yh(t,e){for(var r=t.loadGeometry(),n=t.type,i=0,s=0,o=r.length,a=0;a>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=xh[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new vh(o,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=xh.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*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,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return bh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize: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>=t&&a<=r&&u>=e&&u<=n&&l.push(i[o])}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(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(t,e,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++)kh(i[2*r],i[2*r+1],t,e)<=l&&a.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];kh(f,d,t,e)<=l&&a.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(o.push(p+1),o.push(c),o.push(1-u))}return a}}function bh(t,e,r,n,i,s){if(i-n<=r)return;const o=n+i>>1;wh(t,e,o,n,i,s),bh(t,e,r,n,o-1,1-s),bh(t,e,r,o+1,i,1-s)}function wh(t,e,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);wh(t,e,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=e[2*r+s];let a=n,l=i;for(_h(t,e,n,r),e[2*i+s]>o&&_h(t,e,n,i);ao;)l--}e[2*n+s]===o?_h(t,e,n,l):(l++,_h(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1)}}function _h(t,e,r,n){Sh(t,r,n),Sh(e,2*r,2*n),Sh(e,2*r+1,2*n+1)}function Sh(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function kh(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}const Ah={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},Ih=Math.fround||(Mh=new Float32Array(1),t=>(Mh[0]=+t,Mh[0]));var Mh;const zh=3,Ph=5,Ch=6;class Bh{constructor(t){this.options=Object.assign(Object.create(Ah),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:r,maxZoom:n}=this.options;e&&console.time("total time");const i=`prepare ${t.length} points`;e&&console.time(i),this.points=t;const s=[];for(let e=0;e=r;t--){const r=+Date.now();o=this.trees[t]=this._createTree(this._cluster(o,t)),e&&console.log("z%d: %d clusters in %dms",t,o.numItems,+Date.now()-r)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let r=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let i=180===t[2]?180:((t[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,i=180;else if(r>i){const t=this.getClusters([r,n,180,s],e),o=this.getClusters([-180,n,i,s],e);return t.concat(o)}const o=this.trees[this._limitZoom(e)],a=o.range(Eh(r),Fh(s),Eh(i),Fh(n)),l=o.data,u=[];for(const t of a){const e=this.stride*t;u.push(l[e+Ph]>1?Vh(l,e,this.clusterProps):this.points[l[e+zh]])}return u}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),n="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(n);const s=i.data;if(e*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[e*this.stride],s[e*this.stride+1],o),l=[];for(const e of a){const r=e*this.stride;s[r+4]===t&&l.push(s[r+Ph]>1?Vh(s,r,this.clusterProps):this.points[s[r+zh]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,r){const n=[];return this._appendLeaves(n,t,e=e||10,r=r||0,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],i=Math.pow(2,t),{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((e-a)/i,l,(e+1+a)/i,u),n.data,e,r,i,c),0===e&&this._addTileFeatures(n.range(1-a/i,l,1,u),n.data,i,r,i,c),e===i-1&&this._addTileFeatures(n.range(0,l,a/i,u),n.data,-1,r,i,c),c.features.length?c:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const r=this.getChildren(t);if(e++,1!==r.length)break;t=r[0].properties.cluster_id}return e}_appendLeaves(t,e,r,n,i){const s=this.getChildren(e);for(const e of s){const s=e.properties;if(s&&s.cluster?i+s.point_count<=n?i+=s.point_count:i=this._appendLeaves(t,s.cluster_id,r,n,i):i1;let l,u,c;if(a)l=Th(e,t,this.clusterProps),u=e[t],c=e[t+1];else{const r=this.points[e[t+zh]];l=r.properties;const[n,i]=r.geometry.coordinates;u=Eh(n),c=Fh(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?e[t+zh]:this.points[e[t+zh]].id,void 0!==p&&(h.id=p),s.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:r,extent:n,reduce:i,minPoints:s}=this.options,o=r/(n*Math.pow(2,e)),a=t.data,l=[],u=this.stride;for(let r=0;re&&(f+=a[r+Ph])}if(f>p&&f>=s){let t,s=n*p,o=c*p,d=-1;const y=((r/u|0)<<5)+(e+1)+this.points.length;for(const n of h){const l=n*u;if(a[l+2]<=e)continue;a[l+2]=e;const c=a[l+Ph];s+=a[l]*c,o+=a[l+1]*c,a[l+4]=y,i&&(t||(t=this._map(a,r,!0),d=this.clusterProps.length,this.clusterProps.push(t)),i(t,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 t=0;t1)for(const t of h){const r=t*u;if(!(a[r+2]<=e)){a[r+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+Ph]>1){const n=this.clusterProps[t[e+Ch]];return r?Object.assign({},n):n}const n=this.points[t[e+zh]].properties,i=this.options.map(n);return r&&i===n?Object.assign({},i):i}}function Vh(t,e,r){return{type:"Feature",id:t[e+zh],properties:Th(t,e,r),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Dh(t[e+1])]}};var n}function Th(t,e,r){const n=t[e+Ph],i=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,s=t[e+Ch],o=-1===s?{}:Object.assign({},r[s]);return Object.assign(o,{cluster:!0,cluster_id:t[e+zh],point_count:n,point_count_abbreviated:i})}function Eh(t){return t/360+.5}function Fh(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function Dh(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function $h(t,e,r,n){let i=n;const s=e+(r-e>>1);let o,a=r-e;const l=t[e],u=t[e+1],c=t[r],h=t[r+1];for(let n=e+3;ni)o=n,i=e;else if(e===i){const t=Math.abs(n-s);tn&&(o-e>3&&$h(t,e,o,n),t[o+2]=i,r-o>3&&$h(t,o,r,n))}function Lh(t,e,r,n,i,s){let o=i-r,a=s-n;if(0!==o||0!==a){const l=((t-r)*o+(e-n)*a)/(o*o+a*a);l>1?(r=i,n=s):l>0&&(r+=o*l,n+=a*l)}return o=t-r,a=e-n,o*o+a*a}function Oh(t,e,r,n){const i={id:null==t?null:t,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)Rh(i,r);else if("Polygon"===e)Rh(i,r[0]);else if("MultiLineString"===e)for(const t of r)Rh(i,t);else if("MultiPolygon"===e)for(const t of r)Rh(i,t[0]);return i}function Rh(t,e){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=e.length-3;e[2]=1,$h(e,0,a,r),e[a+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function Nh(t,e,r,n){for(let i=0;i1?1:r}function Xh(t,e,r,n,i,s,o,a){if(n/=e,s>=(r/=e)&&o=n)return null;const l=[];for(const e of t){const t=e.geometry;let s=e.type;const o=0===i?e.minX:e.minY,u=0===i?e.maxX:e.maxY;if(o>=r&&u=n)continue;let c=[];if("Point"===s||"MultiPoint"===s)Hh(t,c,r,n,i);else if("LineString"===s)Yh(t,c,r,n,i,!1,a.lineMetrics);else if("MultiLineString"===s)Kh(t,c,r,n,i,!1);else if("Polygon"===s)Kh(t,c,r,n,i,!0);else if("MultiPolygon"===s)for(const e of t){const t=[];Kh(e,t,r,n,i,!0),t.length&&c.push(t)}if(c.length){if(a.lineMetrics&&"LineString"===s){for(const t of c)l.push(Oh(e.id,s,t,e.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(Oh(e.id,s,c,e.tags))}}return l.length?l:null}function Hh(t,e,r,n,i){for(let s=0;s=r&&o<=n&&Wh(e,t[s],t[s+1],t[s+2])}}function Yh(t,e,r,n,i,s,o){let a=Jh(t);const l=0===i?Qh:tp;let u,c,h=t.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),e.push(a),a=Jh(t)),o&&(h+=u)}let p=t.length-3;const f=t[p],d=t[p+1],y=0===i?f:d;y>=r&&y<=n&&Wh(a,f,d,t[p+2]),p=a.length-3,s&&p>=3&&(a[p]!==a[0]||a[p+1]!==a[1])&&Wh(a,a[0],a[1],a[2]),a.length&&e.push(a)}function Jh(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Kh(t,e,r,n,i,s){for(const o of t)Yh(o,e,r,n,i,s,!1)}function Wh(t,e,r,n){t.push(e,r,n)}function Qh(t,e,r,n,i,s){const o=(s-e)/(n-e);return Wh(t,s,r+(i-r)*o,1),o}function tp(t,e,r,n,i,s){const o=(s-r)/(i-r);return Wh(t,e+(n-e)*o,s,1),o}function ep(t,e){const r=[];for(let n=0;n0&&e.size<(i?o:n))return void(r.numPoints+=e.length/3);const a=[];for(let t=0;to)&&(r.numSimplified++,a.push(e[t],e[t+1])),r.numPoints++;i&&function(t,e){let r=0;for(let e=0,n=t.length,i=n-2;e0===e)for(let e=0,r=t.length;e24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");let n=function(t,e){const r=[];if("FeatureCollection"===t.type)for(let n=0;n1&&console.time("creation"),p=this.tiles[h]=sp(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(p.source=t,null==i){if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(r!==s>>t||n!==o>>t)continue}}if(p.source=null,0===t.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=Xh(t,c,r-f,r+y,0,p.minX,p.maxX,l),_=Xh(t,c,r+d,r+m,0,p.minX,p.maxX,l);t=null,w&&(g=Xh(w,c,n-f,n+y,1,p.minY,p.maxY,l),x=Xh(w,c,n+d,n+m,1,p.minY,p.maxY,l),w=null),_&&(v=Xh(_,c,n-f,n+y,1,p.minY,p.maxY,l),b=Xh(_,c,n+d,n+m,1,p.minY,p.maxY,l),_=null),u>1&&console.timeEnd("clipping"),a.push(g||[],e+1,2*r,2*n),a.push(x||[],e+1,2*r,2*n+1),a.push(v||[],e+1,2*r+1,2*n),a.push(b||[],e+1,2*r+1,2*n+1)}}getTile(t,e,r){t=+t,e=+e,r=+r;const n=this.options,{extent:i,debug:s}=n;if(t<0||t>24)return null;const o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);let l,u=t,c=e,h=r;for(;!l&&u>0;)u--,c>>=1,h>>=1,l=this.tiles[cp(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,t,e,r),s>1&&console.timeEnd("drilling down"),this.tiles[a]?np(this.tiles[a],i):null):null}}function cp(t,e,r){return 32*((1<{s.properties=t;const e={};for(const t of o)e[t]=r[t].evaluate(i,s);return e},t.reduce=(t,e)=>{s.properties=e;for(const e of o)i.accumulated=t[e],t[e]=n[e].evaluate(i,s)},t}(e)).load((yield this._pendingData).features):(n=yield this._pendingData,new up(n,e.geojsonVtOptions)),this.loaded={};const t={};if(r){const n=r.finish();n&&(t.resourceTiming={},t.resourceTiming[e.source]=JSON.parse(JSON.stringify(n)))}return t}catch(t){if(delete this._pendingRequest,function(t){return t.message===Vn}(t))return{abandoned:!0};throw t}var n}))}getData(){return t(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(t){const e=this.loaded;return e&&e[t.uid]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,r){return t(this,void 0,void 0,(function*(){let t=yield this.loadGeoJSON(e,r);if(delete this._pendingRequest,"object"!=typeof t)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(Qc(t,!0),e.filter){const r=Lr(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const n=t.features.filter((t=>r.value.evaluate({zoom:0},t)));t={type:"FeatureCollection",features:n}}return t}))}loadGeoJSON(e,r){return t(this,void 0,void 0,(function*(){const{promoteId:t}=e;if(e.request){const n=yield((t,e)=>Rn(c(t,{type:"json"}),e))(e.request,r);return this._dataUpdateable=pp(n.data,t)?fp(n.data,t):void 0,n.data}if("string"==typeof e.data)try{const r=JSON.parse(e.data);return this._dataUpdateable=pp(r,t)?fp(r,t):void 0,r}catch(t){throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}if(!e.dataDiff)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${e.source}`);return function(t,e,r){var n,i,s,o;if(e.removeAll&&t.clear(),e.remove)for(const r of e.remove)t.delete(r);if(e.add)for(const n of e.add){const e=hp(n,r);null!=e&&t.set(e,n)}if(e.update)for(const r of e.update){let e=t.get(r.id);if(null==e)continue;const a=!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((r.newGeometry||r.removeAllProperties||a)&&(e=Object.assign({},e),t.set(r.id,e),a&&(e.properties=Object.assign({},e.properties))),r.newGeometry&&(e.geometry=r.newGeometry),r.removeAllProperties)e.properties={};else if((null===(s=r.removeProperties)||void 0===s?void 0:s.length)>0)for(const t of r.removeProperties)Object.prototype.hasOwnProperty.call(e.properties,t)&&delete e.properties[t];if((null===(o=r.addOrUpdateProperties)||void 0===o?void 0:o.length)>0)for(const{key:t,value:n}of r.addOrUpdateProperties)e.properties[t]=n}}(this._dataUpdateable,e.dataDiff,t),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(e){return t(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset)}}class yp{constructor(e){this.self=e,this.actor=new Yn(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(t,e)=>{if(this.externalWorkerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.externalWorkerSourceTypes[t]=e},this.self.addProtocol=Fn,this.self.removeProtocol=Dn,this.self.registerRTLTextPlugin=t=>{if(xi.isParsed())throw new Error("RTL text plugin already registered.");xi.setMethods(t)},this.actor.registerMessageHandler("LDT",((t,e)=>this._getDEMWorkerSource(t,e.source).loadTile(e))),this.actor.registerMessageHandler("RDT",((e,r)=>t(this,void 0,void 0,(function*(){this._getDEMWorkerSource(e,r.source).removeTile(r)})))),this.actor.registerMessageHandler("GCEZ",((e,r)=>t(this,void 0,void 0,(function*(){return this._getWorkerSource(e,r.type,r.source).getClusterExpansionZoom(r)})))),this.actor.registerMessageHandler("GCC",((e,r)=>t(this,void 0,void 0,(function*(){return this._getWorkerSource(e,r.type,r.source).getClusterChildren(r)})))),this.actor.registerMessageHandler("GCL",((e,r)=>t(this,void 0,void 0,(function*(){return this._getWorkerSource(e,r.type,r.source).getClusterLeaves(r)})))),this.actor.registerMessageHandler("LD",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadData(e))),this.actor.registerMessageHandler("GD",((t,e)=>this._getWorkerSource(t,e.type,e.source).getData())),this.actor.registerMessageHandler("LT",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadTile(e))),this.actor.registerMessageHandler("RT",((t,e)=>this._getWorkerSource(t,e.type,e.source).reloadTile(e))),this.actor.registerMessageHandler("AT",((t,e)=>this._getWorkerSource(t,e.type,e.source).abortTile(e))),this.actor.registerMessageHandler("RMT",((t,e)=>this._getWorkerSource(t,e.type,e.source).removeTile(e))),this.actor.registerMessageHandler("RS",((e,r)=>t(this,void 0,void 0,(function*(){if(!this.workerSources[e]||!this.workerSources[e][r.type]||!this.workerSources[e][r.type][r.source])return;const t=this.workerSources[e][r.type][r.source];delete this.workerSources[e][r.type][r.source],void 0!==t.removeSource&&t.removeSource(r)})))),this.actor.registerMessageHandler("RM",(e=>t(this,void 0,void 0,(function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e]})))),this.actor.registerMessageHandler("SR",((e,r)=>t(this,void 0,void 0,(function*(){this.referrer=r})))),this.actor.registerMessageHandler("SRPS",((t,e)=>this._syncRTLPluginState(t,e))),this.actor.registerMessageHandler("IS",((e,r)=>t(this,void 0,void 0,(function*(){this.self.importScripts(r)})))),this.actor.registerMessageHandler("SI",((t,e)=>this._setImages(t,e))),this.actor.registerMessageHandler("UL",((e,r)=>t(this,void 0,void 0,(function*(){this._getLayerIndex(e).update(r.layers,r.removedIds)})))),this.actor.registerMessageHandler("SL",((e,r)=>t(this,void 0,void 0,(function*(){this._getLayerIndex(e).replace(r)}))))}_setImages(e,r){return t(this,void 0,void 0,(function*(){this.availableImages[e]=r;for(const t in this.workerSources[e]){const n=this.workerSources[e][t];for(const t in n)n[t].availableImages=r}}))}_syncRTLPluginState(e,r){return t(this,void 0,void 0,(function*(){if(xi.isParsed())return xi.getState();if("loading"!==r.pluginStatus)return xi.setState(r),r;const t=r.pluginURL;if(this.self.importScripts(t),xi.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return xi.setState(e),e}throw xi.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new Yu),e}_getWorkerSource(t,e,r){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][r]){const n={sendAsync:(e,r)=>(e.targetMapId=t,this.actor.sendAsync(e,r))};switch(e){case"vector":this.workerSources[t][e][r]=new Hc(n,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][r]=new dp(n,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][r]=new this.externalWorkerSourceTypes[e](n,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][r]}_getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new Jc),this.demWorkerSources[t][e]}}return m(self)&&(self.worker=new yp(self)),yp}(); //# sourceMappingURL=maplibre-gl-csp-worker.js.map